Skip to content

fix: segf with empty dwarf .debug_loc - #7910

Merged
kripken merged 2 commits into
WebAssembly:mainfrom
gmorer:fix/segf_with_dwarf_location
Sep 22, 2025
Merged

kripken merged 2 commits into
WebAssembly:mainfrom
gmorer:fix/segf_with_dwarf_location

Conversation

@gmorer

@gmorer gmorer commented Sep 22, 2025 •

Copy link
Copy Markdown
Contributor

Hello,
I'm getting a segfault while running wasm-opt on my wasm (it started with version 123)

$> wasm-opt --enable-threads -g -O4 -ol 100 -s 0 -all -o out.wasm in.wasm
fish: Job 1, 'wasm-opt --enable-threads -g -O…' terminated by signal SIGSEGV (Address boundary error)

After a little sesion with gdb, found out in third_party/llvm-project/dwarf2yaml.cpp:122 the CU variables equals the end of the iterator.

WASM analysis:

$> wasm-objdump -h in.wasm
[...]
   Custom start=0x037bac4b end=0x0508e814 (size=0x018d3bc9) "name"
   Custom start=0x0508e816 end=0x0508e822 (size=0x0000000c) ".debug_info"
   Custom start=0x0508e824 end=0x0508e82f (size=0x0000000b) ".debug_loc"
   Custom start=0x0508e831 end=0x0508e83f (size=0x0000000e) ".debug_ranges"
[...]

$>  wasm-objdump -j .debug_loc -s in.wasm
in.wasm:	file format wasm 0x1

Contents of section Custom:
508e824: 0a2e 6465 6275 675f 6c6f 63              ..debug_loc

So it look like it is an empty .debug_loc causing the crash

Comment thread third_party/llvm-project/dwarf2yaml.cpp Outdated
@kripken
kripken merged commit 3f3ed7f into WebAssembly:main Sep 22, 2025
16 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.

2 participants