rust-lang / backtrace-rs

Backtraces in Rust
https://docs.rs/backtrace
Other
535 stars 245 forks source link

Backtraces through system libraries give bad symbols on macOS 10.15 #79831 #398

Open jrmuizel opened 3 years ago

jrmuizel commented 3 years ago
$ git clone https://github.com/jrmuizel/bt-test/
$ cd bt-test
$ RUST_BACKTRACE=1 cargo run
thread 'main' panicked at 'food', src/main.rs:15:9
stack backtrace:
   0: std::panicking::begin_panic
             at /Users/jrmuizel/.rustup/toolchains/1.47.0-x86_64-apple-darwin/lib/rustlib/src/rust/library/std/src/panicking.rs:497
   1: <bt_test::PanicWrapper as core::ops::drop::Drop>::drop
             at ./src/main.rs:15
   2: core::ptr::drop_in_place
             at /Users/jrmuizel/.rustup/toolchains/1.47.0-x86_64-apple-darwin/lib/rustlib/src/rust/library/core/src/ptr/mod.rs:184
   3: alloc::sync::Arc<T>::drop_slow
             at /Users/jrmuizel/.rustup/toolchains/1.47.0-x86_64-apple-darwin/lib/rustlib/src/rust/library/alloc/src/sync.rs:934
   4: <alloc::sync::Arc<T> as core::ops::drop::Drop>::drop
             at /Users/jrmuizel/.rustup/toolchains/1.47.0-x86_64-apple-darwin/lib/rustlib/src/rust/library/alloc/src/sync.rs:1454
   5: core::ptr::drop_in_place
             at /Users/jrmuizel/.rustup/toolchains/1.47.0-x86_64-apple-darwin/lib/rustlib/src/rust/library/core/src/ptr/mod.rs:184
   6: core::mem::drop
             at /Users/jrmuizel/.rustup/toolchains/1.47.0-x86_64-apple-darwin/lib/rustlib/src/rust/library/core/src/mem/mod.rs:901
   7: core_graphics::data_provider::CGDataProvider::from_buffer::release
             at /Users/jrmuizel/.cargo/registry/src/github.com-1ecc6299db9ec823/core-graphics-0.22.2/src/data_provider.rs:63
   8: _CGSNextPoint
   9: _img_raw_read
  10: _pdf_xref_create
  11: ___CFRunLoopSourceCopyDescription
  12: <core_graphics::data_provider::CGDataProvider as core::ops::drop::Drop>::drop::{{closure}}
             at /Users/jrmuizel/.cargo/registry/src/github.com-1ecc6299db9ec823/core-graphics-0.22.2/src/data_provider.rs:36
  13: <core_graphics::data_provider::CGDataProvider as core::ops::drop::Drop>::drop
             at /Users/jrmuizel/.cargo/registry/src/github.com-1ecc6299db9ec823/foreign-types-0.3.2/src/lib.rs:241
  14: core::ptr::drop_in_place
             at /Users/jrmuizel/.rustup/toolchains/1.47.0-x86_64-apple-darwin/lib/rustlib/src/rust/library/core/src/ptr/mod.rs:184
  15: core::mem::drop
             at /Users/jrmuizel/.rustup/toolchains/1.47.0-x86_64-apple-darwin/lib/rustlib/src/rust/library/core/src/mem/mod.rs:901
  16: bt_test::main
             at ./src/main.rs:22
  17: core::ops::function::FnOnce::call_once
             at /Users/jrmuizel/.rustup/toolchains/1.47.0-x86_64-apple-darwin/lib/rustlib/src/rust/library/core/src/ops/function.rs:227
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

