Harden dumpDebugLoc against malformed .debug_loc sections
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 45/100
Research direction
Start in dumpDebugLoc in third_party/llvm-project/dwarf2yaml.cpp, where the exit(1) on a null list sits, and read parseOneLocationList to see how entry.Loc is sized before the copy. Check how the address size is taken from the first CU. Done means a malformed list prints a warning and skips the rest of the section instead of exiting, the entry.Loc length is bounded, and a debug-build assert covers the shared address size. The issue does not give the length limit, so that needs a maintainer decision.
Written by the indexing model from the issue text.
Description
Background:
#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.
Location: third_party/llvm-project/dwarf2yaml.cpp, dumpDebugLoc.
-
exit(1)on parse failure.if (!list) { errs() << "debug_loc error\n"; exit(1); }A single malformed location list aborts the entire
wasm-optrun. 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.Locis read from the section byparseOneLocationList. There is
no upper bound on its length before the copy intoloc.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-sizecomment from a question to an explicit
assumption with a debug-build assert.
Refs #6879, #7910.
- Dominant language
- WebAssembly
- Stars
- 8.7k
- Forks
- 913
- Avg merge
- 2d 14h
- Merged PRs (30d)
- 92
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from WebAssembly/binaryen
-
DAE2 crashes on call.without.effects with a non ref.func expressionPossibly taken @stevenfontanella claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
WebAssembly/binaryen#9404 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
WebAssembly/binaryen#9135 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 Half a day Newbie friendliness 76/100
WebAssembly/binaryen#9018 · 3 comments ·
Maintainers usually reply within 1 day
-
Remove `call.without.effects` intrinsicPossibly taken @stevenfontanella claimed this 2 days ago. Open
WebAssembly/binaryen#9399 · 1 assignee ·
Maintainers usually reply within 1 day
-
Inlining: --inline-max-combined-binary-size is not enforced when several functions are inlined into one caller in the same iterationPossibly taken @kripken claimed this 6 days ago. Open
Difficulty 3/5 1-2 days Newbie friendliness 58/100
WebAssembly/binaryen#9384 · 1 assignee ·
Maintainers usually reply within 1 day
All issues in WebAssembly/binaryen
Similar issues
-
area:compiler effort:S impact:med platform:windows type:bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
area:Analysis enhancement
Difficulty 1/5 1-3 hours Newbie friendliness 69/100
facebookresearch/atlas-lean#5118 ·
Maintainers usually reply within 1 day
-
drools: declared enum with 128 or more literals fails at class initialization (NegativeArraySizeException)Possibly taken @drccrd claimed this today. Openarea:rules
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
apache/incubator-kie#7306 · 3 comments ·
Maintainers usually reply within 2 days
-
bug css P3
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day