gimli-rs / addr2line

A cross-platform `addr2line` clone written in Rust, using `gimli`
https://docs.rs/addr2line
Apache License 2.0
315 stars 62 forks source link

Add new compatibility mode to binary, to be able to replace llvm-symbolizer/addr2line #314

Closed qarmin closed 3 months ago

qarmin commented 3 months ago

I have found crash with AddressSanitizer in zed and used commands from below to get readable output

export ASAN_SYMBOLIZER_PATH=$(which llvm-symbolized-18)
export ASAN_OPTIONS=symbolize=1

this worked fast, but I got not fully converted output

==174195==ERROR: AddressSanitizer: stack-use-after-scope on address 0x73107e3b9e80 at pc 0x5c35e3b8e734 bp 0x7310819fbd60 sp 0x7310819fbd58
WRITE of size 8 at 0x73107e3b9e80 thread T11
    #0 0x5c35e3b8e733 in _$LT$core..slice..iter..Iter$LT$T$GT$$u20$as$u20$core..iter..traits..iterator..Iterator$GT$::size_hint::h8e57b468e13c89f1 /rustc/c6727fc9b5c64cefa7263486497ee95e529bd0f8/library/core/src/slice/iter/macros.rs:173:17
    #1 0x5c35e3b8e733 in _$LT$core..iter..adapters..enumerate..Enumerate$LT$I$GT$$u20$as$u20$core..iter..traits..iterator..Iterator$GT$::size_hint::h88b18cc691be6e6f /rustc/c6727fc9b5c64cefa7263486497ee95e529bd0f8/library/core/src/iter/adapters/enumerate.rs:56:9
    #2 0x5c35e3b8e733 in _$LT$cranelift_entity..iter..Iter$LT$K$C$V$GT$$u20$as$u20$core..iter..traits..iterator..Iterator$GT$::size_hint::he96e627b275ac2f2 /home/rafal/.cargo/registry/src/index.crates.io-6f17d22bba15001f/cranelift-entity-0.106.2/src/iter.rs:37:24
    #3 0x5c35e3b12a12 in _$LT$core..iter..adapters..filter_map..FilterMap$LT$I$C$F$GT$$u20$as$u20$core..iter..traits..iterator..Iterator$GT$::size_hint::h3e1343f3f0c169eb /rustc/c6727fc9b5c64cefa7263486497ee95e529bd0f8/library/core/src/iter/adapters/filter_map.rs:129:26
    #4 0x5c35e3b12a12 in _$LT$alloc..vec..Vec$LT$T$GT$$u20$as$u20$alloc..vec..spec_from_iter_nested..SpecFromIterNested$LT$T$C$I$GT$$GT$::from_iter::ha7db48c8db24290d /rustc/c6727fc9b5c64cefa7263486497ee95e529bd0f8/library/alloc/src/vec/spec_from_iter_nested.rs:29:34
    #5 0x5c35e3b12a12 in _$LT$alloc..vec..Vec$LT$T$GT$$u20$as$u20$alloc..vec..spec_from_iter..SpecFromIter$LT$T$C$I$GT$$GT$::from_iter::h2965d8e634c52d2e /rustc/c6727fc9b5c64cefa7263486497ee95e529bd0f8/library/alloc/src/vec/spec_from_iter.rs:33:9
    #6 0x5c35e3b686b9 in _$LT$alloc..vec..Vec$LT$T$GT$$u20$as$u20$core..iter..traits..collect..FromIterator$LT$T$GT$$GT$::from_iter::hb55b2b4b70830d57 /rustc/c6727fc9b5c64cefa7263486497ee95e529bd0f8/library/alloc/src/vec/mod.rs:2971:9

with

export ASAN_SYMBOLIZER_PATH=$(which addr2line)
export ASAN_OPTIONS=symbolize=1

I got proper

==175140==ERROR: AddressSanitizer: stack-use-after-scope on address 0x7eb16a7ca080 at pc 0x6234b02c0734 bp 0x7eb16d5fbd60 sp 0x7eb16d5fbd58
WRITE of size 8 at 0x7eb16a7ca080 thread T10
    #0 0x6234b02c0733 in <core::slice::iter::Iter<T> as core::iter::traits::iterator::Iterator>::size_hint /rustc/c6727fc9b5c64cefa7263486497ee95e529bd0f8/library/core/src/slice/iter/macros.rs:173
    #1 0x6234b02c0733 in <core::iter::adapters::enumerate::Enumerate<I> as core::iter::traits::iterator::Iterator>::size_hint /rustc/c6727fc9b5c64cefa7263486497ee95e529bd0f8/library/core/src/iter/adapters/enumerate.rs:56
    #2 0x6234b02c0733 in <cranelift_entity::iter::Iter<K,V> as core::iter::traits::iterator::Iterator>::size_hint /home/rafal/.cargo/registry/src/index.crates.io-6f17d22bba15001f/cranelift-entity-0.106.2/src/iter.rs:37
    #3 0x6234b0244a12 in <core::iter::adapters::filter_map::FilterMap<I,F> as core::iter::traits::iterator::Iterator>::size_hint /rustc/c6727fc9b5c64cefa7263486497ee95e529bd0f8/library/core/src/iter/adapters/filter_map.rs:129
    #4 0x6234b0244a12 in <alloc::vec::Vec<T> as alloc::vec::spec_from_iter_nested::SpecFromIterNested<T,I>>::from_iter /rustc/c6727fc9b5c64cefa7263486497ee95e529bd0f8/library/alloc/src/vec/spec_from_iter_nested.rs:29
    #5 0x6234b0244a12 in <alloc::vec::Vec<T> as alloc::vec::spec_from_iter::SpecFromIter<T,I>>::from_iter /rustc/c6727fc9b5c64cefa7263486497ee95e529bd0f8/library/alloc/src/vec/spec_from_iter.rs:33
    #6 0x6234b029a6b9 in <alloc::vec::Vec<T> as core::iter::traits::collect::FromIterator<T>>::from_iter /rustc/c6727fc9b5c64cefa7263486497ee95e529bd0f8/library/alloc/src/vec/mod.rs:2971

but entire operation took almost 160 seconds (llvm-symbolizer took 2 seconds)

When compiling this package and trying to use it, I have this error

export ASAN_SYMBOLIZER_PATH=$(which a2l)
zed
==177959==ERROR: External symbolizer path is set to '/home/rafal/.cargo/bin/a2l' which isn't a known symbolizer. Please set the path to the llvm-symbolizer binary or other known tool.

it is possible to add new mode to be able to replace llvm-symbolizer?

qarmin commented 3 months ago

Nevermind, looks that sanitizer checks for specific name