js-20261012-wasm-dwarf-inline-origin-stacktrace-reconstruction
Done. Here's what I diagnosed and delivered.
The problem isn't a single bug — it's a set of coordinate/identity mismatches that a naive "scan every DIE for low ≤ addr < high" resolver gets wrong:
.o files store R_WASM_FUNCTION_OFFSET_I32 / R_WASM_SECTION_OFFSET_I32; without applying them every low_pc is wrong.wasm-ld rewrites dead functions to 0xfffffffe/0xffffffff; if treated as live ranges they corrupt the whole index (I actually hit and fixed this).abstract_origin can hang a naive walker.solution/wasm-dwarf-inline.js (1551 lines, dependency-free): Wasm section/reloc/linking parser, DWARF 2–5 parser (line, ranges, rnglists, addr, str_offsets, split .dwo merge), abstract-origin cycle guard, tombstone filtering, centered interval tree, GNU call-site/tail-call handling, frame reconstruction with deterministic tie-breaking and structured ambiguity, plus a CLI.solution/test.js: differential harness that compiles real Wasm with clang --target=wasm32 -g (DWARF 4 and 5), links with wasm-ld, and compares every line-table row / range boundary against llvm-addr2line -f -i.SOLUTION.md: the requested writeup with root-cause analysis, exact fix, and verification.PASS linked.wasm (multi-CU, DWARF4) (26/26)
PASS linked5.wasm (multi-CU, DWARF5) (26/26)
PASS trap.wasm (nested inline) (8/8)
PASS call.wasm (call sites) (27/27)
PASS inline.o / inline5.o relocation equivalence + addr2line (14/14 each)
PASS split-DWARF5 .dwo merge (10/10)
PASS tail-call call-site metadata
PASS cyclic abstract-origin handling
PASS overlapping-range structured ambiguity
PASS 100k queries in ~56 ms (non-quadratic)
PASS runtime V8 offset 0x40 -> DWARF 0x4 -> [inner > middle > guarded]
PASS dead-code tombstones excluded
==> pass=87 fail=0
Run it yourself: cd ~/solution && node test.js.
# Evidence - Problem class: js-20261012-wasm-dwarf-inline-origin-stacktrace-reconstruction - Model: openrouter/deepseek/deepseek-v4.1-flash - Solved: 2026-10-12T22:25:03.404Z - Verification: solution produced by pi in sandbox; see signatures.json
{"description": "Given WebAssembly code sections and DWARF line, inlined-subroutine, range-list, and call-site metadata, reconstruct source-level stack traces for instruction addresses across split compilation units and relocated function bodies. Handle overlapping ranges, abstract-origin chains, tail calls, and malformed cyclic DIE references deterministically, reporting exact source locations or a structured ambiguity without quadratic scans.", "environment": "node20", "language": "js", "model": "openrouter/deepseek/deepseek-v4.1-flash", "problem_class": "js-20261012-wasm-dwarf-inline-origin-stacktrace-reconstruction", "provider": "openrouter", "solved_at": "2026-10-12T22:25:03.404Z", "version": "20"}