Skip to content
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

error: rustc interrupted by SIGSEGV -- i686 OOM #121305

Closed
ctron opened this issue Feb 19, 2024 · 5 comments · Fixed by #122574
Closed

error: rustc interrupted by SIGSEGV -- i686 OOM #121305

ctron opened this issue Feb 19, 2024 · 5 comments · Fixed by #122574
Labels
A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. C-bug Category: This is a bug. I-crash Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics. O-x86_32 Target: x86 processors, 32 bit (like i686-*) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@ctron
Copy link

ctron commented Feb 19, 2024

Running a build of trunk, as part of a Koiji (Fedora Build System) job, I get the following for the i686 target:

Also see: https://kojipkgs.fedoraproject.org//work/tasks/2175/113752175/build.log

     Running `/usr/bin/rustc --crate-name trunk --edition=2021 src/main.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type bin --emit=dep-info,link -C opt-level=3 -C panic=abort -C lto=fat -C codegen-units=1 -C debuginfo=2 -C metadata=d3ec747c4cc21fae -C extra-filename=-d3ec747c4cc21fae --out-dir /builddir/build/BUILD/trunk-0.18.8/target/rpm/deps -L dependency=/builddir/build/BUILD/trunk-0.18.8/target/rpm/deps --extern ansi_term=/builddir/build/BUILD/trunk-0.18.8/target/rpm/deps/libansi_term-c9a74fb1c5a33450.rlib --extern anyhow=/builddir/build/BUILD/trunk-0.18.8/target/rpm/deps/libanyhow-dd048082dae418bb.rlib --extern async_recursion=/builddir/build/BUILD/trunk-0.18.8/target/rpm/deps/libasync_recursion-c69e2e329310a5a4.so --extern axum=/builddir/build/BUILD/trunk-0.18.8/target/rpm/deps/libaxum-ac356d2aa4feb267.rlib --extern axum_server=/builddir/build/BUILD/trunk-0.18.8/target/rpm/deps/libaxum_server-4d9001becb5ce6f6.rlib --extern base64=/builddir/build/BUILD/trunk-0.18.8/target/rpm/deps/libbase64-888a08a1d17b3136.rlib --extern bytes=/builddir/build/BUILD/trunk-0.18.8/target/rpm/deps/libbytes-1942756fbc7ff3f5.rlib --extern cargo_lock=/builddir/build/BUILD/trunk-0.18.8/target/rpm/deps/libcargo_lock-3bedda8dcf2bd92e.rlib --extern cargo_metadata=/builddir/build/BUILD/trunk-0.18.8/target/rpm/deps/libcargo_metadata-13d0b92ddcd9dc1d.rlib --extern clap=/builddir/build/BUILD/trunk-0.18.8/target/rpm/deps/libclap-208af58cda91ff8e.rlib --extern console=/builddir/build/BUILD/trunk-0.18.8/target/rpm/deps/libconsole-be11c805d7b150ab.rlib --extern css_minify=/builddir/build/BUILD/trunk-0.18.8/target/rpm/deps/libcss_minify-6b9f55f91bd0178a.rlib --extern directories=/builddir/build/BUILD/trunk-0.18.8/target/rpm/deps/libdirectories-8da71472ea013b8f.rlib --extern dunce=/builddir/build/BUILD/trunk-0.18.8/target/rpm/deps/libdunce-4105c42cb1567e0a.rlib --extern envy=/builddir/build/BUILD/trunk-0.18.8/target/rpm/deps/libenvy-fcec93522e880756.rlib --extern flate2=/builddir/build/BUILD/trunk-0.18.8/target/rpm/deps/libflate2-c43669308ba55796.rlib --extern futures_util=/builddir/build/BUILD/trunk-0.18.8/target/rpm/deps/libfutures_util-4d4deb3e4637bb82.rlib --extern hex=/builddir/build/BUILD/trunk-0.18.8/target/rpm/deps/libhex-c474070b6b59f573.rlib --extern htmlescape=/builddir/build/BUILD/trunk-0.18.8/target/rpm/deps/libhtmlescape-061ab0d2a39d69b7.rlib --extern http_body=/builddir/build/BUILD/trunk-0.18.8/target/rpm/deps/libhttp_body-2d1e45a2614d06ca.rlib --extern humantime=/builddir/build/BUILD/trunk-0.18.8/target/rpm/deps/libhumantime-278d9379cde96194.rlib --extern humantime_serde=/builddir/build/BUILD/trunk-0.18.8/target/rpm/deps/libhumantime_serde-db7d2ea4d7a0a7dd.rlib --extern hyper=/builddir/build/BUILD/trunk-0.18.8/target/rpm/deps/libhyper-34b7f79d93066f32.rlib --extern lightningcss=/builddir/build/BUILD/trunk-0.18.8/target/rpm/deps/liblightningcss-fb29360f52959467.rlib --extern local_ip_address=/builddir/build/BUILD/trunk-0.18.8/target/rpm/deps/liblocal_ip_address-3113cdb67a5dff42.rlib --extern mime_guess=/builddir/build/BUILD/trunk-0.18.8/target/rpm/deps/libmime_guess-be195c8a943faa19.rlib --extern minify_html=/builddir/build/BUILD/trunk-0.18.8/target/rpm/deps/libminify_html-76ef26fd2ed499ab.rlib --extern minify_js=/builddir/build/BUILD/trunk-0.18.8/target/rpm/deps/libminify_js-361bcf99267f5936.rlib --extern nipper=/builddir/build/BUILD/trunk-0.18.8/target/rpm/deps/libnipper-879431096c30b7ee.rlib --extern notify=/builddir/build/BUILD/trunk-0.18.8/target/rpm/deps/libnotify-e1a4be633bd8a41d.rlib --extern notify_debouncer_full=/builddir/build/BUILD/trunk-0.18.8/target/rpm/deps/libnotify_debouncer_full-970b1992d2b22302.rlib --extern once_cell=/builddir/build/BUILD/trunk-0.18.8/target/rpm/deps/libonce_cell-7cd748c2563a78c0.rlib --extern open=/builddir/build/BUILD/trunk-0.18.8/target/rpm/deps/libopen-739254795e6c5ee7.rlib --extern oxipng=/builddir/build/BUILD/trunk-0.18.8/target/rpm/deps/liboxipng-97b9886d7eefad2d.rlib --extern parking_lot=/builddir/build/BUILD/trunk-0.18.8/target/rpm/deps/libparking_lot-1f4c5b39f1a989bf.rlib --extern remove_dir_all=/builddir/build/BUILD/trunk-0.18.8/target/rpm/deps/libremove_dir_all-ca007ee62736d362.rlib --extern reqwest=/builddir/build/BUILD/trunk-0.18.8/target/rpm/deps/libreqwest-2fd2027d4a7e1435.rlib --extern seahash=/builddir/build/BUILD/trunk-0.18.8/target/rpm/deps/libseahash-aa4788848059bd91.rlib --extern serde=/builddir/build/BUILD/trunk-0.18.8/target/rpm/deps/libserde-0e3c22b8a86f10a3.rlib --extern serde_json=/builddir/build/BUILD/trunk-0.18.8/target/rpm/deps/libserde_json-3da9734373291be3.rlib --extern sha2=/builddir/build/BUILD/trunk-0.18.8/target/rpm/deps/libsha2-af789abc53e545a1.rlib --extern strum=/builddir/build/BUILD/trunk-0.18.8/target/rpm/deps/libstrum-6aad415c38f72078.rlib --extern tar=/builddir/build/BUILD/trunk-0.18.8/target/rpm/deps/libtar-90b7c93a92264b36.rlib --extern thiserror=/builddir/build/BUILD/trunk-0.18.8/target/rpm/deps/libthiserror-bccc0d9083114dce.rlib --extern tokio=/builddir/build/BUILD/trunk-0.18.8/target/rpm/deps/libtokio-99e61a37c268ec96.rlib --extern tokio_stream=/builddir/build/BUILD/trunk-0.18.8/target/rpm/deps/libtokio_stream-5fd73724da08b397.rlib --extern tokio_tungstenite=/builddir/build/BUILD/trunk-0.18.8/target/rpm/deps/libtokio_tungstenite-8606b84c9adc7236.rlib --extern toml=/builddir/build/BUILD/trunk-0.18.8/target/rpm/deps/libtoml-0edc7c99832fdd13.rlib --extern tower_http=/builddir/build/BUILD/trunk-0.18.8/target/rpm/deps/libtower_http-2406bf889da5a646.rlib --extern tracing=/builddir/build/BUILD/trunk-0.18.8/target/rpm/deps/libtracing-4f8ee5d8ef85a130.rlib --extern tracing_subscriber=/builddir/build/BUILD/trunk-0.18.8/target/rpm/deps/libtracing_subscriber-c81d2f014e955f9d.rlib --extern which=/builddir/build/BUILD/trunk-0.18.8/target/rpm/deps/libwhich-b5cddcb173f53f82.rlib --extern zip=/builddir/build/BUILD/trunk-0.18.8/target/rpm/deps/libzip-22daa20d7a6a3f37.rlib -Copt-level=3 -Cdebuginfo=2 -Ccodegen-units=1 -Cstrip=none -Clink-arg=-Wl,-z,relro -Clink-arg=-Wl,-z,now -Clink-arg=-specs=/usr/lib/rpm/redhat/redhat-package-notes --cap-lints=warn -L native=/builddir/build/BUILD/trunk-0.18.8/target/rpm/build/ring-d8d3c8e8e3c88903/out -L native=/builddir/build/BUILD/trunk-0.18.8/target/rpm/build/libdeflate-sys-966c87b836b83231/out/lib -L native=/builddir/build/BUILD/trunk-0.18.8/target/rpm/build/bzip2-sys-65b4b2d68c93585b/out/lib -L native=/builddir/build/BUILD/trunk-0.18.8/target/rpm/build/zstd-sys-b01e8ba32de86af3/out`
