You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Harden dumpDebugLoc against malformed .debug_loc sections #9249
#6879 was a SIGSEGV in dumpDebugLoc for modules with empty .debug_loc
sections. Fixed by #7910 with a null-CU guard. While reviewing that fix,
three defensive improvements to the same function became apparent. None
is a regression, but each turns a malformed-input case into a hard
failure when it could fail gracefully.
if (!list) {
errs() << "debug_loc error\n";
exit(1);
}
A single malformed location list aborts the entire wasm-opt run. A
warning plus break (skip the rest of the section) would let the tool
finish processing the module with incomplete debug info, which is
the behavior for every other diagnostic in wasm-opt.
Unbounded copy of location expression bytes.
entry.Loc is read from the section by parseOneLocationList. There is
no upper bound on its length before the copy into loc.Location. A
malformed length field causes unbounded allocation.
Address-size heuristic.
The comment "should be ok since they all have the same address size?"
is a heuristic. All CUs in well-formed modules share the same AddrSize, so reading it from the first CU is safe in practice, but
the assumption is not enforced.
Proposed changes:
Replace exit(1) with a warning and break.
Add a length sanity check before copying entry.Loc.
Promote the address-size comment from a question to an explicit
assumption with a debug-build assert.
Activity