Repository navigation
rustc aborts when there is a compilation failure on FreeBSD and OpenBSD #43575
Description
Activity
- addedC-bugCategory: This is a bug.Category: This is a bug.O-freebsdOperating system: FreeBSDOperating system: FreeBSD
on Aug 3, 2017 I have the same problem with OpenBSD if I switch from
stdc++tolibc++andlibc++abi.Under this configuration (
libc++), the compilation of rustc is done right, but several tests failed, specially in failing tests (compile-fail or parse-fail tests for example).A simple way to reproduce the error is to run
rustc -v: the compiler will crash.$ rustc -vV rustc 1.19.0 binary: rustc commit-hash: unknown commit-date: unknown host: x86_64-unknown-openbsd release: 1.19.0 LLVM version: 4.0 $ rustc -v error: no input filename given fatal runtime error: failed to initiate panic, error 5 Abort trap (core dumped)The error is correctly reported ("no input filename given"), but just after rustc die due to internal panic error.
I am suspecting a problem between rust and libc++ regarding unwinding. It could be a rustc problem as a libc++/libc++abi problem.
Please note that all unitary tests on panicking/unwinding passes.
Running via gdb, with unwind debugging:
$ gdb -args rustc -v GNU gdb (GDB) 7.12.1 (gdb) set environment LIBUNWIND_PRINT_UNWINDING=1 LIBUNWIND_PRINT_APIS=1 (gdb) run Starting program: /data/semarie/repos/openbsd/ports/pobj/rust-1.19.0/build-amd64/build/x86_64-unknown-openbsd/stage2/bin/rustc -v error: no input filename given libuwind: unwind_phase1(ex_ojb=0x1f1d1d5a7000): pc=0x1f1ccb1d9ce4, start_ip=0x1f1ccb1d9c70, func=__rust_start_panic, lsda=0x0, personality=0x0 libuwind: unwind_phase1(ex_ojb=0x1f1d1d5a7000): pc=0x1f1ccb1cd529, start_ip=0x1f1ccb1cd520, func=.anonymous., lsda=0x0, personality=0x0 libuwind: unwind_phase1(ex_ojb=0x1f1d1d5a7000): pc=0x1f1ccb1cd4e6, start_ip=0x1f1ccb1cd330, func=_ZN3std9panicking20rust_panic_with_hook17hf2d11de5f905222bE, lsda=0x1f1ccb382c3c, personality=0x1f1ccb1d97a0 libuwind: unwind_phase1(ex_ojb=0x1f1d1d5a7000): calling personality function 0x1f1ccb1d97a0 libuwind: unwind_phase1(ex_ojb=0x1f1d1d5a7000): _URC_CONTINUE_UNWIND libuwind: unwind_phase1(ex_ojb=0x1f1d1d5a7000): pc=0x1f1d7cc32d78, start_ip=0x1f1d7cc32d60, func=.anonymous., lsda=0x0, personality=0x0 libuwind: unwind_phase1(ex_ojb=0x1f1d1d5a7000): pc=0x1f1d7ce2953d, start_ip=0x1f1d7ce29350, func=_ZN5rustc7session11early_error17h0187f9fdb6331d60E, lsda=0x1f1d7d156c98, personality=0x1f1ccb1d97a0 libuwind: unwind_phase1(ex_ojb=0x1f1d1d5a7000): calling personality function 0x1f1ccb1d97a0 libuwind: unwind_phase1(ex_ojb=0x1f1d1d5a7000): _URC_CONTINUE_UNWIND libuwind: unwind_phase1(ex_ojb=0x1f1d1d5a7000): pc=0x1f1d108ebe6d, start_ip=0x1f1d108e9a10, func=_ZN93_$LT$rustc_driver..RustcDefaultCalls$u20$as$u20$rustc_driver..CompilerCalls$LT$$u27$a$GT$$GT$8no_input17hc57ca5476db31dacE, lsda=0x1f1d10a7ad9c, personality=0x1f1ccb1d97a0 libuwind: unwind_phase1(ex_ojb=0x1f1d1d5a7000): calling personality function 0x1f1ccb1d97a0 libuwind: unwind_phase1(ex_ojb=0x1f1d1d5a7000): _URC_CONTINUE_UNWIND libuwind: unwind_phase1(ex_ojb=0x1f1d1d5a7000): pc=0x1f1d108e77ef, start_ip=0x1f1d108e7330, func=_ZN12rustc_driver12run_compiler17h8fb3410f76685058E, lsda=0x1f1d10a7a9d4, personality=0x1f1ccb1d97a0 libuwind: unwind_phase1(ex_ojb=0x1f1d1d5a7000): calling personality function 0x1f1ccb1d97a0 libuwind: unwind_phase1(ex_ojb=0x1f1d1d5a7000): _URC_CONTINUE_UNWIND libuwind: unwind_phase1(ex_ojb=0x1f1d1d5a7000): unw_step() reached bottom => _URC_END_OF_STACK fatal runtime error: failed to initiate panic, error 5 [New thread 259044] Thread 2 received signal SIGABRT, Aborted. [Switching to thread 259044] thrkill () at -:3 3 -: No such file or directory. (gdb) bt #0 thrkill () at -:3 #1 0x00001f1d2ddb11ad in _libc_abort () at /usr/src/lib/libc/stdlib/abort.c:52 #2 0x00001f1ccb1bed31 in std::sys_common::util::abort::h076c0bb8451af0e6 () from /data/semarie/repos/openbsd/ports/pobj/rust-1.19.0/build-amd64/build/x86_64-unknown-openbsd/stage2/lib/libstd-2ce1d6a76eafdd05.so #3 0x00001f1ccb1cd57e in rust_panic () from /data/semarie/repos/openbsd/ports/pobj/rust-1.19.0/build-amd64/build/x86_64-unknown-openbsd/stage2/lib/libstd-2ce1d6a76eafdd05.so #4 0x00001f1ccb1cd4e6 in std::panicking::rust_panic_with_hook::hf2d11de5f905222b () from /data/semarie/repos/openbsd/ports/pobj/rust-1.19.0/build-amd64/build/x86_64-unknown-openbsd/stage2/lib/libstd-2ce1d6a76eafdd05.so #5 0x00001f1d7cc32d78 in std::panicking::begin_panic::h6afedfaffc3f9d2e () from /data/semarie/repos/openbsd/ports/pobj/rust-1.19.0/build-amd64/build/x86_64-unknown-openbsd/stage2/lib/librustc-011439a32a903962.so #6 0x00001f1d7ce2953d in rustc::session::early_error::h0187f9fdb6331d60 () from /data/semarie/repos/openbsd/ports/pobj/rust-1.19.0/build-amd64/build/x86_64-unknown-openbsd/stage2/lib/librustc-011439a32a903962.so #7 0x00001f1d108ebe6d in _$LT$rustc_driver..RustcDefaultCalls$u20$as$u20$rustc_driver..CompilerCalls$LT$$u27$a$GT$$GT$::no_input::hc57ca5476db31dac () from /data/semarie/repos/openbsd/ports/pobj/rust-1.19.0/build-amd64/build/x86_64-unknown-openbsd/stage2/lib/librustc_driver-052b8dbae020bc96.so #8 0x00001f1d108e77ef in rustc_driver::run_compiler::h8fb3410f76685058 () from /data/semarie/repos/openbsd/ports/pobj/rust-1.19.0/build-amd64/build/x86_64-unknown-openbsd/stage2/lib/librustc_driver-052b8dbae020bc96.so #9 0x00001f1d1080c26c in std::sys_common::backtrace::__rust_begin_short_backtrace::hd612f4587ecab5f6 () from /data/semarie/repos/openbsd/ports/pobj/rust-1.19.0/build-amd64/build/x86_64-unknown-openbsd/stage2/lib/librustc_driver-052b8dbae020bc96.so #10 0x00001f1ccb1d9c27 in __rust_maybe_catch_panic () from /data/semarie/repos/openbsd/ports/pobj/rust-1.19.0/build-amd64/build/x86_64-unknown-openbsd/stage2/lib/libstd-2ce1d6a76eafdd05.so #11 0x00001f1d10831c61 in _$LT$F$u20$as$u20$alloc..boxed..FnBox$LT$A$GT$$GT$::call_box::hff49756066bea45b () from /data/semarie/repos/openbsd/ports/pobj/rust-1.19.0/build-amd64/build/x86_64-unknown-openbsd/stage2/lib/librustc_driver-052b8dbae020bc96.so #12 0x00001f1ccb1cc1a8 in std::sys::imp::thread::Thread::new::thread_start::h4f30b5b9f427f3ca () from /data/semarie/repos/openbsd/ports/pobj/rust-1.19.0/build-amd64/build/x86_64-unknown-openbsd/stage2/lib/libstd-2ce1d6a76eafdd05.so #13 0x00001f1d8fca15ce in _rthread_start (v=0x0) at /usr/src/lib/librthread/rthread.c:115 #14 0x00001f1d2dd5dbdb in __tfork_thread () at /usr/src/lib/libc/arch/amd64/sys/tfork_thread.S:75 #15 0x0000000000000000 in ?? () (gdb)@Mark-Simulacrum could you update the tags please ?
- addedI-crashIssue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.O-openbsdOperating system: OpenBSDOperating system: OpenBSD
on Aug 8, 2017 I confirm that building with
debuginfo=trueis enough to make to crash disappear.- changed the title
[-]rustc aborts when there is a compilation failure on FreeBSD[/-][+]rustc aborts when there is a compilation failure on FreeBSD and OpenBSD[/+]on Aug 8, 2017 Using a rustc binary compiled with
debuginfo=true, I traced the program using libunwind debugging.$ gdb -args rustc -v GNU gdb (GDB) 7.12.1 (gdb) set environment LIBUNWIND_PRINT_UNWINDING=1 LIBUNWIND_PRINT_APIS=1 (gdb) run libuwind: unwind_phase1(ex_ojb=0x7642d21b980): pc=0x763ec2fae54, start_ip=0x763ec2fade0, func=__rust_start_panic, lsda=0x0, personality=0x0 libuwind: unwind_phase1(ex_ojb=0x7642d21b980): pc=0x763ec2ee56d, start_ip=0x763ec2ee560, func=.anonymous., lsda=0x0, personality=0x0 libuwind: unwind_phase1(ex_ojb=0x7642d21b980): pc=0x763ec2ee517, start_ip=0x763ec2ee340, func=_ZN3std9panicking20rust_panic_with_hook17hf2d11de5f905222bE, lsda=0x763ec4a69c8, personality=0x763ec2fa8f0 libuwind: unwind_phase1(ex_ojb=0x7642d21b980): calling personality function 0x763ec2fa8f0 libuwind: unwind_phase1(ex_ojb=0x7642d21b980): _URC_CONTINUE_UNWIND libuwind: unwind_phase1(ex_ojb=0x7642d21b980): pc=0x763600148fb, start_ip=0x763600148e0, func=.anonymous., lsda=0x0, personality=0x0 libuwind: unwind_phase1(ex_ojb=0x7642d21b980): pc=0x763601fefcb, start_ip=0x763601fedd0, func=_ZN5rustc7session11early_error17h0187f9fdb6331d60E, lsda=0x76360521010, personality=0x763ec2fa8f0 libuwind: unwind_phase1(ex_ojb=0x7642d21b980): calling personality function 0x763ec2fa8f0 libuwind: unwind_phase1(ex_ojb=0x7642d21b980): _URC_CONTINUE_UNWIND libuwind: unwind_phase1(ex_ojb=0x7642d21b980): pc=0x7637809902a, start_ip=0x76378096e30, func=_ZN93_$LT$rustc_driver..RustcDefaultCalls$u20$as$u2 0$rustc_driver..CompilerCalls$LT$$u27$a$GT$$GT$8no_input17hc57ca5476db31dacE, lsda=0x76378226ca4, personality=0x763ec2fa8f0 libuwind: unwind_phase1(ex_ojb=0x7642d21b980): calling personality function 0x763ec2fa8f0 libuwind: unwind_phase1(ex_ojb=0x7642d21b980): _URC_CONTINUE_UNWIND libuwind: unwind_phase1(ex_ojb=0x7642d21b980): pc=0x76378094e44, start_ip=0x763780949e0, func=_ZN12rustc_driver12run_compiler17h8fb3410f76685058E, lsda=0x763782268dc, personality=0x763ec2fa8f0 libuwind: unwind_phase1(ex_ojb=0x7642d21b980): calling personality function 0x763ec2fa8f0 libuwind: unwind_phase1(ex_ojb=0x7642d21b980): _URC_CONTINUE_UNWIND libuwind: unwind_phase1(ex_ojb=0x7642d21b980): pc=0x76377fc01b2, start_ip=0x76377fbfe40, func=.anonymous., lsda=0x76378211190, personality=0x763ec2fa8f0 libuwind: unwind_phase1(ex_ojb=0x7642d21b980): calling personality function 0x763ec2fa8f0 libuwind: unwind_phase1(ex_ojb=0x7642d21b980): _URC_CONTINUE_UNWIND libuwind: unwind_phase1(ex_ojb=0x7642d21b980): pc=0x763ec2fad9b, start_ip=0x763ec2fad80, func=__rust_maybe_catch_panic, lsda=0x763ec4a6be0, personality=0x763ec2fa8f0 libuwind: unwind_phase1(ex_ojb=0x7642d21b980): calling personality function 0x763ec2fa8f0 libuwind: unwind_phase1(ex_ojb=0x7642d21b980): _URC_HANDLER_FOUND libuwind: unwind_phase2(ex_ojb=0x763b3a84880) libuwind: unwind_phase2(ex_ojb=0x763b3a84880): start_ip=0x763ec2fade0, func=__rust_start_panic, sp=0x7f7ffffc8370, lsda=0x0, personality=0x0 libuwind: unwind_phase2(ex_ojb=0x763b3a84880): start_ip=0x763ec2ee560, func=.anonymous., sp=0x7f7ffffc83c0, lsda=0x0, personality=0x0 libuwind: unwind_phase2(ex_ojb=0x763b3a84880): start_ip=0x763ec2ee340, func=_ZN3std9panicking20rust_panic_with_hook17hf2d11de5f905222bE, sp=0x7f7ffffc8420, lsda=0x763ec4a69c8, personality=0x763ec2fa8f0 libuwind: unwind_phase2(ex_ojb=0x763b3a84880): _URC_CONTINUE_UNWIND libuwind: unwind_phase2(ex_ojb=0x763b3a84880): start_ip=0x76377fc1510, func=.anonymous., sp=0x7f7ffffc84f0, lsda=0x0, personality=0x0 libuwind: unwind_phase2(ex_ojb=0x763b3a84880): start_ip=0x763780a3a50, func=_ZN12rustc_driver11exit_on_err17h4a90782c564b79d5E, sp=0x7f7ffffc8520, lsda=0x0, personality=0x0 libuwind: unwind_phase2(ex_ojb=0x763b3a84880): start_ip=0x763780a3be0, func=_ZN12rustc_driver4main17hd2323c6d770bec56E, sp=0x7f7ffffc8560, lsda=0x76378227e24, personality=0x763ec2fa8f0 libuwind: unwind_phase2(ex_ojb=0x763b3a84880): _URC_INSTALL_CONTEXT libuwind: unwind_phase2(ex_ojb=0x763b3a84880): re-entering user code with ip=0x763780a4cab, sp=0x7f7ffffc8560 libuwind: unwind_phase2(ex_ojb=0x763b3a84880) libuwind: unwind_phase2(ex_ojb=0x763b3a84880): start_ip=0x763780a3be0, func=_ZN12rustc_driver4main17hd2323c6d770bec56E, sp=0x7f7ffffc8560, lsda=0x76378227e24, personality=0x763ec2fa8f0 libuwind: unwind_phase2(ex_ojb=0x763b3a84880): _URC_CONTINUE_UNWIND libuwind: unwind_phase2(ex_ojb=0x763b3a84880): start_ip=0x763ec2fad80, func=__rust_maybe_catch_panic, sp=0x7f7ffffc8a80, lsda=0x763ec4a6be0, personality=0x763ec2fa8f0 libuwind: unwind_phase2(ex_ojb=0x763b3a84880): _URC_INSTALL_CONTEXT libuwind: unwind_phase2(ex_ojb=0x763b3a84880): re-entering user code with ip=0x763ec2fada6, sp=0x7f7ffffc8a80 [Inferior 1 (process 99116) exited with code 0145] (gdb)the main difference is where libunwind stop to unwind the stack trace.
in bogus one, libunwind found
_ZN12rustc_driver12run_compiler17h8fb3410f76685058Eand stop (return_URC_END_OF_STACK).in right one, libunwind found an anonymous function just after, and continue unwinding with
__rust_maybe_catch_panicwhere it founds the handler (and unwinding phase2 could start).I finally found that i686-unknown-linux-musl, which use also libunwind from LLVM, uses a workaround for the same issue: it uses
eliminate_frame_pointer = falseinTargetOptions.This way, all programs compiled with rustc will be compiled with functional unwinding.
For me, it is still a workaround, but it seems to work well.
The problem seems that some information (need usually by libunwind) is missing for anonymous function (unwinding-tables information ?), and with explicit framepointer libunwind is able to compensate this lake of information.
I confirm that setting
eliminate_frame_pointertofalseresults in a working compiler.I talked to Ed Maste and Dimitry Andric about the bug in LLVM bugtracker you mentionned and they don't think this is the same problem. Ed told me about Clang's
-fexceptionsflag which could help. I find little to no informations about it, but I'll play a bit with it.- added 2 commits that reference this issue
on Nov 30, 2017 It seems like this workaround no longer works on FreeBSD but I'm not sure.
Actually it does work, will submit a PR for it.
- added a commit that references this issue
on Feb 24, 2018 - added 2 commits that reference this issue
on Mar 9, 2018 - addedT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
on Nov 22, 2019 Is this issue resolved now? I see:
error: aborting due to 5 previous errors; 1 warning emitted error: build failedAnd no fatal runtime error or abort trap. FreeBSD 13ish, rust-nightly 1.49.
If it's resolved, let's close it! Thanks.
The bugzilla issue referenced in the code that works around this problem (https://bugs.llvm.org/show_bug.cgi?id=30879) has been fixed. Could anyone test with the workaround reverted?
When there is a compilation failure, the Rust compiler aborts with the following output:
I used the following invalid source file:
Here is the backtrace:
As you can see in the paths, this is with Rust 1.19.0. The same happens with previous versions, so this isn't a regression (or not a recent one).
In the example, Rust was compiled with Clang 4.0.0, but the bundled LLVM was used.
When I compile and run a program which panics, the panic looks to be handled correctly:
I don't know how to debug this further. I tried with
debuginfo = trueanddebuginfo-lines = trueinconfig.toml, but then the problem vanishes. I'm willing to help but I would like some pointers to where to look :-)