error: rustc interrupted by SIGSEGV, printing backtrace
/usr/lib/librustc_driver-52ec46fe17a0f019.so(+0x578c47)[0xf3778c47]
linux-gate.so.1(__kernel_sigreturn+0x0)[0xf7ed85a0]
/usr/lib/libLLVM-17.so(+0xcd8c2c)[0xec6d8c2c]
/usr/lib/libLLVM-17.so(+0xcd87fb)[0xec6d87fb]
/usr/lib/libLLVM-17.so(_ZN4llvm15ValueHandleBase14ValueIsDeletedEPNS_5ValueE+0x121)[0xec1f71c1]
/usr/lib/libLLVM-17.so(_ZN4llvm5ValueD1Ev+0x28)[0xec1f74a8]
/usr/lib/libLLVM-17.so(_ZN4llvm12GlobalObjectD1Ev+0x44)[0xec157034]
/usr/lib/libLLVM-17.so(+0x7c1ddd)[0xec1c1ddd]
/usr/lib/libLLVM-17.so(_ZN4llvm6ModuleD1Ev+0x64)[0xec1bd634]
/usr/lib/libLLVM-17.so(_ZN4llvm15LLVMContextImplD1Ev+0xb6)[0xec1867b6]
/usr/lib/libLLVM-17.so(_ZN4llvm11LLVMContextD1Ev+0x28)[0xec184768]
/usr/lib/libLLVM-17.so(LLVMContextDispose+0x26)[0xec0b6216]
/usr/lib/librustc_driver-52ec46fe17a0f019.so(+0x7eb746)[0xf39eb746]
/usr/lib/librustc_driver-52ec46fe17a0f019.so(_RNvXs1_Cs5wJj2IwsfEc_18rustc_codegen_llvmNtB5_18LlvmCodegenBackendNtNtNtCs2Ot5weHMREJ_17rustc_codegen_ssa6traits5write19WriteBackendMethods11run_fat_lto+0x30e9)[0xf3a04809]
/usr/lib/librustc_driver-52ec46fe17a0f019.so(+0x8f257a)[0xf3af257a]
/usr/lib/librustc_driver-52ec46fe17a0f019.so(+0x8f887a)[0xf3af887a]
/usr/lib/libstd-3ea11b8b961b5e64.so(rust_metadata_std_58d9b43584c2b021+0x7fe5c)[0xf313ae5c]
/usr/lib/libc.so.6(+0x92923)[0xf2f54923]
/usr/lib/libc.so.6(+0x117d88)[0xf2fd9d88]
note: we would appreciate a report at https://github.com/rust-lang/rust
error: could not compile `trunk` (bin "trunk")
Caused by:
  process didn't exit successfully: `/usr/bin/rustc --crate-name trunk --edition=2021 src/main.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type bin --emit=dep-info,link -C opt-level=3 -C panic=abort -C lto=fat -C codegen-units=1 -C debuginfo=2 -C metadata=d3ec747c4cc21fae -C extra-filename=-d3ec747c4cc21fae --out-dir /builddir/build/BUILD/trunk-0.18.8/target/rpm/deps -L dependency=/builddir/build/BUILD/trunk-0.18.8/target/rpm/deps --extern ansi_term=/builddir/build/BUILD/trunk-0.18.8/target/rpm/deps/libansi_term-c9a74fb1c5a33450.rlib --extern anyhow=/builddir/build/BUILD/trunk-0.18.8/target/rpm/deps/libanyhow-dd048082dae418bb.rlib --extern async_recursion=/builddir/build/BUILD/trunk-0.18.8/target/rpm/deps/libasync_recursion-c69e2e329310a5a4.so --extern axum=/builddir/build/BUILD/trunk-0.18.8/target/rpm/deps/libaxum-ac356d2aa4feb267.rlib --extern axum_server=/builddir/build/BUILD/trunk-0.18.8/target/rpm/deps/libaxum_server-4d9001becb5ce6f6.rlib --extern base64=/builddir/build/BUILD/trunk-0.18.8/target/rpm/deps/libbase64-888a08a1d17b3136.rlib --extern bytes=/builddir/build/BUILD/trunk-0.18.8/target/rpm/deps/libbytes-1942756fbc7ff3f5.rlib --extern cargo_lock=/builddir/build/BUILD/trunk-0.18.8/target/rpm/deps/libcargo_lock-3bedda8dcf2bd92e.rlib --extern cargo_metadata=/builddir/build/BUILD/trunk-0.18.8/target/rpm/deps/libcargo_metadata-13d0b92ddcd9dc1d.rlib --extern clap=/builddir/build/BUILD/trunk-0.18.8/target/rpm/deps/libclap-208af58cda91ff8e.rlib --extern console=/builddir/build/BUILD/trunk-0.18.8/target/rpm/deps/libconsole-be11c805d7b150ab.rlib --extern css_minify=/builddir/build/BUILD/trunk-0.18.8/target/rpm/deps/libcss_minify-6b9f55f91bd0178a.rlib --extern directories=/builddir/build/BUILD/trunk-0.18.8/target/rpm/deps/libdirectories-8da71472ea013b8f.rlib --extern dunce=/builddir/build/BUILD/trunk-0.18.8/target/rpm/deps/libdunce-4105c42cb1567e0a.rlib --extern envy=/builddir/build/BUILD/trunk-0.18.8/target/rpm/deps/libenvy-fcec93522e880756.rlib --extern flate2=/builddir/build/BUILD/trunk-0.18.8/target/rpm/deps/libflate2-c43669308ba55796.rlib --extern futures_util=/builddir/build/BUILD/trunk-0.18.8/target/rpm/deps/libfutures_util-4d4deb3e4637bb82.rlib --extern hex=/builddir/build/BUILD/trunk-0.18.8/target/rpm/deps/libhex-c474070b6b59f573.rlib --extern htmlescape=/builddir/build/BUILD/trunk-0.18.8/target/rpm/deps/libhtmlescape-061ab0d2a39d69b7.rlib --extern http_body=/builddir/build/BUILD/trunk-0.18.8/target/rpm/deps/libhttp_body-2d1e45a2614d06ca.rlib --extern humantime=/builddir/build/BUILD/trunk-0.18.8/target/rpm/deps/libhumantime-278d9379cde96194.rlib --extern humantime_serde=/builddir/build/BUILD/trunk-0.18.8/target/rpm/deps/libhumantime_serde-db7d2ea4d7a0a7dd.rlib --extern hyper=/builddir/build/BUILD/trunk-0.18.8/target/rpm/deps/libhyper-34b7f79d93066f32.rlib --extern lightningcss=/builddir/build/BUILD/trunk-0.18.8/target/rpm/deps/liblightningcss-fb29360f52959467.rlib --extern local_ip_address=/builddir/build/BUILD/trunk-0.18.8/target/rpm/deps/liblocal_ip_address-3113cdb67a5dff42.rlib --extern mime_guess=/builddir/build/BUILD/trunk-0.18.8/target/rpm/deps/libmime_guess-be195c8a943faa19.rlib --extern minify_html=/builddir/build/BUILD/trunk-0.18.8/target/rpm/deps/libminify_html-76ef26fd2ed499ab.rlib --extern minify_js=/builddir/build/BUILD/trunk-0.18.8/target/rpm/deps/libminify_js-361bcf99267f5936.rlib --extern nipper=/builddir/build/BUILD/trunk-0.18.8/target/rpm/deps/libnipper-879431096c30b7ee.rlib --extern notify=/builddir/build/BUILD/trunk-0.18.8/target/rpm/deps/libnotify-e1a4be633bd8a41d.rlib --extern notify_debouncer_full=/builddir/build/BUILD/trunk-0.18.8/target/rpm/deps/libnotify_debouncer_full-970b1992d2b22302.rlib --extern once_cell=/builddir/build/BUILD/trunk-0.18.8/target/rpm/deps/libonce_cell-7cd748c2563a78c0.rlib --extern open=/builddir/build/BUILD/trunk-0.18.8/target/rpm/deps/libopen-739254795e6c5ee7.rlib --extern oxipng=/builddir/build/BUILD/trunk-0.18.8/target/rpm/deps/liboxipng-97b9886d7eefad2d.rlib --extern parking_lot=/builddir/build/BUILD/trunk-0.18.8/target/rpm/deps/libparking_lot-1f4c5b39f1a989bf.rlib --extern remove_dir_all=/builddir/build/BUILD/trunk-0.18.8/target/rpm/deps/libremove_dir_all-ca007ee62736d362.rlib --extern reqwest=/builddir/build/BUILD/trunk-0.18.8/target/rpm/deps/libreqwest-2fd2027d4a7e1435.rlib --extern seahash=/builddir/build/BUILD/trunk-0.18.8/target/rpm/deps/libseahash-aa4788848059bd91.rlib --extern serde=/builddir/build/BUILD/trunk-0.18.8/target/rpm/deps/libserde-0e3c22b8a86f10a3.rlib --extern serde_json=/builddir/build/BUILD/trunk-0.18.8/target/rpm/deps/libserde_json-3da9734373291be3.rlib --extern sha2=/builddir/build/BUILD/trunk-0.18.8/target/rpm/deps/libsha2-af789abc53e545a1.rlib --extern strum=/builddir/build/BUILD/trunk-0.18.8/target/rpm/deps/libstrum-6aad415c38f72078.rlib --extern tar=/builddir/build/BUILD/trunk-0.18.8/target/rpm/deps/libtar-90b7c93a92264b36.rlib --extern thiserror=/builddir/build/BUILD/trunk-0.18.8/target/rpm/deps/libthiserror-bccc0d9083114dce.rlib --extern tokio=/builddir/build/BUILD/trunk-0.18.8/target/rpm/deps/libtokio-99e61a37c268ec96.rlib --extern tokio_stream=/builddir/build/BUILD/trunk-0.18.8/target/rpm/deps/libtokio_stream-5fd73724da08b397.rlib --extern tokio_tungstenite=/builddir/build/BUILD/trunk-0.18.8/target/rpm/deps/libtokio_tungstenite-8606b84c9adc7236.rlib --extern toml=/builddir/build/BUILD/trunk-0.18.8/target/rpm/deps/libtoml-0edc7c99832fdd13.rlib --extern tower_http=/builddir/build/BUILD/trunk-0.18.8/target/rpm/deps/libtower_http-2406bf889da5a646.rlib --extern tracing=/builddir/build/BUILD/trunk-0.18.8/target/rpm/deps/libtracing-4f8ee5d8ef85a130.rlib --extern tracing_subscriber=/builddir/build/BUILD/trunk-0.18.8/target/rpm/deps/libtracing_subscriber-c81d2f014e955f9d.rlib --extern which=/builddir/build/BUILD/trunk-0.18.8/target/rpm/deps/libwhich-b5cddcb173f53f82.rlib --extern zip=/builddir/build/BUILD/trunk-0.18.8/target/rpm/deps/libzip-22daa20d7a6a3f37.rlib -Copt-level=3 -Cdebuginfo=2 -Ccodegen-units=1 -Cstrip=none -Clink-arg=-Wl,-z,relro -Clink-arg=-Wl,-z,now -Clink-arg=-specs=/usr/lib/rpm/redhat/redhat-package-notes --cap-lints=warn -L native=/builddir/build/BUILD/trunk-0.18.8/target/rpm/build/ring-d8d3c8e8e3c88903/out -L native=/builddir/build/BUILD/trunk-0.18.8/target/rpm/build/libdeflate-sys-966c87b836b83231/out/lib -L native=/builddir/build/BUILD/trunk-0.18.8/target/rpm/build/bzip2-sys-65b4b2d68c93585b/out/lib -L native=/builddir/build/BUILD/trunk-0.18.8/target/rpm/build/zstd-sys-b01e8ba32de86af3/out` (signal: 11, SIGSEGV: invalid memory reference)
