Stream: general

Topic: ✔ too many locals: locals exceed maximum


view this post on Zulip Andrew Kelley (Jun 28 2022 at 00:19):

Hello, I have received this error from wasmtime 0.37.0:

Error: failed to run main module `../lib/std/zig-cache/o/e844be59deeadc476c0e3b7eecd89e75/test.wasm`

Caused by:
    0: WebAssembly translation error
    1: Invalid input WebAssembly code at offset 17178321: too many locals: locals exceed maximum

what can I do to find out what symbol is the one that has too many locals?

view this post on Zulip Alex Crichton (Jun 28 2022 at 00:47):

unfortunately it's not easy (and we should improve this error), but with the wasm-tools CLI you can:

view this post on Zulip Andrew Kelley (Jun 28 2022 at 00:49):

thanks for the tip!

view this post on Zulip Peter Huene (Jun 28 2022 at 00:53):

For context, 50000 is the maximum number of locals supported by the parser (that's a lot of locals...)

view this post on Zulip Andrew Kelley (Jun 28 2022 at 00:54):

yep there is a good chance the generated code here is shall we say... less than ideal :)

view this post on Zulip Andrew Kelley (Jun 28 2022 at 00:55):

first step to fixing the compiler is to find out where the bad code is!

view this post on Zulip Peter Huene (Jun 28 2022 at 00:57):

I'm happy to help find the offending function if you run into trouble

view this post on Zulip Andrew Kelley (Jun 28 2022 at 01:00):

hmm no wasm-tools in nixos yet it looks like. I'll grab a build from upstream

view this post on Zulip Andrew Kelley (Jun 28 2022 at 01:07):

hmm I'm a bit stuck on trying to get wasm-tools installed: https://clbin.com/vygfV

view this post on Zulip Alex Crichton (Jun 28 2022 at 01:08):

ah that's a rustc-too-old issue

view this post on Zulip Alex Crichton (Jun 28 2022 at 01:08):

you may be able to check out an older release and get it to work

view this post on Zulip Andrew Kelley (Jun 28 2022 at 01:09):

so that's git checkout <older tag> in the wasm-tools repo, then cargo install ?

view this post on Zulip Alex Crichton (Jun 28 2022 at 01:09):

yeah that should work

view this post on Zulip Alex Crichton (Jun 28 2022 at 01:09):

you'd want the wasm-tools-* tags I think

view this post on Zulip Andrew Kelley (Jun 28 2022 at 01:15):

alright I was able to get wasm-tools-1.0.3 built with cargo 1.56.0

view this post on Zulip Andrew Kelley (Jun 28 2022 at 01:20):

alright so I found the function that has a crap ton of locals but unfortunately no symbol name:

============== func 13896 ====================
0x105ae98 | d3 ef 27    | size of function
0x105ae9b | cb 73       | 14795 local blocks
0x105ae9d | 05 7f       | 5 locals of type I32
0x105ae9f | 01 7e       | 1 locals of type I64

is that something added to wasm-tools after 1.0.3?

view this post on Zulip Alex Crichton (Jun 28 2022 at 01:20):

for the symbol name info it'll be in the name custom section, probably at the end of the file

view this post on Zulip Alex Crichton (Jun 28 2022 at 01:21):

you can try searching for 13896 in the output

view this post on Zulip Alex Crichton (Jun 28 2022 at 01:21):

and it'll hopefully show up down there

view this post on Zulip Andrew Kelley (Jun 28 2022 at 01:21):

aha! 0x2a3edc1 | c8 6c 1e 63 | Naming { index: 13896, name: "crypto.25519.field.Fe.isSquare" }

thanks! now I'm hot on the trail

view this post on Zulip Alex Crichton (Jun 28 2022 at 01:22):

I opened https://github.com/bytecodealliance/wasmtime/pull/4340 to improve this

Add in the wasm function index, the name if specified, and the function offset in the original file to assist in debugging failed function compiles.

view this post on Zulip Notification Bot (Jun 29 2022 at 18:35):

Andrew Kelley has marked this topic as resolved.

view this post on Zulip Almog Baku (Jun 30 2022 at 13:18):

(deleted)

view this post on Zulip Almog Baku (Jun 30 2022 at 13:18):

(deleted)


Last updated: Oct 23 2024 at 20:03 UTC