Skip to content

[JS Interop] Scan configureAll in the entire module, not just the start function#8727

Closed
kripken wants to merge 8 commits into
WebAssembly:mainfrom
kripken:configureAll.start
Closed

[JS Interop] Scan configureAll in the entire module, not just the start function#8727
kripken wants to merge 8 commits into
WebAssembly:mainfrom
kripken:configureAll.start

Conversation

@kripken
Copy link
Copy Markdown
Member

@kripken kripken commented May 19, 2026

Nice finding from fuzzing the start function + PreserveImportsExportsJS: it made
some configureAll function and called it not from the start. We did not handle
that.

Unfortunately we have a const Module which causes a headache in ModuleUtils
here. I added a small workaround for that - but maybe there is a better way?

@kripken kripken requested a review from tlively May 19, 2026 18:35
@kripken kripken requested a review from a team as a code owner May 19, 2026 18:35
@kripken
Copy link
Copy Markdown
Member Author

kripken commented May 19, 2026

If we want to avoid this overhead, and it would be nice to, some options:

  1. Keep the requirement to do this in the start, and fix the fuzzer instead. But we need to be sure our users aren't doing more.
  2. Look for the configureAll once, not a new scan each time we need that info. Perhaps during module load we could convert the configureAll into @binaryen.js.called annotations. Our users should really add those themselves, but this would auto-add it for convenience. With those annotations, we don't need to scan later.

@tlively
Copy link
Copy Markdown
Member

tlively commented May 19, 2026

2. Look for the configureAll once, not a new scan each time we need that info. Perhaps during module load we could convert the configureAll into @binaryen.js.called annotations. Our users should really add those themselves, but this would auto-add it for convenience. With those annotations, we don't need to scan later.

Doing this as an opt-in pass but requiring manual annotations by default might be a good compromise. Still maybe surprising for users who expect us to handle configureAll correctly by default, though :/ However, requiring manual annotations is the only solution that is robust for arbitrary usage of configureAll because figuring out what functions are passed to it is undecidable in general.

@kripken kripken mentioned this pull request May 20, 2026
@kripken
Copy link
Copy Markdown
Member Author

kripken commented May 20, 2026

Good idea, let's do that: #8733

@kripken kripken closed this May 20, 2026
@kripken kripken deleted the configureAll.start branch May 20, 2026 18:12
kripken added a commit that referenced this pull request May 20, 2026
This adds `@binaryen.js.called` to functions called from any
`configureAll`, even one not from the start function.

Addresses the issue in #8727, where fuzzing the start function can lead
to situations where a function is referred to from configureAll but not
marked as js-called, which can break optimizations. By using this in the
fuzzer, we can fuzz even files with interesting configureAll calls.
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