-
Notifications
You must be signed in to change notification settings - Fork 63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Errors when parsing DWARF from Wasm objects #265
Comments
To be clear, the unwrap causing the panic is not |
Right, sorry, my code is panic'ing on an To repro, you can build the
and that should hit the panic on the unexpected-EOF error from inside addr2line/gimli. (It's 60MiB gzipped; any others, please be nice to my S3 bandwidth and download only if needed!) Thanks for looking into this! |
How is |
Okay The problem is that |
Ah, fantastic, thank you for finding that and sorry for burning your time with such a basic error! Followup question, but I'm happy to close this issue and/or open a new one if you'd prefer: it seems the returned line-number info now has a bunch of ranges, all starting at PC 0; does each range correspond to one function, in order, or...? (I naively would have expected either offset-in-file or offset-in-code-section) From the same
|
We've seen trouble in the past with line programs starting at zero for wasm, in rust-lang/rust#79410 |
Interesting, thanks! FWIW, this Wasm module was produced by clang 15.0.7, as packaged in wasi-sdk 19, building a large C++ program; but maybe it's an underlying LLVM issue of some sort? |
These |
This should be fixed by gimli-rs/gimli#642 |
With an override to use that PR's branch for |
Well, I maybe spoke prematurely: I'm getting tuples that look superficially reasonable, but the offsets seem nonsensical in context -- sourcelocs that are from unrelated files and clearly can't be right. I suspect I'm still not understanding something about how Wasm and DWARF interact, or am misinterpreting an offset somehow. Anyone else with experience in this please feel free to point me toward resources that could help! |
Can you give an example? I'm happy to look into it. |
Sure -- latest |
I'm not seeing the locs for
Looking at the dwarf with
We can find that address in
where file 6 is:
If I run
So it looks like the DWARF contains the correct info and |
Ah, sorry -- I had been passing optimization options to waffle-util that expanded function bodies (they are lazily parsed); latest I suspect I'm misinterpreting offsets somehow; I'll continue to experiment with this... |
I patched it to display the DWARF address for each loc too, and they all have low values. So I would guess you're looking up the locations using some sort of relative offset, instead of the address. |
I've resolved this successfully now -- thank you so much for your patience! (For anyone stumbling on this now or later: (i) Is it likely there will be new releases of gimli and addr2line soon to pick up the PR from above? I suppose this issue can be closed once a patched gimli is used on |
Did you push those changes? It still doesn't look right to me. I'll do a patch release of gimli, so you'll be able to pick up that change without needing an addr2line release (I want to do some more changes before another release of it). |
I have, I think; waffle commit |
See cfallin/waffle#1 |
When troubleshooting deadlocks in WebAssembly modules, it is important to understand which `wait` instructions are still pending a `notify`. It would be nice to have some kind of `--warn-deadlock-after=1s` flag available that would poll the parking lot for `wait`s hanging past the time limit, but I realized the real value would be to tie the `wait` instruction (through CLIF) to the original source code, if debug information were available. This did not seem to be entirely feasible, since CLIF loses the original Wasm source context (is this true?) and I was not confident that we would be able to use `addr2line` to map from Wasm instructions to source (e.g., see @cfallin's [issue](gimli-rs/addr2line#265)). Instead, this change simply logs each valid `wait` and `notify` execution, leaving it to the user to figure out which one is hanging (should not be too difficult) and how to map this back to their source code (more difficult).
When troubleshooting deadlocks in WebAssembly modules, it is important to understand which `wait` instructions are still pending a `notify`. It would be nice to have some kind of `--warn-deadlock-after=1s` flag available that would poll the parking lot for `wait`s hanging past the time limit, but I realized the real value would be to tie the `wait` instruction (through CLIF) to the original source code, if debug information were available. This did not seem to be entirely feasible, since CLIF loses the original Wasm source context (is this true?) and I was not confident that we would be able to use `addr2line` to map from Wasm instructions to source (e.g., see @cfallin's [issue](gimli-rs/addr2line#265)). Instead, this change simply logs each valid `wait` and `notify` execution, leaving it to the user to figure out which one is hanging (should not be too difficult) and how to map this back to their source code (more difficult).
I'm attempting to use
addr2line
to get line-number info from the DWARF embedded in a wasm32 module (produced by wasi-sdk 19's clang from a large C++ program). I've incorporated a fairly straightforward integration into my Wasm-parsing frontend that gathers all appropriate.debug_*
sections, puts them in agimli::Dwarf
, and tries to build anaddr2line::Context
from that. No parsing or data-munging at all is happening on my side.This seems to generate valid line-number tuples for a C hello-world program, but a large C++ program (the SpiderMonkey JS engine compiled to Wasm) built with the same clang results in
That offset is definitely out-of-range (the input file is 277MiB).
At the top level, first, is
addr2line
known or expected to work with the DWARF that is embedded in wasm32? If so, I'd be happy to try to get the above module to you for reduction / debugging!The text was updated successfully, but these errors were encountered: