WebAssembly / WebAssembly/wabt

Assertion fails in `return_call` test case when tracing is on

Open
#1,763 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C++
Stars
8.1k
Forks
827
Avg merge
4d 6h
Merged PRs (30d)
18

Description

When running the example in #1761 with tracing on, you get a crash due to an assertion failure like the following

$ wabt/out/clang/Debug/wasm-interp out/test/interp/return-call-get-local/return-call-get-local.wasm -t --run-all-exports --enable-tail-call
>>> running export "f":
#0.    0: V:0  | i64.const 1
#0.   12: V:1  | br @24
#0.   24: V:1  | i32.const 3
#0.   32: V:2  | drop_keep $1 $1
#0.   44: V:1  | br @68
#0.   68: V:1  | i32.const 2
wasm-interp: ../../../src/interp/interp.cc:192: wabt::interp::ValueType wabt::interp::FuncDesc::GetLocalType(wabt::interp::Index) const: Assertion `iter != locals.end()' failed.
Aborted (core dumped)

This is because the value stack height is set for the wrong function when a return_call is done, because it re-uses the existing stack frame without adjusting any of its values. It's probably easiest to fix this after #1749 lands because it also adjusts how return_call is executed.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the crash with the shown wasm-interp command and tracing enabled. Start at src/interp/interp.cc:192 and trace how return_call reuses the stack frame, especially after the execution changes from #1749. Done means the return_call test completes without the GetLocalType assertion while tracing remains enabled.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, wasm
Domain
devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.