Skip to content

Add --js-call-indirect option. #5864

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

Conversation

juj
Copy link
Collaborator

@juj juj commented Aug 8, 2023

Currently Chrome and Firefox are unhelpful in diagnosing call_indirect errors, but when one occurs, a blank error print

RuntimeError: null function or function signature mismatch

is logged.

This challenge was discussed in emscripten-core/emscripten#16126 and there were workarounds presented there:

  • one can build with -Wbad-function-cast -Wcast-function-type or even -Werror=bad-function-cast -Werror=cast-function-type. However, in our huge codebase, we get tons of diagnostics from these in 3rd party code paths that are never exercised, or are false positives, so it does not help one to target an immediate bug scenario - and would not help see into issues where the function pointers to call_indirect are either null, or corrupted.
  • one can build with UBSAN: -fsanitize=undefined. However unfortunately our codebase is too large, and we get a local count too large error.
  • in Chromium bug entry https://bugs.chromium.org/p/chromium/issues/detail?id=1350384# , Chrome authors did help Chrome's debugger to do better prints, but unfortunately our codebase is too large that Chrome dies attempting to debug it.

Hence I would like to improve the debuggability of call_indirects from the toolchain side to help figure out when the function signature does not match, or when the function pointer is bad.

To do that, my idea is to try to route all call_indirects instead over to js_call_indirect_sig functions on the JS import side, which could do analysis on the calls, and then refer to the WebAssembly.Table (wasmTable object in Emscripten JS runtime).

@juj juj force-pushed the js_call_indirect branch from a0fc882 to 412250c Compare August 9, 2023 14:13
@juj juj force-pushed the js_call_indirect branch from 412250c to 77000ef Compare August 9, 2023 14:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants