Repository navigation
Avoid Var::name() on function-level branches in decompiler - #2762
Merged
Merged
Conversation
A branch to the function's implicit outermost label is left as an index by name resolution, so Var::name() read the inactive std::string union member. Route br/br_if/br_table through a helper that emits return for an unnamed target.
Member
|
I think maybe we should should delete the decompiler since its not maintained at all, and I'm not sure it has any users either. |
sbc100
approved these changes
Jun 19, 2026
Contributor
Author
|
No objection from me. It does look unmaintained, and there's a fair bit of this class of bug still lurking in there. This at least stops the crash for anyone still using it in the meantime. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Found while fuzzing wasm-decompile.
A branch whose target is the function's implicit outermost label is left as an index by the name resolution passes, since there is no block label to attach to it. DecompileExpr then called Var::name() on that index var. ir.h keeps index_ and name_ in a union, so this reads the inactive std::string member; with NDEBUG the assert is gone and it dereferences a garbage pointer instead.
Smallest repro, decompiles to a return:
br_if and br_table with a function-level target reach the same path. Routed the three branch sites through a helper that emits return when the target is unnamed.