lldb gives:

  * frame #0: 0x000000010001a984 bt-test`rust_panic at panicking.rs:618:9 [opt]
    frame #1: 0x000000010001a944 bt-test`std::panicking::rust_panic_with_hook::hc36596b4257bea99 at panicking.rs:588:5 [opt]
    frame #2: 0x0000000100005704 bt-test`std::panicking::begin_panic::_$u7b$$u7b$closure$u7d$$u7d$::h9db863f0e6ebb292 at panicking.rs:498:9
    frame #3: 0x0000000100004a08 bt-test`std::sys_common::backtrace::__rust_end_short_backtrace::h69d0fe27bfa4f075(f=<unavailable>) at backtrace.rs:153:18
    frame #4: 0x0000000100032932 bt-test`std::panicking::begin_panic::hc1de26656f484907(msg=(data_ptr = "foodsrc/main.rs", length = 4)) at panicking.rs:497:12
    frame #5: 0x0000000100003b34 bt-test`_$LT$bt_test..PanicWrapper$u20$as$u20$core..ops..drop..Drop$GT$::drop::h62ef6e2409387504(self=0x0000000100208f20) at main.rs:15:9
    frame #6: 0x0000000100003985 bt-test`core::ptr::drop_in_place::hc8d1bc33f994b701((null)=0x0000000100208f20) at mod.rs:184:1
    frame #7: 0x0000000100002982 bt-test`alloc::sync::Arc$LT$T$GT$::drop_slow::hae5788b48af4ed55(self=0x00007ffeefbff088) at sync.rs:934:18
    frame #8: 0x0000000100003a20 bt-test`_$LT$alloc..sync..Arc$LT$T$GT$$u20$as$u20$core..ops..drop..Drop$GT$::drop::h1a1f5ff6edd186e9(self=0x00007ffeefbff088) at sync.rs:1454:13
    frame #9: 0x0000000100003961 bt-test`core::ptr::drop_in_place::hc757b4bc8d66d950((null)=0x00007ffeefbff088) at mod.rs:184:1
    frame #10: 0x0000000100003525 bt-test`core::mem::drop::h3895b47aafaa1ec6(_x=Arc<bt_test::PanicWrapper> @ 0x00007ffeefbff088) at mod.rs:901:24
    frame #11: 0x0000000100003ca6 bt-test`core_graphics::data_provider::CGDataProvider::from_buffer::release::h16e206798bbead58(info=0x0000000100208f20, (null)=0x00000001002040c0, (null)=3) at data_provider.rs:63:13
    frame #12: 0x00007fff32f1fb0d CoreGraphics`data_release_info + 31
    frame #13: 0x00007fff32ecfdf0 CoreGraphics`data_provider_finalize + 64
    frame #14: 0x00007fff32e9562e CoreGraphics`data_provider_retain_count + 74
    frame #15: 0x00007fff32b57677 CoreFoundation`_CFRelease + 460
    frame #16: 0x0000000100004168 bt-test`_$LT$core_graphics..data_provider..CGDataProvider$u20$as$u20$core..ops..drop..Drop$GT$::drop::_$u7b$$u7b$closure$u7d$$u7d$::hca22e5dbf2959e57((null)=0x0000000100034f73, cs=0x0000000100209040) at data_provider.rs:36:20
    frame #17: 0x0000000100004149 bt-test`_$LT$core_graphics..data_provider..CGDataProvider$u20$as$u20$core..ops..drop..Drop$GT$::drop::hcac384f7a3866a31(self=0x00007ffeefbff1f8) at lib.rs:241:26
    frame #18: 0x0000000100004181 bt-test`core::ptr::drop_in_place::h18907e00d68d441d((null)=0x00007ffeefbff1f8) at mod.rs:184:1
    frame #19: 0x0000000100003545 bt-test`core::mem::drop::h985cabc9d406f69e(_x=(__0 = 0x0000000100209040)) at mod.rs:901:24
    frame #20: 0x00000001000037dc bt-test`bt_test::main::hebe005de97d25410 at main.rs:22:5
    frame #21: 0x000000010000388e bt-test`core::ops::function::FnOnce::call_once::h15f10ee761496535((null)=(bt-test`bt_test::main::hebe005de97d25410 at main.rs:19), (null)=<unavailable>) at function.rs:227:5
    frame #22: 0x00000001000024c1 bt-test`std::sys_common::backtrace::__rust_begin_short_backtrace::h839b34d787d4e007(f=(bt-test`bt_test::main::hebe005de97d25410 at main.rs:19)) at backtrace.rs:137:18
    frame #23: 0x00000001000040c4 bt-test`std::rt::lang_start::_$u7b$$u7b$closure$u7d$$u7d$::h9d5a3c29c5c0b98f at rt.rs:66:18
    frame #24: 0x000000010001aba0 bt-test`std::rt::lang_start_internal::hd0c760d47f593c0a [inlined] core::ops::function::impls::_$LT$impl$u20$core..ops..function..FnOnce$LT$A$GT$$u20$for$u20$$RF$F$GT$::call_once::h8a9b574793342aba at function.rs:259:13 [opt]
    frame #25: 0x000000010001ab96 bt-test`std::rt::lang_start_internal::hd0c760d47f593c0a [inlined] std::panicking::try::do_call::h4f96def3e784cc72 at panicking.rs:373 [opt]
    frame #26: 0x000000010001ab96 bt-test`std::rt::lang_start_internal::hd0c760d47f593c0a [inlined] std::panicking::try::h852a41061a270947 at panicking.rs:337 [opt]
    frame #27: 0x000000010001ab96 bt-test`std::rt::lang_start_internal::hd0c760d47f593c0a [inlined] std::panic::catch_unwind::h1c1a28455dde417c at panic.rs:379 [opt]
    frame #28: 0x000000010001ab96 bt-test`std::rt::lang_start_internal::hd0c760d47f593c0a at rt.rs:51 [opt]
    frame #29: 0x00000001000040a1 bt-test`std::rt::lang_start::hb275e80941058cbe(main=(bt-test`bt_test::main::hebe005de97d25410 at main.rs:19), argc=1, argv=0x00007ffeefbff420) at rt.rs:65:5
    frame #30: 0x0000000100003852 bt-test`main + 34
    frame #31: 0x00007fff6caf8cc9 libdyld.dylib`start + 1

Note:

   8: _CGSNextPoint
   9: _img_raw_read
  10: _pdf_xref_create
  11: ___CFRunLoopSourceCopyDescription

vs

    frame #12: 0x00007fff32f1fb0d CoreGraphics`data_release_info + 31
    frame #13: 0x00007fff32ecfdf0 CoreGraphics`data_provider_finalize + 64
    frame #14: 0x00007fff32e9562e CoreGraphics`data_provider_retain_count + 74
    frame #15: 0x00007fff32b57677 CoreFoundation`_CFRelease + 460

Redirected from: https://github.com/rust-lang/rust/issues/79831

@mstange thinks this might be caused by coded added in https://github.com/rust-lang/backtrace-rs/commit/6a3054166a06c917de5ac158194dcba819e510c8

philipc commented 3 years ago

This does work for me on macOS 10.14.

alexcrichton commented 3 years ago

Locally on 11.1 I actually get:

  11: <unknown>
  12: <unknown>
  13: <unknown>
  14: <unknown>

Definitely looks like something fishy is going on!

mstange commented 3 years ago

The macOS 11 problem is a different one, see https://github.com/gimli-rs/object/issues/268 .

philipc commented 3 years ago

I haven't been able to reproduce this. The bt-test crate works on a fresh 10.15 install. I also tried adding a test that runs in github actions (https://github.com/philipc/backtrace-rs/commit/cf7b51d62d56d80dc2790913674327bef920a09b) and it works too.

jrmuizel commented 3 years ago

Weird. I'm on 10.15.6 and can still reproduce it.

jrmuizel commented 3 years ago

Here's what I get when running that macos test: https://gist.github.com/jrmuizel/4ec8c169d978b4612f2d8d8e98138a86

philipc commented 3 years ago

@jrmuizel Could you check if https://github.com/philipc/backtrace-rs/commit/a97793894ce659c2557d770810658e786349ae05 is any better? I think this is more correct than before, but I am doubtful it will fix the problem you are seeing. I would be interested in seeing the Big Sur output for this too.

jrmuizel commented 3 years ago

Still fails:

https://gist.github.com/jrmuizel/67d5aec31ec0d6a244069ea81ce78edc