Skip to content

Panic/SIGSEGV in unwind cleanup #66781

Closed
Closed
@sfackler

Description

@sfackler

We had a Rust (1.39.0 stable on x86_64-unknown-linux-gnu) service running on a server that started to exhaust its resources - in particular, mmap calls were returning ENOMEM. While in this state, the standard library's unwinding glue started encountering some issues:

  1. Unwrapping a None value:
...
   5: rust_begin_unwind
             at src/libstd/panicking.rs:307
   6: core::panicking::panic_fmt
             at src/libcore/panicking.rs:85
   7: core::panicking::panic
             at src/libcore/panicking.rs:49
   8: core::option::Option<T>::unwrap
             at /rustc/4560ea788cb760f0a34127156c78e2552949f734/src/libcore/macros.rs:12
      panic_unwind::imp::cleanup
             at src/libpanic_unwind/gcc.rs:91
      __rust_maybe_catch_panic
             at src/libpanic_unwind/lib.rs:83
   9: std::panicking::try
             at /rustc/4560ea788cb760f0a34127156c78e2552949f734/src/libstd/panicking.rs:271
      std::panic::catch_unwind
             at /rustc/4560ea788cb760f0a34127156c78e2552949f734/src/libstd/panic.rs:394
...

That corresponds to this unwrap here: https://github.com/rust-lang/rust/blob/1.39.0/src/libpanic_unwind/gcc.rs#L91.

  1. A SIGSEGV inside of __rust_maybe_catch_panic:
Signal: 11 Code: 1
0x0055d61629b70a - __rust_maybe_catch_panic (0x0055d61629b6f0) + 0x1a
0x0055d615da0838 - core::ops::function::FnOnce::call_once{{vtable.shim}}::h72262d2d5e42fdc2 (0x0055d615da07c0) + 0x78
0x0055d6162839af - <alloc::boxed::Box<F> as core::ops::function::FnOnce<A>>::call_once::h483711add4ba2330 (0x0055d616283970) + 0x3f
0x0055d61629aae0 - std::sys::unix::thread::Thread::new::thread_start::h7c2a7f9b68fe4bba (0x0055d61629aa50) + 0x90
0x007f6290088e65 - start_thread (0x007f6290088da0) + 0xc5
0x007f628e8d188d - ???? 

My guess is that the inability to mmap somehow put the unwinder in a bad place?

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-runtimeArea: std's runtime and "pre-main" init for handling backtraces, unwinds, stack overflowsC-bugCategory: This is a bug.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions