Skip to content

RUST_BACKTRACE on macOS can trigger crashes #71397

Closed
@jdm

Description

@jdm

I'm running macOS 10.15.3. Starting in the 3/26 nightly, running applications and tests that panic with RUST_BACKTRACE=1 frequently results in a segfault:

joshmatthews@joshmatthews-fcmd6r neovide % RUST_BACKTRACE=1 cargo run
warning: unreachable expression
   --> src/window.rs:150:9
    |
149 |   panic!();
    |   --------- any code following this expression is unreachable
150 | /         if self.ignore_text_input {
151 | |             self.ignore_text_input = false;
152 | |         } else {
153 | |             let text = if text == "<" {
...   |
158 | |             BRIDGE.queue_command(UiCommand::Keyboard(text))
159 | |         }
    | |_________^ unreachable expression
    |
    = note: `#[warn(unreachable_code)]` on by default

    Finished dev [unoptimized + debuginfo] target(s) in 0.21s
     Running `target/debug/neovide`
thread 'main' panicked at 'explicit panic', src/window.rs:149:1
stack backtrace:
zsh: segmentation fault  RUST_BACKTRACE=1 cargo run

The backtrace from this shows libbacktrace:

thread 'main' panicked at 'explicit panic', src/window.rs:149:1
stack backtrace:
Process 9595 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x740)
    frame #0: 0x0000000100a569b3 neovide`__rdos_macho_add + 2163
