Skip to content

Assert that ReadBinaryIr is not used with skip_function_bodies - #2817

Merged
sbc100 merged 1 commit into
WebAssembly:mainfrom
Nishuuzz:fix/skip-function-bodies
Aug 11, 2026
Merged

sbc100 merged 1 commit into
WebAssembly:mainfrom
Nishuuzz:fix/skip-function-bodies

Conversation

@Nishuuzz

@Nishuuzz Nishuuzz commented Aug 10, 2026 •

Copy link
Copy Markdown
Contributor

ReadBinaryIr fails on any module that has a function in it once skip_function_bodies is set. Reading sqlite (built with emscripten) both ways:

skip_function_bodies=0 -> ok
skip_function_bodies=1 -> FAILED
    function 34 missing end marker

34 is just its first non-imported function, so it gives up on the first body it reaches.

BeginFunctionBody pushes a label for the function, but with bodies skipped the reader steps straight over the body and the end that would pop that label never arrives. EndFunctionBody then sees it still sitting on the stack and reports the body as missing its end marker.

The option was only ever meant for the objdump reader, which doesn't build a module, so this declares it unsupported here instead of teaching the IR reader to work around it, along the lines of #2816. Nothing in the tree passes it to ReadBinaryIr today, so nothing starts asserting.

Fixes #2534.

@sbc100

sbc100 commented Aug 10, 2026 •

Copy link
Copy Markdown
Member

I think skip_function_bodies was really just designed for the objdump binary reader.

Maybe better to simply declare skip_function_bodies incompatible with the IR binary reader.

@sbc100

sbc100 commented Aug 10, 2026

Copy link
Copy Markdown
Member

(Something like #2816 maybe)

Skipping the bodies steps over the end marker that would close each
function's label, so EndFunctionBody reports the body as missing its end
marker and reading fails for any module with a function in it.

The option was only ever meant for the objdump reader, so declare it
unsupported here rather than teaching the IR reader to work around it.
@Nishuuzz
Nishuuzz force-pushed the fix/skip-function-bodies branch from 7be68fb to 5240478 Compare August 11, 2026 10:00
@Nishuuzz Nishuuzz changed the title Fix skip_function_bodies with ReadBinaryIr Assert that ReadBinaryIr is not used with skip_function_bodies Aug 11, 2026
@Nishuuzz

Copy link
Copy Markdown
Contributor Author

That makes sense, switched it over — the diff is now just the comment and the assert in ReadBinaryIr, following #2816. Dropped my change to the reader and the test that went with it, and retitled accordingly. Nothing in the tree passes the option to ReadBinaryIr, so nothing starts tripping it.

One thing worth flagging rather than quietly dropping: the person who filed #2534 was using it to skip bodies when loading large modules, so asserting closes that off rather than giving them a path. Not arguing against it — the option clearly was not designed for this reader — just noting it in case you would rather it grew a supported route one day. Either way #2534 can be closed as not supported here.

@sbc100
sbc100 merged commit afa2acc into WebAssembly:main Aug 11, 2026
17 checks passed
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.

options skip_function_bodies can not work with ReadBinaryIr

2 participants