@ctron ctron added C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Feb 19, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Feb 19, 2024
@ctron
Copy link
Author

ctron commented Feb 19, 2024

To my understanding this should be Rust 1.76.0

@matthiaskrgr matthiaskrgr added the A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. label Feb 19, 2024
@saethlin saethlin added I-crash Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics. and removed I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Feb 19, 2024
@jieyouxu jieyouxu added the E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example label Feb 19, 2024
@cuviper
Copy link
Member

cuviper commented Feb 26, 2024

I think this is "just" an OOM situation. Fedora builds with full debuginfo by default, and this package is configured for fat LTO as well, which will all get quite heavy. When I tried to reproduce this with the rustup stable toolchain, I got:

LLVM ERROR: out of memory
Allocation failed

It completed when I turned off debuginfo though. With Fedora's toolchain, I can reproduce your SIGSEGV in LLVM, but it also completes the build when debuginfo is off. My guess is that it is also hitting an allocation failure, but perhaps in a place that doesn't properly check the pointer before trying to use it.

@cuviper
Copy link
Member

cuviper commented Feb 27, 2024

With the rustup toolchain, it's running out of memory in LLVM's SmallVector, which calls llvm::safe_* allocation methods that abort on failure. That's where we get the "LLVM ERROR: out of memory", "Allocation failed".

With the Fedora toolchain, it's running out of memory in LLVM's DenseMap, which calls llvm::allocate_buffer to plain ::operator new, throwing std::bad_alloc. Rust runs its own destructors during that unwind, in particular dropping ModuleCodegen<ModuleLlvm> that calls LLVMContextDispose, and this segfaults in a DenseMap (presumably the same one).

Thread 4 "coordinator" hit Catchpoint 1 (exception thrown), 0xeb696f2a in __cxxabiv1::__cxa_throw (obj=0xffc48410, tinfo=0xeb8603f0 <typeinfo for std::bad_alloc>, dest=0xeb694c30 <std::bad_alloc::~bad_alloc()>)
    at ../../../../libstdc++-v3/libsupc++/eh_throw.cc:81
81        PROBE2 (throw, obj, tinfo);
(gdb) bt
#0  0xeb696f2a in __cxxabiv1::__cxa_throw (obj=0xffc48410, tinfo=0xeb8603f0 <typeinfo for std::bad_alloc>, dest=0xeb694c30 <std::bad_alloc::~bad_alloc()>) at ../../../../libstdc++-v3/libsupc++/eh_throw.cc:81
#1  0xeb67f8b4 in operator new (sz=134217728, al=4) at ../../../../libstdc++-v3/libsupc++/new_opa.cc:153
#2  0xebf81f04 in llvm::allocate_buffer(unsigned int, unsigned int) () at /usr/src/debug/llvm-17.0.6-6.fc40.i386/lib/Support/MemAlloc.cpp:16
#3  0xecd48bb3 in allocateBuckets () at /usr/src/debug/llvm-17.0.6-6.fc40.i386/include/llvm/ADT/DenseMap.h:899
[...]
#23 linkInModule () at /usr/src/debug/llvm-17.0.6-6.fc40.i386/lib/Linker/LinkModules.cpp:607
#24 0xf372395d in LLVMRustLinkerAdd (L=0xa3d96a70, BC=0xb3400010 "BC\300\3365\024", Len=23603900) at /usr/include/c++/14/bits/unique_ptr.h:191
#25 0xf3a032ff in <rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_ssa::traits::write::WriteBackendMethods>::run_fat_lto () from /usr/lib/librustc_driver-52ec46fe17a0f019.so
[...]
(gdb) c
Continuing.