neovide`__rdos_macho_add:
->  0x100a569b3 <+2163>: movq   (%rcx), %rcx
    0x100a569b6 <+2166>: testq  %rcx, %rcx
    0x100a569b9 <+2169>: jne    0x100a569b0               ; <+2160>
    0x100a569bb <+2171>: movq   %r14, (%rax)
Target 0: (neovide) stopped.
(lldb) bt
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x740)
  * frame #0: 0x0000000100a569b3 neovide`__rdos_macho_add + 2163
    frame #1: 0x0000000100a56046 neovide`__rdos_backtrace_initialize + 278
    frame #2: 0x0000000100a553d2 neovide`fileline_initialize + 450
    frame #3: 0x0000000100a55498 neovide`__rdos_backtrace_syminfo + 40
    frame #4: 0x0000000100a47737 neovide`backtrace::symbolize::libbacktrace::resolve::h7f9f0ba72481fbad at libbacktrace.rs:469:9 [opt]
    frame #5: 0x0000000100a3d4ee neovide`std::sys_common::backtrace::_print_fmt::_$u7b$$u7b$closure$u7d$$u7d$::h1788fc7cbd879752 [inlined] backtrace::symbolize::resolve_frame_unsynchronized::h61c7548d2ef51055 at mod.rs:178:5 [opt]
    frame #6: 0x0000000100a3d4d9 neovide`std::sys_common::backtrace::_print_fmt::_$u7b$$u7b$closure$u7d$$u7d$::h1788fc7cbd879752 at backtrace.rs:85 [opt]
    frame #7: 0x0000000100a473c3 neovide`backtrace::backtrace::libunwind::trace::trace_fn::h839531a54973d0a3 [inlined] core::ops::function::impls::_$LT$impl$u20$core..ops..function..FnMut$LT$A$GT$$u20$for$u20$$RF$mut$u20$F$GT$::call_mut::h25035912fcd7ea4d at function.rs:274:13 [opt]
    frame #8: 0x0000000100a473b5 neovide`backtrace::backtrace::libunwind::trace::trace_fn::h839531a54973d0a3 at libunwind.rs:98 [opt]
    frame #9: 0x00007fff6971d196 libunwind.dylib`_Unwind_Backtrace + 78
    frame #10: 0x0000000100a3ce5f neovide`_$LT$std..sys_common..backtrace.._print..DisplayBacktrace$u20$as$u20$core..fmt..Display$GT$::fmt::h427013014b44f9a8 [inlined] backtrace::backtrace::libunwind::trace::h28d4037cad4f389e at libunwind.rs:86:5 [opt]
    frame #11: 0x0000000100a3ce4c neovide`_$LT$std..sys_common..backtrace.._print..DisplayBacktrace$u20$as$u20$core..fmt..Display$GT$::fmt::h427013014b44f9a8 [inlined] backtrace::backtrace::trace_unsynchronized::hd54fd38f7fdb5696 at mod.rs:66 [opt]
    frame #12: 0x0000000100a3ce4c neovide`_$LT$std..sys_common..backtrace.._print..DisplayBacktrace$u20$as$u20$core..fmt..Display$GT$::fmt::h427013014b44f9a8 [inlined] std::sys_common::backtrace::_print_fmt::hb47266356b9734d1 at backtrace.rs:78 [opt]
    frame #13: 0x0000000100a3cd40 neovide`_$LT$std..sys_common..backtrace.._print..DisplayBacktrace$u20$as$u20$core..fmt..Display$GT$::fmt::h427013014b44f9a8 at backtrace.rs:59 [opt]
    frame #14: 0x0000000100a64f1e neovide`core::fmt::write::h27b2640c546226f6 at mod.rs:1069:17 [opt]
    frame #15: 0x0000000100a39a57 neovide`std::io::Write::write_fmt::he5892bc9871e1e5f at mod.rs:1439:15 [opt]
    frame #16: 0x0000000100a3ef0a neovide`std::panicking::default_hook::_$u7b$$u7b$closure$u7d$$u7d$::h3b089677c4f8d745 [inlined] std::sys_common::backtrace::_print::hf45c79eb5391485c at backtrace.rs:62:5 [opt]
    frame #17: 0x0000000100a3eeb9 neovide`std::panicking::default_hook::_$u7b$$u7b$closure$u7d$$u7d$::h3b089677c4f8d745 [inlined] std::sys_common::backtrace::print::h43196d14250d00b9 at backtrace.rs:49 [opt]
    frame #18: 0x0000000100a3eead neovide`std::panicking::default_hook::_$u7b$$u7b$closure$u7d$$u7d$::h3b089677c4f8d745 at panicking.rs:198 [opt]
    frame #19: 0x0000000100a3ec4c neovide`std::panicking::default_hook::hcfb648533dd347e2 at panicking.rs:218:9 [opt]
    frame #20: 0x0000000100a3f4d8 neovide`std::panicking::rust_panic_with_hook::hb95563f6bbfa7e96 at panicking.rs:511:17 [opt]
    frame #21: 0x0000000100a6f756 neovide`std::panicking::begin_panic::h4d337183d183fa38(msg=(data_ptr = "explicit panicCould not calculate logical mouse positionpressreleaseuprightno_idleRender failed. ClosingStarting window event loopCould not create sdl event pumprefresh_rate", length = 14)) at panicking.rs:438:5
    frame #22: 0x00000001000716e8 neovide`neovide::window::WindowWrapper::handle_text_input::h753c24ebed39fa77(self=0x00007ffeefbfd838, text=String @ 0x00007ffeefbff728) at window.rs:149:1
    frame #23: 0x00000001000726ba neovide`neovide::window::ui_loop::h321839a92b1801d3 at window.rs:270:50
    frame #24: 0x00000001000c3ae5 neovide`neovide::main::h6353e38135ac2e41 at main.rs:24:5
    frame #25: 0x00000001000decae neovide`std::rt::lang_start::_$u7b$$u7b$closure$u7d$$u7d$::heda059d8c2ddf031 at rt.rs:67:34
    frame #26: 0x0000000100a3f839 neovide`std::rt::lang_start_internal::h80bdaa9ee12e5134 [inlined] std::rt::lang_start_internal::_$u7b$$u7b$closure$u7d$$u7d$::h8c31ec7a8b13107a at rt.rs:52:13 [opt]
    frame #27: 0x0000000100a3f82e neovide`std::rt::lang_start_internal::h80bdaa9ee12e5134 [inlined] std::panicking::try::do_call::h7c5c3835f900e8bd at panicking.rs:331 [opt]
    frame #28: 0x0000000100a3f82e neovide`std::rt::lang_start_internal::h80bdaa9ee12e5134 [inlined] std::panicking::try::hfc986d95955e33bd at panicking.rs:274 [opt]
    frame #29: 0x0000000100a3f82e neovide`std::rt::lang_start_internal::h80bdaa9ee12e5134 [inlined] std::panic::catch_unwind::h021461f3fbd332fb at panic.rs:394 [opt]
    frame #30: 0x0000000100a3f82e neovide`std::rt::lang_start_internal::h80bdaa9ee12e5134 at rt.rs:51 [opt]
    frame #31: 0x00000001000dec91 neovide`std::rt::lang_start::h1e9a4c075cc2b5d2(main=(neovide`neovide::main::h6353e38135ac2e41 at main.rs:22), argc=1, argv=0x00007ffeefbff8f8) at rt.rs:67:5
    frame #32: 0x00000001000c3b12 neovide`main + 34
    frame #33: 0x00007fff694e67fd libdyld.dylib`start + 1
    frame #34: 0x00007fff694e67fd libdyld.dylib`start + 1

Since 64a8c8a#diff-1a7024d46c31d728a04d5e0cafd98df8 merged as part of #70383 which merged on March 25, there's a pretty clear candidate for the regression.

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.O-macosOperating system: macOST-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.regression-from-stable-to-nightlyPerformance or correctness regression from stable to nightly.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions