-
Notifications
You must be signed in to change notification settings - Fork 108
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
Allow invalid ranges in RngListIter #715
Conversation
I've encountered a toolchain which produces invalid ranges, where the end of the range is before the beginning. I want to fix that toolchain, of course, but I also noticed that tools like `llvm-addr2line` and `llvm-dwarfdump --lookup` apparently silently skip the invalid ranges, so they're able to give partial answers. By contrast, `gimli` returns an error in this case. Then the `addr2line` crate, for example, bubbles the error all the way out and doesn't return any results. It would be useful to be able to skip over the invalid ranges, instead of truncating a range-list at the first error. To that end I've deleted the check here in `RngListIter::convert_raw`, so the caller can decide what they want to do with such ranges. `addr2line`, for example, already checks that `range.begin < range.end` and silently ignores the range otherwise. The specific toolchain where I've encountered this is TinyGo (which uses LLVM), when building WebAssembly with the `wasip1` target. I tested TinyGo 0.32.0-dev and LLVM 17, and this was the shortest program I could find which produces invalid ranges: ```go package main import "os" func main() { os.Lstat("some-filename") } ```
This seems fine to me, but I'll take the time to reproduce it and see if any other options are apparent. |
I couldn't reproduce this with the lastest dev version of tinygo ( Can you give me a file (email or attach here is fine). |
Here's the wasm I got from If you run
|
In case you're curious: After more investigation we believe these invalid ranges are being introduced by wasm-opt when tinygo runs the "asyncify" pass over LLVM's output, because we no longer see these invalid ranges if we run tinygo with the There was a similar issue reported at WebAssembly/binaryen#6406, and actually we can reproduce that issue even with At any rate, while the producer of this DWARF is clearly buggy, I still think it's useful for gimli to return the address range as provided and let the caller decide if they want to validate it, so I'm still interested in merging this PR or something equivalent. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you change it to return Ok(None)
(same as what we do for tombstones), and also do a similar change for location lists.
Sure, done! |
I thought it would be easiest to describe the issue I'm encountering with a patch, but I'm not attached to this particular solution if folks would prefer some other approach.
I've encountered a toolchain which produces invalid ranges, where the end of the range is before the beginning.
I want to fix that toolchain, of course, but I also noticed that tools like
llvm-addr2line
andllvm-dwarfdump --lookup
apparently silently skip the invalid ranges, so they're able to give partial answers. By contrast,gimli
returns an error in this case. Then theaddr2line
crate, for example, bubbles the error all the way out and doesn't return any results.It would be useful to be able to skip over the invalid ranges, instead of truncating a range-list at the first error. To that end I've deleted the check here in
RngListIter::convert_raw
, so the caller can decide what they want to do with such ranges.addr2line
, for example, already checks thatrange.begin < range.end
and silently ignores the range otherwise.The specific toolchain where I've encountered this is TinyGo (which uses LLVM), when building WebAssembly with the
wasip1
target. I tested TinyGo 0.32.0-dev and LLVM 17, and this was the shortest program I could find which produces invalid ranges: