Stream: git-wasmtime

Topic: wasmtime / issue #5400 Wasmtime: "Unknown" backtrace: Wha...


view this post on Zulip Wasmtime GitHub notifications bot (Dec 08 2022 at 20:47):

mablinov opened issue #5400:

Hi all,

I've been trying to get Lua ported to wasmtime for fun and educational value, and I've gotten as far as the prompt.

However, when I type something in, the interpreter explodes - which by itself is fine, but wasmtime doesn't give a terribly helpful backtrace when it happens, as illustrated below:

Lua 5.4.4  Copyright (C) 1994-2022 Lua.org, PUC-Rio
> 1 + 2
luaD_rawrunprotected: Entered
lua_pushcclosure: entered, L->top = 0x17910, L->ci->top = 0x17a60
lua_pcallk(): entered
luaD_rawrunprotected: Entered
lua_pcallk(): entered
luaD_rawrunprotected: Entered
Error: failed to run main module `lua.wasm`

Caused by:
    0: failed to invoke command default
    1: error while executing at wasm backtrace:
           0: 0xf2f3 - <unknown>!<wasm function 144>
           1: 0xd9e6 - <unknown>!<wasm function 129>
           2: 0xc7a9 - <unknown>!<wasm function 119>
           3: 0xc675 - <unknown>!<wasm function 118>
           4: 0xd23a - <unknown>!<wasm function 124>
           5: 0x106ab - <unknown>!<wasm function 154>
           6: 0x11ed6 - <unknown>!<wasm function 161>
           7: 0x12022 - <unknown>!<wasm function 163>
           8: 0x120fe - <unknown>!<wasm function 164>
           9: 0x8e38 - <unknown>!<wasm function 89>
          10: 0xf396 - <unknown>!<wasm function 145>
          11: 0x12351 - <unknown>!<wasm function 167>
          12: 0x8b00 - <unknown>!<wasm function 88>
          13: 0x274d - <unknown>!<wasm function 29>
          14: 0x2039 - <unknown>!<wasm function 22>
          15:  0xfdc - <unknown>!<wasm function 13>
          16: 0x11913 - <unknown>!<wasm function 159>
          17: 0x11c07 - <unknown>!<wasm function 161>
          18: 0x12022 - <unknown>!<wasm function 163>
          19: 0x120fe - <unknown>!<wasm function 164>
          20: 0x8e38 - <unknown>!<wasm function 89>
          21: 0xf396 - <unknown>!<wasm function 145>
          22: 0x12351 - <unknown>!<wasm function 167>
          23: 0x8b00 - <unknown>!<wasm function 88>
          24:  0xa2a - <unknown>!<wasm function 11>
          25: 0x5dd98 - <unknown>!<wasm function 686>
          26: 0x5dd2a - <unknown>!<wasm function 685>
    2: wasm trap: wasm `unreachable` instruction executed

I've tried building the project with -O0 -g3 flags, and launching lua.wasm with wasmtime -g flag, but I still get the un-annotated backtrace.

Is there something I'm missing?

view this post on Zulip Wasmtime GitHub notifications bot (Dec 08 2022 at 22:27):

alexcrichton commented on issue #5400:

The <unknown> in the backtrace is the module name, as listed in the core wasm's name section. This is almost always never specified so <unknown> there is somewhat expected.

The <wasm function NN>, however, means that the name section probably didn't exist in the original wasm binary. How are you compiling lua to wasm? Is it possible to turn off optimizations and turn on dwarf when compiling to wasm?

Note that Wasmtime's -O0 and -g flags here are orthogonal mostly. The -g flag to wasmtime is pretty broken (and we should probably remove it), and -O0 only affects cranelift code quality which doesn't affect debuggability through backtraces like this.

view this post on Zulip Wasmtime GitHub notifications bot (Dec 08 2022 at 23:08):

mablinov commented on issue #5400:

Hi @alexcrichton, thanks for explaining what the fields mean.

I'm building the Lua object files with -O0 -g3. For example:

emcc -Wall -O0 -g3  -Wfatal-errors -Wextra -Wshadow -Wsign-compare -Wundef -Wwrite-strings -Wredundant-decls -Wdisable
d-optimization -Wdouble-promotion -Wmissing-declarations  -Wdeclaration-after-statement -Wmissing-prototypes -Wnested-
externs -Wstrict-prototypes -Wc++-compat -Wold-style-definition  -std=c99 -DLUA_USE_APICHECK  -fno-stack-protector -fn
o-common   -c -o lvm.o lvm.c

Is the full build invocation for the lvm.o object file.

view this post on Zulip Wasmtime GitHub notifications bot (Dec 08 2022 at 23:28):

mablinov commented on issue #5400:

Just wanted to update: I've opened a parallel issue in the emscripten-core/emscripten repo (here), and it turns out that I just needed to build my object files with the --profiling-funcs flag.

Sorry about the noise - I'm often not sure whether my problems have to do with the compiler, or the runtime!

view this post on Zulip Wasmtime GitHub notifications bot (Dec 08 2022 at 23:28):

mablinov closed issue #5400:

Hi all,

I've been trying to get Lua ported to wasmtime for fun and educational value, and I've gotten as far as the prompt.

However, when I type something in, the interpreter explodes - which by itself is fine, but wasmtime doesn't give a terribly helpful backtrace when it happens, as illustrated below:

Lua 5.4.4  Copyright (C) 1994-2022 Lua.org, PUC-Rio
> 1 + 2
luaD_rawrunprotected: Entered
lua_pushcclosure: entered, L->top = 0x17910, L->ci->top = 0x17a60
lua_pcallk(): entered
luaD_rawrunprotected: Entered
lua_pcallk(): entered
luaD_rawrunprotected: Entered
Error: failed to run main module `lua.wasm`

Caused by:
    0: failed to invoke command default
    1: error while executing at wasm backtrace:
           0: 0xf2f3 - <unknown>!<wasm function 144>
           1: 0xd9e6 - <unknown>!<wasm function 129>
           2: 0xc7a9 - <unknown>!<wasm function 119>
           3: 0xc675 - <unknown>!<wasm function 118>
           4: 0xd23a - <unknown>!<wasm function 124>
           5: 0x106ab - <unknown>!<wasm function 154>
           6: 0x11ed6 - <unknown>!<wasm function 161>
           7: 0x12022 - <unknown>!<wasm function 163>
           8: 0x120fe - <unknown>!<wasm function 164>
           9: 0x8e38 - <unknown>!<wasm function 89>
          10: 0xf396 - <unknown>!<wasm function 145>
          11: 0x12351 - <unknown>!<wasm function 167>
          12: 0x8b00 - <unknown>!<wasm function 88>
          13: 0x274d - <unknown>!<wasm function 29>
          14: 0x2039 - <unknown>!<wasm function 22>
          15:  0xfdc - <unknown>!<wasm function 13>
          16: 0x11913 - <unknown>!<wasm function 159>
          17: 0x11c07 - <unknown>!<wasm function 161>
          18: 0x12022 - <unknown>!<wasm function 163>
          19: 0x120fe - <unknown>!<wasm function 164>
          20: 0x8e38 - <unknown>!<wasm function 89>
          21: 0xf396 - <unknown>!<wasm function 145>
          22: 0x12351 - <unknown>!<wasm function 167>
          23: 0x8b00 - <unknown>!<wasm function 88>
          24:  0xa2a - <unknown>!<wasm function 11>
          25: 0x5dd98 - <unknown>!<wasm function 686>
          26: 0x5dd2a - <unknown>!<wasm function 685>
    2: wasm trap: wasm `unreachable` instruction executed

I've tried building the project with -O0 -g3 flags, and launching lua.wasm with wasmtime -g flag, but I still get the un-annotated backtrace.

Is there something I'm missing?


Last updated: Dec 23 2024 at 12:05 UTC