Thread 4 "coordinator" received signal SIGSEGV, Segmentation fault.
LookupBucketFor<llvm::ValueMapCallbackVH<llvm::Value const*, llvm::WeakTrackingVH, llvm::ValueMapConfig<llvm::Value const*, llvm::sys::SmartMutex<false> > > > () at /usr/src/debug/llvm-17.0.6-6.fc40.i386/include/llvm/ADT/DenseMap.h:658
658           if (LLVM_LIKELY(KeyInfoT::isEqual(Val, ThisBucket->getFirst()))) {
(gdb) bt
#0  LookupBucketFor<llvm::ValueMapCallbackVH<llvm::Value const*, llvm::WeakTrackingVH, llvm::ValueMapConfig<llvm::Value const*, llvm::sys::SmartMutex<false> > > > () at /usr/src/debug/llvm-17.0.6-6.fc40.i386/include/llvm/ADT/DenseMap.h:658
#1  LookupBucketFor<llvm::ValueMapCallbackVH<llvm::Value const*, llvm::WeakTrackingVH, llvm::ValueMapConfig<llvm::Value const*, llvm::sys::SmartMutex<false> > > > () at /usr/src/debug/llvm-17.0.6-6.fc40.i386/include/llvm/ADT/DenseMap.h:689
#2  erase () at /usr/src/debug/llvm-17.0.6-6.fc40.i386/include/llvm/ADT/DenseMap.h:331
#3  0xec6d87fb in deleted () at /usr/src/debug/llvm-17.0.6-6.fc40.i386/include/llvm/IR/ValueMap.h:267
#4  0xec1f71c1 in ValueIsDeleted () at /usr/src/debug/llvm-17.0.6-6.fc40.i386/lib/IR/Value.cpp:1230
#5  0xec1f74a8 in ~Value () at /usr/src/debug/llvm-17.0.6-6.fc40.i386/lib/IR/Value.cpp:79
#6  0xec157034 in ~GlobalValue () at /usr/src/debug/llvm-17.0.6-6.fc40.i386/include/llvm/IR/GlobalValue.h:188
#7  ~GlobalObject () at /usr/src/debug/llvm-17.0.6-6.fc40.i386/lib/IR/Globals.cpp:98
#8  0xec1c1ddd in ~GlobalVariable () at /usr/src/debug/llvm-17.0.6-6.fc40.i386/include/llvm/IR/GlobalVariable.h:69
#9  deleteNode () at /usr/src/debug/llvm-17.0.6-6.fc40.i386/include/llvm/ADT/ilist.h:42
#10 erase () at /usr/src/debug/llvm-17.0.6-6.fc40.i386/include/llvm/ADT/ilist.h:205
#11 0xec1bd634 in erase () at /usr/src/debug/llvm-17.0.6-6.fc40.i386/include/llvm/ADT/ilist.h:242
#12 clear () at /usr/src/debug/llvm-17.0.6-6.fc40.i386/include/llvm/ADT/ilist.h:246
#13 ~Module () at /usr/src/debug/llvm-17.0.6-6.fc40.i386/lib/IR/Module.cpp:81
#14 0xec1867b6 in ~LLVMContextImpl () at /usr/src/debug/llvm-17.0.6-6.fc40.i386/lib/IR/LLVMContextImpl.cpp:52
#15 0xec184768 in llvm::LLVMContext::~LLVMContext() () at /usr/src/debug/llvm-17.0.6-6.fc40.i386/lib/IR/LLVMContext.cpp:113
#16 0xec0b6216 in LLVMContextDispose () at /usr/src/debug/llvm-17.0.6-6.fc40.i386/lib/IR/Core.cpp:129
#17 0xf39eb746 in core::ptr::drop_in_place::<rustc_codegen_ssa::ModuleCodegen<rustc_codegen_llvm::ModuleLlvm>> () from /usr/lib/librustc_driver-52ec46fe17a0f019.so
#18 0xf3a04809 in <rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_ssa::traits::write::WriteBackendMethods>::run_fat_lto () from /usr/lib/librustc_driver-52ec46fe17a0f019.so

@jieyouxu jieyouxu removed the E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example label Feb 28, 2024
@Librazy
Copy link

Librazy commented Mar 14, 2024

I encontered this when compiling a big proprietary project to --target=i686-unknown-linux-musl using nightly-2024-03-01 on a x86_64 host

error: rustc interrupted by SIGSEGV, printing backtrace
/usr/local/rustup/toolchains/nightly-2024-03-01-x86_64-unknown-linux-gnu/lib/librustc_driver-57b4203c90092e15.so(+0x2f0de43)[0x7f985610de43]
/lib/x86_64-linux-gnu/libc.so.6(+0x42520)[0x7f9853019520]
/usr/local/rustup/toolchains/nightly-2024-03-01-x86_64-unknown-linux-gnu/lib/libLLVM-18-rust-1.78.0-nightly.so(+0x5d96596)[0x7f9851796596]
/usr/local/rustup/toolchains/nightly-2024-03-01-x86_64-unknown-linux-gnu/lib/libLLVM-18-rust-1.78.0-nightly.so(+0x5e8f617)[0x7f985188f617]
/usr/local/rustup/toolchains/nightly-2024-03-01-x86_64-unknown-linux-gnu/lib/libLLVM-18-rust-1.78.0-nightly.so(_ZN4llvm18ScheduleDAGSDNodes12EmitScheduleERNS_26MachineInstrBundleIteratorINS_12MachineInstrELb0EEE+0x4a0)[0x7f9851889360]
/usr/local/rustup/toolchains/nightly-2024-03-01-x86_64-unknown-linux-gnu/lib/libLLVM-18-rust-1.78.0-nightly.so(_ZN4llvm16SelectionDAGISel17CodeGenAndEmitDAGEv+0x1a22)[0x7f9851935622]
/usr/local/rustup/toolchains/nightly-2024-03-01-x86_64-unknown-linux-gnu/lib/libLLVM-18-rust-1.78.0-nightly.so(_ZN4llvm16SelectionDAGISel20SelectAllBasicBlocksERKNS_8FunctionE+0x1589)[0x7f98519303c9]
/usr/local/rustup/toolchains/nightly-2024-03-01-x86_64-unknown-linux-gnu/lib/libLLVM-18-rust-1.78.0-nightly.so(_ZN4llvm16SelectionDAGISel20runOnMachineFunctionERNS_15MachineFunctionE+0x853)[0x7f985171d713]
/usr/local/rustup/toolchains/nightly-2024-03-01-x86_64-unknown-linux-gnu/lib/libLLVM-18-rust-1.78.0-nightly.so(+0x5d1ce93)[0x7f985171ce93]
/usr/local/rustup/toolchains/nightly-2024-03-01-x86_64-unknown-linux-gnu/lib/libLLVM-18-rust-1.78.0-nightly.so(_ZN4llvm13FPPassManager13runOnFunctionERNS_8FunctionE+0xb00)[0x7f985153fbd0]
/usr/local/rustup/toolchains/nightly-2024-03-01-x86_64-unknown-linux-gnu/lib/libLLVM-18-rust-1.78.0-nightly.so(_ZN4llvm13FPPassManager11runOnModuleERNS_6ModuleE+0x2f)[0x7f985153f0af]
/usr/local/rustup/toolchains/nightly-2024-03-01-x86_64-unknown-linux-gnu/lib/libLLVM-18-rust-1.78.0-nightly.so(_ZN4llvm6legacy15PassManagerImpl3runERNS_6ModuleE+0x264)[0x7f9851a34b6a]
/usr/local/rustup/toolchains/nightly-2024-03-01-x86_64-unknown-linux-gnu/lib/librustc_driver-57b4203c90092e15.so(+0x57aaafa)[0x7f98589aaafa]
/usr/local/rustup/toolchains/nightly-2024-03-01-x86_64-unknown-linux-gnu/lib/librustc_driver-57b4203c90092e15.so(+0x4c6b9aa)[0x7f9857e6b9aa]
/usr/local/rustup/toolchains/nightly-2024-03-01-x86_64-unknown-linux-gnu/lib/librustc_driver-57b4203c90092e15.so(+0x4c6975a)[0x7f9857e6975a]
/usr/local/rustup/toolchains/nightly-2024-03-01-x86_64-unknown-linux-gnu/lib/librustc_driver-57b4203c90092e15.so(+0x4c69442)[0x7f9857e69442]
/usr/local/rustup/toolchains/nightly-2024-03-01-x86_64-unknown-linux-gnu/lib/librustc_driver-57b4203c90092e15.so(+0x4c6793d)[0x7f9857e6793d]
/usr/local/rustup/toolchains/nightly-2024-03-01-x86_64-unknown-linux-gnu/lib/librustc_driver-57b4203c90092e15.so(+0x4c66efd)[0x7f9857e66efd]
/usr/local/rustup/toolchains/nightly-2024-03-01-x86_64-unknown-linux-gnu/lib/libstd-41777efa78699460.so(rust_metadata_std_7b1098677428ad7b+0xc1955)[0x7f9859456955]
/lib/x86_64-linux-gnu/libc.so.6(+0x94ac3)[0x7f985306bac3]
/lib/x86_64-linux-gnu/libc.so.6(+0x126850)[0x7f98530fd850]

@cuviper
Copy link
Member

cuviper commented Mar 14, 2024

@Librazy with an x86_64 host and a different backtrace, I doubt that yours has the same root cause. I suggest filing a separate issue -- but it's going to be hard for anyone to help if they can't reproduce it, since your code is proprietary.

@cuviper cuviper changed the title error: rustc interrupted by SIGSEGV error: rustc interrupted by SIGSEGV -- i686 OOM Mar 14, 2024
@cuviper cuviper added the O-x86_32 Target: x86 processors, 32 bit (like i686-*) label Mar 14, 2024
bors added a commit to rust-lang-ci/rust that referenced this issue Mar 16, 2024
Register LLVM handlers for bad-alloc / OOM

LLVM's default bad-alloc handler may throw if exceptions are enabled,
and `operator new` isn't hooked at all by default. Now we register our
own handler that prints a message similar to fatal errors, then aborts.
We also call the function that registers the C++ `std::new_handler`.

Fixes rust-lang#121305
Cc llvm/llvm-project#85281
r? `@nikic`
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Mar 17, 2024
Register LLVM handlers for bad-alloc / OOM

LLVM's default bad-alloc handler may throw if exceptions are enabled,
and `operator new` isn't hooked at all by default. Now we register our
own handler that prints a message similar to fatal errors, then aborts.
We also call the function that registers the C++ `std::new_handler`.

Fixes rust-lang#121305
Cc llvm/llvm-project#85281
r? `@nikic`
@bors bors closed this as completed in 33b4ed2 Mar 17, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Mar 17, 2024
Rollup merge of rust-lang#122574 - cuviper:llvm-oom, r=nikic

Register LLVM handlers for bad-alloc / OOM

LLVM's default bad-alloc handler may throw if exceptions are enabled,
and `operator new` isn't hooked at all by default. Now we register our
own handler that prints a message similar to fatal errors, then aborts.
We also call the function that registers the C++ `std::new_handler`.

Fixes rust-lang#121305
Cc llvm/llvm-project#85281
r? ``@nikic``
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. C-bug Category: This is a bug. I-crash Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics. O-x86_32 Target: x86 processors, 32 bit (like i686-*) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants