gimli
gimli copied to clipboard
Allow invalid ranges in RngListIter
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
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:
package main
import "os"
func main() {
os.Lstat("some-filename")
}