Skip to content

error-chain segfault when using causes via libunwind #42

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

Closed
clux opened this issue Aug 23, 2018 · 2 comments
Closed

error-chain segfault when using causes via libunwind #42

clux opened this issue Aug 23, 2018 · 2 comments

Comments

@clux
Copy link
Owner

clux commented Aug 23, 2018

Program received signal SIGSEGV, Segmentation fault.
0x0000000000bff9d3 in libunwind::LocalAddressSpace::get32(unsigned long) ()
(gdb) bt
#0  0x0000000000bff9d3 in libunwind::LocalAddressSpace::get32(unsigned long) ()
#1  0x0000000000c02c80 in libunwind::CFI_Parser<libunwind::LocalAddressSpace>::findFDE(libunwind::LocalAddressSpace&, unsigned long, unsigned long, unsigned int, unsigned long, libunwind::CFI_Parser<libunwind::LocalAddressSpace>::FDE_Info*, libunwind::CFI_Parser<libunwind::LocalAddressSpace>::CIE_Info*) ()
#2  0x0000000000c02417 in libunwind::UnwindCursor<libunwind::LocalAddressSpace, libunwind::Registers_x86_64>::getInfoFromDwarfSection(unsigned long, libunwind::UnwindInfoSections const&, unsigned int) ()
#3  0x0000000000c01e17 in libunwind::UnwindCursor<libunwind::LocalAddressSpace, libunwind::Registers_x86_64>::setInfoBasedOnIPRegister(bool) ()
#4  0x0000000000c01bd9 in libunwind::UnwindCursor<libunwind::LocalAddressSpace, libunwind::Registers_x86_64>::step() ()
#5  0x0000000000c00d6d in unw_step ()
#6  0x0000000000bfefff in _Unwind_Backtrace ()
#7  0x0000000000b5684d in backtrace::backtrace::libunwind::trace::hd633fbf58699793f (cb=...)
    at /root/.cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.9/src/backtrace/libunwind.rs:53
#8  backtrace::backtrace::trace::hf547bd4c20bd8958 (cb=...) at /root/.cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.9/src/backtrace/mod.rs:42
#9  0x0000000000b55803 in backtrace::capture::Backtrace::new_unresolved::hb79408d21b35173a () at /root/.cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.9/src/capture.rs:88
#10 backtrace::capture::Backtrace::new::ha127780e86ae8348 () at /root/.cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.9/src/capture.rs:63
#11 _$LT$backtrace..capture..Backtrace$u20$as$u20$core..default..Default$GT$::default::hc59e5c652a626061 ()
    at /root/.cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.9/src/capture.rs:235
#12 0x0000000000b55879 in backtrace::capture::Backtrace::new::ha127780e86ae8348 ()
#13 0x000000000070bf1d in error_chain::make_backtrace::h3de17587d40dd8d9 () at /root/.cargo/registry/src/github.com-1ecc6299db9ec823/error-chain-0.11.0/src/lib.rs:616
#14 0x000000000070bfa5 in _$LT$error_chain..State$u20$as$u20$core..default..Default$GT$::default::h83acd38a3fbdd55d ()
    at /root/.cargo/registry/src/github.com-1ecc6299db9ec823/error-chain-0.11.0/src/lib.rs:710
#15 0x000000000053842f in myapp::Error::from_kind::hf7853880c89cea62 (kind=...) at <impl_error_chain_processed macros>:53
#16 _$LT$myapp..Error$u20$as$u20$core..convert..From$LT$alloc..string..String$GT$$GT$::from::h4fbf2a56c4646783 (s=...) at <impl_error_chain_processed macros>:102
#17 _$LT$T$u20$as$u20$core..convert..Into$LT$U$GT$$GT$::into::h583c99ca38db9c0f (self=...) at /checkout/src/libcore/convert.rs:396
#21 0x000000000040860b in myapp::main::hf2459d8155fbc2b7 () at src/main.rs:256
#22 0x0000000000401043 in std::rt::lang_start::_$u7b$$u7b$closure$u7d$$u7d$::h8404db9011a8df06 () at /checkout/src/libstd/rt.rs:74
#23 0x0000000000bee4d3 in std::rt::lang_start_internal::_$u7b$$u7b$closure$u7d$$u7d$::hb94c47f3eedfaa55 () at libstd/rt.rs:59
#24 std::panicking::try::do_call::h9a1cf6ef7a2bbed3 () at libstd/panicking.rs:310
#25 0x0000000000bfd3fa in __rust_maybe_catch_panic () at libpanic_unwind/lib.rs:105
#26 0x0000000000be0e2e in std::panicking::try::hb22e57d7731fdf53 () at libstd/panicking.rs:289
#27 std::panic::catch_unwind::h813102482f9fd064 () at libstd/panic.rs:392
#28 std::rt::lang_start_internal::h45c8433e0c8ada66 () at libstd/rt.rs:58

Noticed on old kernels (CircleCI host) only, works fine on local machine using the musl compiled executable, but on ubuntu 14.04 in circle, non-trivial chain_err iteration cause segfaults.

Upstream issue: rust-lang/rust#47551

@clux
Copy link
Owner Author

clux commented Aug 23, 2018

Temporary error handling work-around that (though there's probably a better thing to check for than CIRCLECI):

fn result_exit<T>(name: &str, x: Result<T>) {
    use std::env;
    let _ = x.map_err(|e| {
        error!("{} error: {}", name, e);
        // print causes of error if present
        if let Ok(_) = env::var("CIRCLECI") {
            // only print debug implementation rather than unwinding
            // this prints the firsts chained cause (better than not doing anything)
            warn!("{:?}", e);
        } else {
            // normal case - assume libunwind works
            for e in e.iter().skip(1) {
                warn!("caused by: {}", e);
            }
        }
        process::exit(1);
    });
    process::exit(0);
}

Works fine for me on CircleCI, and you typically only iterate over error causes once.

@clux
Copy link
Owner Author

clux commented Oct 2, 2021

Going to close this for a number of reasons:

  • not heart of anyone else having a similar problem
  • last we hit this we were on ubuntu 14.04
  • no one is really using error-chain much anymore

@clux clux closed this as completed Oct 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant