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

sporadic compilation segfaults #121056

Open
git-girl opened this issue Feb 13, 2024 · 14 comments
Open

sporadic compilation segfaults #121056

git-girl opened this issue Feb 13, 2024 · 14 comments
Labels
C-bug Category: This is a bug. I-crash Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics. S-needs-repro Status: This issue has no reproduction and needs a reproduction to make progress. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@git-girl
Copy link

hey there :3

i went to deploy to a pretty wonky debian server yesterday but the compiler segfauted. at this point we are sure that this is triggered by the system being misconfigured in some way. we also found issues with memory slots however after having roughly tested the ram with memtest we still ran into the same segfaults. the compiler segfaults disappeared once we booted a different system on the hardware (this is to say that there might be hardware issues involved but imo rather unlikely and more likely this by frankensteinish system configs {however one thing to note is that the rest of the services on that server are seemingly healthy since quite a while}).

i hope all of this is put concretely enough, if anything is missing please let me know and i can provide more information. we do have backups of this system, but are planning to do a clean install on friday after which i don't know if i am realistically going to be able to reproduce this behavior.

a basic hello world segfaulted more often then not (but it might also compile).
so this:

cargo new hello_world && cd hello_world
# we made sure to always rebuild from scratch as otherwise one passing build would
# make all subsequent builds fail
cargo build && rm -rf target 

Meta

rustc --version --verbose:

rustc 1.76.0 (07dca489a 2024-02-04)
binary: rustc
commit-hash: 07dca489ac2d933c78d3c5158e3f43beefeb02ce
commit-date: 2024-02-04
host: x86_64-unknown-linux-gnu
release: 1.76.0
LLVM version: 17.0.6

i also tried nightly but also ran into segfaults there.

uname -a
Linux hostname 4.19.0-25-amd64 #1 SMP Debian 4.19.289-2 (2023-08-08) x86_64 GNU/Linux
and
Linux hostname 5.10.0-28-amd64 #1 SMP Debian 5.10.209-2 (2024-01-31) x86_64 GNU/Linux
(i upgraded the system to no avail - one thing of note may be that i specifically could not find any reference to the syscall futex_waitv which is 5.19 and later but only futex_wait)

apt list libc6-dev (as syscalls and futex timeouts were involved)
libc6-dev/oldstable,now 2.31-13+deb11u8 amd64 (installed)
and
apt list libc6
libc6/oldstable,now 2.31-13+deb11u8 amd64 (installed)
(and i also installed all recommended or suggested libc on pacakges.debian)

Error output

i have quite a few more error logs and i think that the segfaults didnt always happen in the same ways.

username@hostname:~/helloworlc$ cargo -vv build && rm -rf target/
   Compiling helloworlc v0.1.0 (/home/username/helloworlc)
     Running `CARGO=/home/username/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/cargo CARGO_BIN_NAME=helloworlc CARGO_CRATE_NAME=helloworlc CARGO_MANIFEST_DIR=/home/username/helloworlc CARGO_PKG_AUTHORS='' CARGO_PKG_DESCRIPTION='' CARGO_PKG_HOMEPAGE='' CARGO_PKG_LICENSE='' CARGO_PKG_LICENSE_FILE='' CARGO_PKG_NAME=helloworlc CARGO_PKG_README='' CARGO_PKG_REPOSITORY='' CARGO_PKG_RUST_VERSION='' CARGO_PKG_VERSION=0.1.0 CARGO_PKG_VERSION_MAJOR=0 CARGO_PKG_VERSION_MINOR=1 CARGO_PKG_VERSION_PATCH=0 CARGO_PKG_VERSION_PRE='' CARGO_PRIMARY_PACKAGE=1 LD_LIBRARY_PATH='/home/username/helloworlc/target/debug/deps:/home/username/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib:/home/username/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib' /home/username/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/rustc --crate-name helloworlc --edition=2021 src/main.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --diagnostic-width=116 --crate-type bin --emit=dep-info,link -C embed-bitcode=no -C debuginfo=2 -C metadata=0649e50ebb6b8c97 -C extra-filename=-0649e50ebb6b8c97 --out-dir /home/username/helloworlc/target/debug/deps -C incremental=/home/username/helloworlc/target/debug/incremental -L dependency=/home/username/helloworlc/target/debug/deps`
error: rustc interrupted by SIGSEGV, printing backtrace
                                                                                                                    
/home/username/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-ef0b2e016afc8182.so(+0x2c31aa6)[0x7f1c532a9aa6]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x13140)[0x7f1c5051f140]
/home/username/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/libLLVM-17-rust-1.76.0-stable.so(_ZN4llvm13FPPassManager13runOnFunctionERNS_8FunctionE+0x9eb)[0x7f1c4e98607b]
/home/username/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/libLLVM-17-rust-1.76.0-stable.so(_ZN4llvm13FPPassManager11runOnModuleERNS_6ModuleE+0x2f)[0x7f1c4e98566f]
/home/username/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/libLLVM-17-rust-1.76.0-stable.so(_ZN4llvm6legacy15PassManagerImpl3runERNS_6ModuleE+0x266)[0x7f1c4eb8dbba]
/home/username/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-ef0b2e016afc8182.so(LLVMRustWriteOutputFile+0x190)[0x7f1c5508e358]
/home/username/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-ef0b2e016afc8182.so(+0x4a15f95)[0x7f1c5508df95]
/home/username/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-ef0b2e016afc8182.so(+0x4a13713)[0x7f1c5508b713]
/home/username/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-ef0b2e016afc8182.so(+0x4a133c2)[0x7f1c5508b3c2]
/home/username/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-ef0b2e016afc8182.so(+0x4aabbf1)[0x7f1c55123bf1]
/home/username/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-ef0b2e016afc8182.so(+0x4aab6c2)[0x7f1c551236c2]
/home/username/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/libstd-66d8041607d2929b.so(rust_metadata_std_79729d9c385e1623+0xbe8e5)[0x7f1c506108e5]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x7ea7)[0x7f1c50513ea7]
/lib/x86_64-linux-gnu/libc.so.6(clone+0x3f)[0x7f1c50431a6f]
                                                                                                                    
note: we would appreciate a report at https://github.com/rust-lang/rust
error: could not compile `helloworlc` (bin "helloworlc")
                                                                                                                    
Caused by:
  process didn't exit successfully: `CARGO=/home/username/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/cargo CARGO_BIN_NAME=helloworlc CARGO_CRATE_NAME=helloworlc CARGO_MANIFEST_DIR=/home/username/helloworlc CARGO_PKG_AUTHORS='' CARGO_PKG_DESCRIPTION='' CARGO_PKG_HOMEPAGE='' CARGO_PKG_LICENSE='' CARGO_PKG_LICENSE_FILE='' CARGO_PKG_NAME=helloworlc CARGO_PKG_README='' CARGO_PKG_REPOSITORY='' CARGO_PKG_RUST_VERSION='' CARGO_PKG_VERSION=0.1.0 CARGO_PKG_VERSION_MAJOR=0 CARGO_PKG_VERSION_MINOR=1 CARGO_PKG_VERSION_PATCH=0 CARGO_PKG_VERSION_PRE='' CARGO_PRIMARY_PACKAGE=1 LD_LIBRARY_PATH='/home/username/helloworlc/target/debug/deps:/home/username/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib:/home/username/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib' /home/username/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/rustc --crate-name helloworlc --edition=2021 src/main.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --diagnostic-width=116 --crate-type bin --emit=dep-info,link -C embed-bitcode=no -C debuginfo=2 -C metadata=0649e50ebb6b8c97 -C extra-filename=-0649e50ebb6b8c97 --out-dir /home/username/helloworlc/target/debug/deps -C incremental=/home/username/helloworlc/target/debug/incremental -L dependency=/home/username/helloworlc/target/debug/deps` (signal: 11, SIGSEGV: invalid memory reference)
username@hostname:~/helloworlc$ cargo -vv build && rm -rf target/
   Compiling helloworlc v0.1.0 (/home/username/helloworlc)
     Running `CARGO=/home/username/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/cargo CARGO_BIN_NAME=helloworlc CARGO_CRATE_NAME=helloworlc CARGO_MANIFEST_DIR=/home/username/helloworlc CARGO_PKG_AUTHORS='' CARGO_PKG_DESCRIPTION='' CARGO_PKG_HOMEPAGE='' CARGO_PKG_LICENSE='' CARGO_PKG_LICENSE_FILE='' CARGO_PKG_NAME=helloworlc CARGO_PKG_README='' CARGO_PKG_REPOSITORY='' CARGO_PKG_RUST_VERSION='' CARGO_PKG_VERSION=0.1.0 CARGO_PKG_VERSION_MAJOR=0 CARGO_PKG_VERSION_MINOR=1 CARGO_PKG_VERSION_PATCH=0 CARGO_PKG_VERSION_PRE='' CARGO_PRIMARY_PACKAGE=1 LD_LIBRARY_PATH='/home/username/helloworlc/target/debug/deps:/home/username/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib:/home/username/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib' /home/username/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/rustc --crate-name helloworlc --edition=2021 src/main.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --diagnostic-width=116 --crate-type bin --emit=dep-info,link -C embed-bitcode=no -C debuginfo=2 -C metadata=0649e50ebb6b8c97 -C extra-filename=-0649e50ebb6b8c97 --out-dir /home/username/helloworlc/target/debug/deps -C incremental=/home/username/helloworlc/target/debug/incremental -L dependency=/home/username/helloworlc/target/debug/deps`
error: rustc interrupted by SIGSEGV, printing backtrace

/home/username/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-ef0b2e016afc8182.so(+0x2c31aa6)[0x7fac94769aa6]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x13140)[0x7fac919df140]
/home/username/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/libLLVM-17-rust-1.76.0-stable.so(_ZN4llvm13FPPassManager13runOnFunctionERNS_8FunctionE+0xa03)[0x7fac8fe46093]
/home/username/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/libLLVM-17-rust-1.76.0-stable.so(_ZN4llvm13FPPassManager11runOnModuleERNS_6ModuleE+0x2f)[0x7fac8fe4566f]
/home/username/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/libLLVM-17-rust-1.76.0-stable.so(_ZN4llvm6legacy15PassManagerImpl3runERNS_6ModuleE+0x266)[0x7fac9004dbba]
/home/username/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-ef0b2e016afc8182.so(LLVMRustWriteOutputFile+0x190)[0x7fac9654e358]
/home/username/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-ef0b2e016afc8182.so(+0x4a15f95)[0x7fac9654df95]
/home/username/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-ef0b2e016afc8182.so(+0x4a13713)[0x7fac9654b713]
/home/username/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-ef0b2e016afc8182.so(+0x4a133c2)[0x7fac9654b3c2]
/home/username/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-ef0b2e016afc8182.so(+0x4aabbf1)[0x7fac965e3bf1]
/home/username/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-ef0b2e016afc8182.so(+0x4aab6c2)[0x7fac965e36c2]
/home/username/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/libstd-66d8041607d2929b.so(rust_metadata_std_79729d9c385e1623+0xbe8e5)[0x7fac91ad08e5]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x7ea7)[0x7fac919d3ea7]
/lib/x86_64-linux-gnu/libc.so.6(clone+0x3f)[0x7fac918f1a6f]

note: we would appreciate a report at https://github.com/rust-lang/rust
error: could not compile `helloworlc` (bin "helloworlc")

Caused by:
  process didn't exit successfully: `CARGO=/home/username/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/cargo CARGO_BIN_NAME=helloworlc CARGO_CRATE_NAME=helloworlc CARGO_MANIFEST_DIR=/home/username/helloworlc CARGO_PKG_AUTHORS='' CARGO_PKG_DESCRIPTION='' CARGO_PKG_HOMEPAGE='' CARGO_PKG_LICENSE='' CARGO_PKG_LICENSE_FILE='' CARGO_PKG_NAME=helloworlc CARGO_PKG_README='' CARGO_PKG_REPOSITORY='' CARGO_PKG_RUST_VERSION='' CARGO_PKG_VERSION=0.1.0 CARGO_PKG_VERSION_MAJOR=0 CARGO_PKG_VERSION_MINOR=1 CARGO_PKG_VERSION_PATCH=0 CARGO_PKG_VERSION_PRE='' CARGO_PRIMARY_PACKAGE=1 LD_LIBRARY_PATH='/home/username/helloworlc/target/debug/deps:/home/username/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib:/home/username/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib' /home/username/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/rustc --crate-name helloworlc --edition=2021 src/main.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --diagnostic-width=116 --crate-type bin --emit=dep-info,link -C embed-bitcode=no -C debuginfo=2 -C metadata=0649e50ebb6b8c97 -C extra-filename=-0649e50ebb6b8c97 --out-dir /home/username/helloworlc/target/debug/deps -C incremental=/home/username/helloworlc/target/debug/incremental -L dependency=/home/username/helloworlc/target/debug/deps` (signal: 11, SIGSEGV: invalid memory reference)

Another Error

i also found panics in raw vec because of capacity overflows (there are even more traces where i think the causes are different, i am happy to provide them and can also go through them on another day {right now i just need to go to bed 😬})

Raw Vec Panic
Caused by:
  process didn't exit successfully: `/home/username/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/rustc - --crate-name ___ --print=file-names --crate-type bin --crate-type rlib --crate-type dylib --crate-type cdylib --crate-type staticlib --crate-type proc-macro --print=sysroot --print=split-debuginfo --print=crate-name --print=cfg` (signal: 11, SIGSEGV: invalid memory reference)
  --- stderr
  thread 'rustc' panicked at library/alloc/src/raw_vec.rs:571:5:
  capacity overflow
  stack backtrace:
     0:     0x7f516476d6f6 - <unknown>
     1:     0x7f51647bff40 - <unknown>
     2:     0x7f516476153f - <unknown>
     3:     0x7f516476d4d4 - <unknown>
     4:     0x7f5164770267 - <unknown>
     5:     0x7f516476ffc9 - <unknown>
     6:     0x7f51673f661c - std[79729d9c385e1623]::panicking::update_hook::<alloc[6df67106ebca92c0]::boxed::Box<rustc_driver_impl[66ed8fdbde15dc6c]::install_ice_hook::{closure#0}>>::{closure#0}
     7:     0x7f51647709b6 - <unknown>
     8:     0x7f51647706c9 - <unknown>
     9:     0x7f516476dbf6 - <unknown>
    10:     0x7f5164770460 - <unknown>
    11:     0x7f51647bc645 - <unknown>
    12:     0x7f51647ad98f - <unknown>
    13:     0x7f516911acd2 - <alloc[6df67106ebca92c0]::vec::Vec<(std[79729d9c385e1623]::path::PathBuf, std[79729d9c385e1623]::path::PathBuf)> as core[f975038e3cc9791c]::clone::Clone>::clone
    14:     0x7f516911b0c7 - rustc_codegen_llvm[3c1678ba3e8e7d64]::back::write::target_machine_factory
    15:     0x7f516911a952 - rustc_codegen_llvm[3c1678ba3e8e7d64]::back::write::create_informational_target_machine
    16:     0x7f516911ba65 - rustc_codegen_llvm[3c1678ba3e8e7d64]::llvm_util::target_features
    17:     0x7f516911ba37 - <rustc_codegen_llvm[3c1678ba3e8e7d64]::LlvmCodegenBackend as rustc_codegen_ssa[8f0ba34f7d763469]::traits::backend::CodegenBackend>::target_features
    18:     0x7f5169294df0 - rustc_interface[bf5cafa581ab7832]::util::add_configuration
    19:     0x7f51692dff40 - rustc_interface[bf5cafa581ab7832]::interface::run_compiler::<core[f975038e3cc9791c]::result::Result<(), rustc_span[7a149c27976a99e7]::ErrorGuaranteed>, rustc_driver_impl[66ed8fdbde15dc6c]::run_compiler::{closure#0}>::{closure#0}
    20:     0x7f516940e7db - std[79729d9c385e1623]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[bf5cafa581ab7832]::util::run_in_thread_with_globals<rustc_interface[bf5cafa581ab7832]::interface::run_compiler<core[f975038e3cc9791c]::result::Result<(), rustc_span[7a149c27976a99e7]::ErrorGuaranteed>, rustc_driver_impl[66ed8fdbde15dc6c]::run_compiler::{closure#0}>::{closure#0}, core[f975038e3cc9791c]::result::Result<(), rustc_span[7a149c27976a99e7]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[f975038e3cc9791c]::result::Result<(), rustc_span[7a149c27976a99e7]::ErrorGuaranteed>>
    21:     0x7f516940e639 - <<std[79729d9c385e1623]::thread::Builder>::spawn_unchecked_<rustc_interface[bf5cafa581ab7832]::util::run_in_thread_with_globals<rustc_interface[bf5cafa581ab7832]::interface::run_compiler<core[f975038e3cc9791c]::result::Result<(), rustc_span[7a149c27976a99e7]::ErrorGuaranteed>, rustc_driver_impl[66ed8fdbde15dc6c]::run_compiler::{closure#0}>::{closure#0}, core[f975038e3cc9791c]::result::Result<(), rustc_span[7a149c27976a99e7]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[f975038e3cc9791c]::result::Result<(), rustc_span[7a149c27976a99e7]::ErrorGuaranteed>>::{closure#1} as core[f975038e3cc9791c]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
    22:     0x7f516477a8e5 - <unknown>
  error: rustc interrupted by SIGSEGV, printing backtrace
                                                                                                        
  /home/username/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-ef0b2e016afc8182.so(+0x2c31aa6)[0x7f5167413aa6]
  /lib/x86_64-linux-gnu/libpthread.so.0(+0x13140)[0x7f5164689140]
  /home/username/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/rustc(+0x2882d)[0x5645fb08282d]
  /home/username/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/rustc(+0x28d83)[0x5645fb082d83]
  /home/username/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/rustc(+0x1f3ea)[0x5645fb0793ea]
  /home/username/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/libstd-66d8041607d2929b.so(rust_metadata_std_79729d9c385e1623+0xda072)[0x7f5164796072]
  /home/username/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/libstd-66d8041607d2929b.so(rust_metadata_std_79729d9c385e1623+0xda224)[0x7f5164796224]
  /home/username/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/libstd-66d8041607d2929b.so(_ZN5gimli4read6abbrev13Abbreviations6insert17h4d60ba1a57156ad8E+0x22d)[0x7f516479649d]
  /home/username/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/libstd-66d8041607d2929b.so(rust_metadata_std_79729d9c385e1623+0x8b4c2)[0x7f51647474c2]
  /home/username/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/libstd-66d8041607d2929b.so(rust_metadata_std_79729d9c385e1623+0x87c0a)[0x7f5164743c0a]
  /home/username/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/libstd-66d8041607d2929b.so(rust_metadata_std_79729d9c385e1623+0xc5f24)[0x7f5164781f24]
  /home/username/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/libstd-66d8041607d2929b.so(rust_metadata_std_79729d9c385e1623+0xce8c6)[0x7f516478a8c6]
  /home/username/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/libstd-66d8041607d2929b.so(rust_metadata_std_79729d9c385e1623+0xc99ad)[0x7f51647859ad]
  /home/username/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/libstd-66d8041607d2929b.so(rust_metadata_std_79729d9c385e1623+0xb18b0)[0x7f516476d8b0]
  /home/username/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/libstd-66d8041607d2929b.so(rust_metadata_std_79729d9c385e1623+0xc45c1)[0x7f51647805c1]
  /lib/x86_64-linux-gnu/libgcc_s.so.1(_Unwind_Backtrace+0x64)[0x7f515cbce2b4]
  /home/username/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/libstd-66d8041607d2929b.so(_ZN91_$LT$std..sys_common..backtrace.._print..DisplayBacktrace$u20$as$u20$core..fmt..Display$GT$3fmt17hbb235daedd7c6190E+0x176)[0x7f516476d6f6]
  /home/username/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/libstd-66d8041607d2929b.so(_ZN4core3fmt5write17h3ed6aeaa977c8e45E+0x1b0)[0x7f51647bff40]
  /home/username/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/libstd-66d8041607d2929b.so(rust_metadata_std_79729d9c385e1623+0xa553f)[0x7f516476153f]
  /home/username/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/libstd-66d8041607d2929b.so(rust_metadata_std_79729d9c385e1623+0xb14d4)[0x7f516476d4d4]
  /home/username/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/libstd-66d8041607d2929b.so(rust_metadata_std_79729d9c385e1623+0xb4267)[0x7f5164770267]
  /home/username/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/libstd-66d8041607d2929b.so(_ZN3std9panicking12default_hook17hf5fcb0f213fe709aE+0x269)[0x7f516476ffc9]
  /home/username/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-ef0b2e016afc8182.so(+0x2c1461c)[0x7f51673f661c]
  /home/username/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/libstd-66d8041607d2929b.so(_ZN3std9panicking20rust_panic_with_hook17h095fccf1dc9379eeE+0x276)[0x7f51647709b6]
  /home/username/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/libstd-66d8041607d2929b.so(rust_metadata_std_79729d9c385e1623+0xb46c9)[0x7f51647706c9]
  /home/username/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/libstd-66d8041607d2929b.so(rust_metadata_std_79729d9c385e1623+0xb1bf6)[0x7f516476dbf6]
  /home/username/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/libstd-66d8041607d2929b.so(_ZN102_$LT$std..panicking..begin_panic_handler..FormatStringPayload$u20$as$u20$core..panic..PanicPayload$GT$8take_box17heb0dcd5e4b4a5c86E+0x0)[0x7f5164770460]
  /home/username/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/libstd-66d8041607d2929b.so(rust_metadata_std_79729d9c385e1623+0x100645)[0x7f51647bc645]
  /home/username/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/libstd-66d8041607d2929b.so(rust_metadata_std_79729d9c385e1623+0xf198f)[0x7f51647ad98f]
  /home/username/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-ef0b2e016afc8182.so(+0x4938cd2)[0x7f516911acd2]
  /home/username/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-ef0b2e016afc8182.so(+0x49390c7)[0x7f516911b0c7]
  /home/username/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-ef0b2e016afc8182.so(+0x4938952)[0x7f516911a952]
  /home/username/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-ef0b2e016afc8182.so(_RNvNtCs59QrpCZBv10_18rustc_codegen_llvm9llvm_util15target_features+0x25)[0x7f516911ba65]
  /home/username/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-ef0b2e016afc8182.so(_RNvXs5_Cs59QrpCZBv10_18rustc_codegen_llvmNtB5_18LlvmCodegenBackendNtNtNtCschqvOleydkH_17rustc_codegen_ssa6traits7backend14CodegenBackend15target_features+0xf)[0x7f516911ba37]
  /home/username/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-ef0b2e016afc8182.so(_RNvNtCsgqCaRwxIDM4_15rustc_interface4util17add_configuration+0x30)[0x7f5169294df0]
  /home/username/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-ef0b2e016afc8182.so(+0x4afdf40)[0x7f51692dff40]
  /home/username/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-ef0b2e016afc8182.so(+0x4c2c7db)[0x7f516940e7db]
  /home/username/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-ef0b2e016afc8182.so(+0x4c2c639)[0x7f516940e639]
  /home/username/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/libstd-66d8041607d2929b.so(rust_metadata_std_79729d9c385e1623+0xbe8e5)[0x7f516477a8e5]
  /lib/x86_64-linux-gnu/libpthread.so.0(+0x7ea7)[0x7f516467dea7]
  /lib/x86_64-linux-gnu/libc.so.6(clone+0x3f)[0x7f516459da6f]
                                                                                                        
  note: we would appreciate a report at https://github.com/rust-lang/rust
  note: backtrace dumped due to SIGSEGV! resuming signal

LLDB

LLDB

obtained by lldb bt all (note that these were technically two different rust projects failing here and as said before not all segfaults were alike so yeah but yeah)

(lldb) run build
Process 15748 launched: '/home/username/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/cargo' (x86_64)
Process 15748 stopped and restarted: thread 1 received signal: SIGCHLD
Process 15748 stopped and restarted: thread 1 received signal: SIGCHLD
Process 15748 stopped and restarted: thread 1 received signal: SIGCHLD
   Compiling hello_world v0.1.0 (/tmp/hello_world)
error: rustc interrupted by SIGSEGV, printing backtrace
                                                                                                                                                                                          
/home/username/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-ef0b2e016afc8182.so(+0x2c31aa6)[0x7ffff5098aa6]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x13140)[0x7ffff230e140]
/home/username/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/libLLVM-17-rust-1.76.0-stable.so(_ZN4llvm13FPPassManager13runOnFunctionERNS_8FunctionE+0x9eb)[0x7ffff077507b]
/home/username/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/libLLVM-17-rust-1.76.0-stable.so(_ZN4llvm13FPPassManager11runOnModuleERNS_6ModuleE+0x2f)[0x7ffff077466f]
/home/username/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/libLLVM-17-rust-1.76.0-stable.so(_ZN4llvm6legacy15PassManagerImpl3runERNS_6ModuleE+0x266)[0x7ffff097cbba]
/home/username/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-ef0b2e016afc8182.so(LLVMRustWriteOutputFile+0x190)[0x7ffff6e7d358]
/home/username/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-ef0b2e016afc8182.so(+0x4a15f95)[0x7ffff6e7cf95]
/home/username/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-ef0b2e016afc8182.so(+0x4a13713)[0x7ffff6e7a713]
/home/username/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-ef0b2e016afc8182.so(+0x4a133c2)[0x7ffff6e7a3c2]
/home/username/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-ef0b2e016afc8182.so(+0x4aabbf1)[0x7ffff6f12bf1]
/home/username/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-ef0b2e016afc8182.so(+0x4aab6c2)[0x7ffff6f126c2]
/home/username/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/libstd-66d8041607d2929b.so(rust_metadata_std_79729d9c385e1623+0xbe8e5)[0x7ffff23ff8e5]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x7ea7)[0x7ffff2302ea7]
/lib/x86_64-linux-gnu/libc.so.6(clone+0x3f)[0x7ffff2220a6f]
                                                                                                                                                                                          
note: we would appreciate a report at https://github.com/rust-lang/rust
Process 15748 stopped and restarted: thread 3 received signal: SIGCHLD
error: could not compile `hello_world` (bin "hello_world")
                                                                                                                                                                                          
Caused by:
  process didn't exit successfully: `rustc --crate-name hello_world --edition=2021 src/main.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type bin --emit=dep-info,link -C embed-bitcode=no -C debuginfo=2 -C metadata=63db71e2032dbcc4 -C extra-filename=-63db71e2032dbcc4 --out-dir /tmp/hello_world/target/debug/deps -C incremental=/tmp/hello_world/target/debug/incremental -L dependency=/tmp/hello_world/target/debug/deps` (signal: 11, SIGSEGV: invalid memory reference)
Process 15748 stopped
* thread #2, name = 'cargo', stop reason = signal SIGUSR1
    frame #0: 0x0000555556ca363d cargo`std::sys::unix::locks::futex_condvar::Condvar::wait::hd4469932b30d626b [inlined] std::sys::unix::locks::futex_mutex::Mutex::lock::h2824c483f8557e8f at futex_mutex.rs:28:13
(lldb) bt all
This version of LLDB has no plugin for the mipsassem language. Inspection of frame variables will be limited.
  thread #1, name = 'cargo'
    frame #0: 0x00007ffff7d47f69 libc.so.6`syscall at syscall.S:38
    frame #1: 0x0000555556c9d794 cargo`std::sys::unix::futex::futex_wait::h44b2d96d9c845f91 at futex.rs:62:21
    frame #2: 0x0000555556ca369a cargo`std::sys::unix::locks::futex_condvar::Condvar::wait_timeout::hd94527c2d21ef338 [inlined] std::sys::unix::locks::futex_condvar::Condvar::wait_optional_timeout::hc9031b8473901451 at futex_condvar.rs:49:17
    frame #3: 0x0000555556ca3663 cargo`std::sys::unix::locks::futex_condvar::Condvar::wait_timeout::hd94527c2d21ef338 at futex_condvar.rs:37
    frame #4: 0x0000555556b58507 cargo`_RNvXs3_Cs77E4pHqZjLV_9jobserverNtB5_12HelperThreadNtNtNtCslpQXAMNzwFQ_4core3ops4drop4Drop4drop + 343
    frame #5: 0x0000555555d192bd cargo`_RINvNtCslpQXAMNzwFQ_4core3ptr13drop_in_placeNtCs77E4pHqZjLV_9jobserver12HelperThreadECsdafv1eHZXBe_5cargo + 13
    frame #6: 0x00005555560a0d28 cargo`_RNvMs2_NtNtNtCsdafv1eHZXBe_5cargo4core8compiler9job_queueNtB5_8JobQueue7execute + 6104
    frame #7: 0x000055555606b327 cargo`_RNvMNtNtNtCsdafv1eHZXBe_5cargo4core8compiler7contextNtB2_7Context7compile + 20023
    frame #8: 0x00005555561bee5e cargo`_RNvNtNtCsdafv1eHZXBe_5cargo3ops13cargo_compile10compile_ws + 558
    frame #9: 0x00005555561beb7b cargo`_RNvNtNtCsdafv1eHZXBe_5cargo3ops13cargo_compile7compile + 139
    frame #10: 0x0000555555bcceed cargo`_RNvNtNtCsasa3T5feJmt_5cargo8commands5build4exec + 621
    frame #11: 0x0000555555ba93a0 cargo`_RNvNtCsasa3T5feJmt_5cargo3cli4main + 12272
    frame #12: 0x0000555555be5a7a cargo`_RNvCsasa3T5feJmt_5cargo4main + 1370
    frame #13: 0x0000555555b696a3 cargo`_RINvNtNtCsaqsJ7jMcZrz_3std10sys_common9backtrace28___rust_begin_short_backtraceFEuuECsasa3T5feJmt_5cargo + 3
    frame #14: 0x0000555555b781a9 cargo`_RNCINvNtCsaqsJ7jMcZrz_3std2rt10lang_startuE0Csasa3T5feJmt_5cargo + 9
    frame #15: 0x0000555556c86851 cargo`std::rt::lang_start_internal::h6939038e2873596b [inlined] core::ops::function::impls::_$LT$impl$u20$core..ops..function..FnOnce$LT$A$GT$$u20$for$u20$$RF$F$GT$::call_once::h37600b1e5eea4ecd at function.rs:284:13
    frame #16: 0x0000555556c8684b cargo`std::rt::lang_start_internal::h6939038e2873596b [inlined] std::panicking::try::do_call::hb4bda49fa13a0c2b at panicking.rs:552
    frame #17: 0x0000555556c8684b cargo`std::rt::lang_start_internal::h6939038e2873596b [inlined] std::panicking::try::h8bbf75149211aaaa at panicking.rs:516
    frame #18: 0x0000555556c8684b cargo`std::rt::lang_start_internal::h6939038e2873596b [inlined] std::panic::catch_unwind::h8c78ec68ebea34cb at panic.rs:142
    frame #19: 0x0000555556c8684b cargo`std::rt::lang_start_internal::h6939038e2873596b [inlined] std::rt::lang_start_internal::_$u7b$$u7b$closure$u7d$$u7d$::hffdf44a19fd9e220 at rt.rs:148
    frame #20: 0x0000555556c8684b cargo`std::rt::lang_start_internal::h6939038e2873596b [inlined] std::panicking::try::do_call::hcb3194972c74716d at panicking.rs:552
    frame #21: 0x0000555556c8684b cargo`std::rt::lang_start_internal::h6939038e2873596b [inlined] std::panicking::try::hcdc6892c5f0dba4c at panicking.rs:516
    frame #22: 0x0000555556c8684b cargo`std::rt::lang_start_internal::h6939038e2873596b [inlined] std::panic::catch_unwind::h4910beb4573f4776 at panic.rs:142
    frame #23: 0x0000555556c8684b cargo`std::rt::lang_start_internal::h6939038e2873596b at rt.rs:148
    frame #24: 0x0000555555bebd55 cargo`main + 37
    frame #25: 0x00007ffff7c76d0a libc.so.6`__libc_start_main(main=(cargo`main), argc=2, argv=0x00007fffffffe7d8, init=<unavailable>, fini=<unavailable>, rtld_fini=<unavailable>, stack_end=0x00007fffffffe7c8) at libc-start.c:308:16
    frame #26: 0x0000555555b4a029 cargo`_start + 41
* thread #2, name = 'cargo', stop reason = signal SIGUSR1
  * frame #0: 0x0000555556ca363d cargo`std::sys::unix::locks::futex_condvar::Condvar::wait::hd4469932b30d626b [inlined] std::sys::unix::locks::futex_mutex::Mutex::lock::h2824c483f8557e8f at futex_mutex.rs:28:13
    frame #1: 0x0000555556ca363a cargo`std::sys::unix::locks::futex_condvar::Condvar::wait::hd4469932b30d626b [inlined] std::sys::unix::locks::futex_condvar::Condvar::wait_optional_timeout::hc9031b8473901451 at futex_condvar.rs:52
    frame #2: 0x0000555556ca363a cargo`std::sys::unix::locks::futex_condvar::Condvar::wait::hd4469932b30d626b at futex_condvar.rs:33
    frame #3: 0x0000555556b55134 cargo`_RINvNtNtCsaqsJ7jMcZrz_3std10sys_common9backtrace28___rust_begin_short_backtraceNCNvNtCs77E4pHqZjLV_9jobserver3imp12spawn_helpers_0uEB1l_ + 276
    frame #4: 0x0000555556b55496 cargo`_RNSNvYNCINvMNtCsaqsJ7jMcZrz_3std6threadNtBa_7Builder16spawn_unchecked_NCNvNtCs77E4pHqZjLV_9jobserver3imp12spawn_helpers_0uEs_0INtNtNtCslpQXAMNzwFQ_4core3ops8function6FnOnceuE9call_once6vtableB1c_ + 166
    frame #5: 0x0000555556ca17a5 cargo`std::sys::unix::thread::Thread::new::thread_start::hbac657605e4b7389 [inlined] _$LT$alloc..boxed..Box$LT$F$C$A$GT$$u20$as$u20$core..ops..function..FnOnce$LT$Args$GT$$GT$::call_once::h12de4fc57affb195 at boxed.rs:2015:9
    frame #6: 0x0000555556ca179d cargo`std::sys::unix::thread::Thread::new::thread_start::hbac657605e4b7389 [inlined] _$LT$alloc..boxed..Box$LT$F$C$A$GT$$u20$as$u20$core..ops..function..FnOnce$LT$Args$GT$$GT$::call_once::h3c619f45059d5cf1 at boxed.rs:2015
    frame #7: 0x0000555556ca1796 cargo`std::sys::unix::thread::Thread::new::thread_start::hbac657605e4b7389 at thread.rs:108
    frame #8: 0x00007ffff7f72ea7 libpthread.so.0`start_thread(arg=<unavailable>) at pthread_create.c:477:8
    frame #9: 0x00007ffff7d4ea6f libc.so.6`__clone at clone.S:95

best regards and thanks so much for all the work!

@git-girl git-girl 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 13, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Feb 13, 2024
@workingjubilee
Copy link
Member

What is with the "compiler acts suspicious enough that memtest has to be used to try to rule that out, but the results come back clean for memtest, but we still can't really pin down a specific problem in rustc" issues lately? Perhaps I was too hasty in closing #119005...

@ds84182
Copy link

ds84182 commented Feb 14, 2024

Just a hunch: what CPU do you have?

@saethlin
Copy link
Member

Reminds me of #120955

@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 14, 2024
@workingjubilee
Copy link
Member

workingjubilee commented Feb 14, 2024

@git-girl This is a weird request, but can you bootstrap a new copy of rustc and LLVM, on a host that builds with a matching glibc version, and then deploy it on this wonky-ass server, and see if that still has the same spotty build errors? You may have to refer to the rustc-dev-guide for assistance.

My hypothesis is that maybe one of the post-build optimizations we apply, that doesn't happen to a freshly bootstrapped host, might be causing an issue in a rare system configuration we're not testing.

@jieyouxu
Copy link
Member

@rustbot label +S-needs-repro

@rustbot rustbot added the S-needs-repro Status: This issue has no reproduction and needs a reproduction to make progress. label Feb 14, 2024
@git-girl
Copy link
Author

thanks so much for everyones replies! i am still working on the reproduction with a docker and i think i got stuck
a bit on the llvm bootstrapping

(just to make sure @workingjubilee i need to just follow the rustc build and that build already builds all the
llvm things right? i put my current docker file for it below i need to actually do the stage2 build and
put it on the server tomorrow and test the behavior {my colleague tested just a docker container today with
no luck, yesterday i originally also build rustc from a nix flake which is where i first encountered the issues})

@ds84182 here is the lscpu output:

`lscpu`
Architecture:                       x86_64
CPU op-mode(s):                     32-bit, 64-bit
Byte Order:                         Little Endian
Address sizes:                      48 bits physical, 48 bits virtual
CPU(s):                             8
On-line CPU(s) list:                0-7
Thread(s) per core:                 1
Core(s) per socket:                 4
Socket(s):                          2
NUMA node(s):                       2
Vendor ID:                          AuthenticAMD
CPU family:                         16
Model:                              2
Model name:                         Quad-Core AMD Opteron(tm) Processor 2350
Stepping:                           3
CPU MHz:                            1994.981
BogoMIPS:                           3989.96
Virtualization:                     AMD-V
L1d cache:                          512 KiB
L1i cache:                          512 KiB
L2 cache:                           4 MiB
L3 cache:                           4 MiB
NUMA node0 CPU(s):                  0-3
NUMA node1 CPU(s):                  4-7
Vulnerability Gather data sampling: Not affected
Vulnerability Itlb multihit:        Not affected
Vulnerability L1tf:                 Not affected
Vulnerability Mds:                  Not affected
Vulnerability Meltdown:             Not affected
Vulnerability Mmio stale data:      Not affected
Vulnerability Retbleed:             Not affected
Vulnerability Spec rstack overflow: Not affected
Vulnerability Spec store bypass:    Not affected
Vulnerability Spectre v1:           Mitigation; usercopy/swapgs barriers and __user pointer sanitization
Vulnerability Spectre v2:           Mitigation; Retpolines, STIBP disabled, RSB filling, PBRSB-eIBRS Not affected
Vulnerability Srbds:                Not affected
Vulnerability Tsx async abort:      Not affected
Flags:                              fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2
                                     ht syscall nx mmxext fxsr_opt pdpe1gb rdtscp lm 3dnowext 3dnow constant_tsc rep_good nopl nonsto
                                    p_tsc cpuid extd_apicid pni monitor cx16 popcnt lahf_lm cmp_legacy svm extapic cr8_legacy abm sse
                                    4a misalignsse 3dnowprefetch osvw ibs hw_pstate vmmcall npt lbrv svm_lock
and the docker file i have atm
FROM debian:11

# RUN apt-get update && apt-get install -y libc6 git curl tar python3 build-essential g++ libssl-dev ninja-build
RUN apt-get update && apt-get install -y libc6 git curl tar python3 build-essential g++ libssl-dev # ninja-build
RUN bash -c 'if [[ "$(ldd --version | awk '\''NR==1{print $NF}'\'')" == "2.31" ]]; then echo "libc okay"; else exit; fi;'

# This was from my attempt to compile llvm because: 
# build cmake from source as debian 11 cmake isnt new enough :{
# WORKDIR /home
# RUN curl -L https://github.com/Kitware/CMake/releases/download/v3.28.3/cmake-3.28.3.tar.gz -o cmake.tar.gz
# RUN tar -xzf cmake.tar.gz
# WORKDIR /home/cmake-3.28.3
# RUN ./bootstrap
# RUN gmake
# RUN gmake install

# Attempt to compile llvm from upstream against the rust cmake files 
# LLVM version: 17.0.6
# WORKDIR /home
# # this repo seems to not be correct as building it with the cmake command below i run into the issue of the 
# RUN curl -L https://github.com/llvm/llvm-project/archive/refs/tags/llvmorg-17.0.6.tar.gz -o llvm_src.tar.gz
# # this seems to be the wrong repo to build from as clang/ is missing from the root
# # RUN curl -L https://github.com/llvm/llvm-project/releases/download/llvmorg-17.0.6/llvm-17.0.6.src.tar.xz -o llvm_src.tar.xz
# RUN tar -xzf llvm_src.tar.gz
# RUN mkdir -p /home/llvm-project-llvmorg-17.0.6/builddir 
# WORKDIR /home/llvm-project-llvmorg-17.0.6/builddir 
# # RUN cmake -DCMAKE_BUILD_TYPE=Release /home/llvm-17.0.6.src
# RUN cmake -G Ninja -C /home/rustc-1.76.0-src/src/llvm-project/clang/cmake/caches/DistributionExample.cmake /home/llvm-project-llvmorg-17.0.6
# RUN ninja stage2-distribution
# RUN ninja stage2-install-distribution

# Attempt building LLVM from llvm upstream in isolation
# RUN cmake --build . --target install
# # to easier find this 
# RUN cmake -DCMAKE_INSTALL_PREFIX=/home/llvm.result -P cmake_install.cmake

# build rust
WORKDIR /home
RUN curl -L https://static.rust-lang.org/dist/rustc-1.76.0-src.tar.gz -o rust.tar.gz
RUN tar -xzf rust.tar.gz 
WORKDIR /home/rustc-1.76.0-src
RUN cp config.example.toml config.toml
RUN ./x.py build

RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | bash -s -- -y

ADD bash_stuff.sh /root/bash_stuff.sh
ENTRYPOINT ["/bin/bash", "/root/bash_stuff.sh"]
#```
# #!/usr/bin/env bash 
#
# source "$HOME/.cargo/env"
# rustup toolchain link stage0 build/host/stage0-sysroot
# rustup toolchain link stage1 build/host/stage1
# rustup override set stage1
#```

# How do i use llvm that was compiled by the previous build step for the stage2 build
# somewhere in the sysroot guy?
#
# CMD cargo version -Vv

@ds84182
Copy link

ds84182 commented Feb 15, 2024

Looking at CPU Errata for that CPU I found:
image

Checked the Linux kernel and I didn't see anything mentioning it, and considering this bug I'm pretty sure its unpatched.

See also:

Just to confirm @git-girl can you run the linked reproducer to see if it (eventually) crashes on your system?

@git-girl
Copy link
Author

@ds84182 oh no i think you are right in that it's a cpu issue. the reproduction is segfaulting.
i am not entirely sure because i didn't understand how the reproduction program is segfaulting at the point it is, but i also have practially no understanding of assembly.

i can't test setting the msr bit because i'll need to make changes to grub and reboot which i can't do remotely, i'll get to try that tomorrow morning though :)

 username@hostname:~/cpu.reproduction$ LANGUAGE=en_US strace ./a.out

 execve("./a.out", ["./a.out"], 0x7fff5f10a220 /* 36 vars */) = 0
 brk(NULL)                               = 0x55a06369d000
 access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
 openat(AT_FDCWD, "/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
 fstat(3, {st_mode=S_IFREG|0644, st_size=66860, ...}) = 0
 mmap(NULL, 66860, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f061e42f000
 close(3)                                = 0
 openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
 read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0@>\2\0\0\0\0\0"..., 832) = 832
 fstat(3, {st_mode=S_IFREG|0755, st_size=1901536, ...}) = 0
 mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f061e42d000
 mmap(NULL, 1914496, PROT_READ, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f061e259000
 mmap(0x7f061e27b000, 1413120, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x22000) = 0x7f061e27b000
 mmap(0x7f061e3d4000, 323584, PROT_READ, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x17b000) = 0x7f061e3d4000
 mmap(0x7f061e423000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1c9000) = 0x7f061e423000
 mmap(0x7f061e429000, 13952, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f061e429000
 close(3)                                = 0
 arch_prctl(ARCH_SET_FS, 0x7f061e42e540) = 0
 mprotect(0x7f061e423000, 16384, PROT_READ) = 0
 mprotect(0x55a062994000, 4096, PROT_READ) = 0
 mprotect(0x7f061e46a000, 4096, PROT_READ) = 0
 munmap(0x7f061e42f000, 66860)           = 0
 --- SIGSEGV {si_signo=SIGSEGV, si_code=SEGV_MAPERR, si_addr=NULL} ---
 +++ killed by SIGSEGV +++
here is the output of me stepping through starting from main:
(lldb) breakpoint set --name main

Breakpoint 4: where = a.out`main, address = 0x0000000000001125
(lldb) run
Process 524651 launched: '/home/username/cpu.reproduction/a.out' (x86_64)
Process 524651 stopped
* thread #1, name = 'a.out', stop reason = breakpoint 4.1
frame #0: 0x0000555555555125 a.out`main
a.out`main:
->  0x555555555125 <+0>: pushq  %rbp
0x555555555126 <+1>: movq   %rsp, %rbp
0x555555555129 <+4>: subq   $0x10, %rsp
0x55555555512d <+8>: movl   %edi, -0x4(%rbp)
(lldb) next
Process 524651 stopped
* thread #1, name = 'a.out', stop reason = instruction step over
frame #0: 0x0000555555555126 a.out`main + 1
a.out`main:
->  0x555555555126 <+1>:  movq   %rsp, %rbp
0x555555555129 <+4>:  subq   $0x10, %rsp
0x55555555512d <+8>:  movl   %edi, -0x4(%rbp)
0x555555555130 <+11>: movq   %rsi, -0x10(%rbp)
(lldb)
Process 524651 stopped
* thread #1, name = 'a.out', stop reason = instruction step over
frame #0: 0x0000555555555129 a.out`main + 4
a.out`main:
->  0x555555555129 <+4>:  subq   $0x10, %rsp
0x55555555512d <+8>:  movl   %edi, -0x4(%rbp)
0x555555555130 <+11>: movq   %rsi, -0x10(%rbp)
0x555555555134 <+15>: movl   $0x0, %eax
(lldb)
Process 524651 stopped
* thread #1, name = 'a.out', stop reason = instruction step over
frame #0: 0x000055555555512d a.out`main + 8
a.out`main:
->  0x55555555512d <+8>:  movl   %edi, -0x4(%rbp)
0x555555555130 <+11>: movq   %rsi, -0x10(%rbp)
0x555555555134 <+15>: movl   $0x0, %eax
0x555555555139 <+20>: callq  0x555555555140            ; ras
(lldb)
Process 524651 stopped
* thread #1, name = 'a.out', stop reason = instruction step over
frame #0: 0x0000555555555130 a.out`main + 11
a.out`main:
->  0x555555555130 <+11>: movq   %rsi, -0x10(%rbp)
0x555555555134 <+15>: movl   $0x0, %eax
0x555555555139 <+20>: callq  0x555555555140            ; ras
0x55555555513e <+25>: jmp    0x555555555134            ; <+15>
(lldb)
Process 524651 stopped
* thread #1, name = 'a.out', stop reason = instruction step over
frame #0: 0x0000555555555134 a.out`main + 15
a.out`main:
->  0x555555555134 <+15>: movl   $0x0, %eax
0x555555555139 <+20>: callq  0x555555555140            ; ras
0x55555555513e <+25>: jmp    0x555555555134            ; <+15>

a.out`ras:
0x555555555140 <+0>:  movq   0x0, %r8
(lldb)
Process 524651 stopped
* thread #1, name = 'a.out', stop reason = instruction step over
frame #0: 0x0000555555555139 a.out`main + 20
a.out`main:
->  0x555555555139 <+20>: callq  0x555555555140            ; ras
0x55555555513e <+25>: jmp    0x555555555134            ; <+15>

a.out`ras:
0x555555555140 <+0>:  movq   0x0, %r8

a.out`ras2:
0x555555555148 <+0>:  pushq  %rax
(lldb)
Process 524651 stopped
* thread #1, name = 'a.out', stop reason = signal SIGSEGV: invalid address (fault address: 0x0)
frame #0: 0x0000555555555140 a.out`ras
a.out`ras:
->  0x555555555140 <+0>: movq   0x0, %r8

a.out`ras2:
0x555555555148 <+0>: pushq  %rax
0x555555555149 <+1>: pushq  %rcx
0x55555555514a <+2>: pushq  %rdx
(lldb) bt all
* thread #1, name = 'a.out', stop reason = signal SIGSEGV: invalid address (fault address: 0x0)
* frame #0: 0x0000555555555140 a.out`ras
frame #1: 0x000055555555513e a.out`main + 25
frame #2: 0x00007ffff7e08d0a libc.so.6`__libc_start_main(main=(a.out`main), argc=1, argv=0x00007fffffffe838, init=<unavailable>, fini=<unavailable>, rtld_fini=<unavailable>, stack_end=0x00007fffffffe828) at libc-start.c:308:16
frame #3: 0x000055555555506a a.out`_start + 42

@ds84182
Copy link

ds84182 commented Feb 15, 2024

Hmm, I think you may have copied the assembly snippet incorrectly. Can you verify that it the movq line is movq $80, %r8?

@git-girl
Copy link
Author

ah omg yes sorry, still segfaults after a while though, which i guess means this is the issue.

this is from journalctl -k

Feb 15 22:00:24 hostname kernel: a.out[630588]: segfault at 7fa6c8ea3718 ip 00007fa6c8ea3718 sp 00007ffe449f7c60 error 15 in libc-2.31.so[7fa6c8ea3000+2000]
Feb 15 22:00:24 hostname kernel: Code: 00 00 c0 1a e5 c8 a6 7f 00 00 c0 14 e5 c8 a6 7f 00 00 c0 1e e5 c8 a6 7f 00 00 c0 23 e5 c8 a6 7f 00 00 e0 e6 e6 c8 a6 7f 00 00 <20> 4e ea c8 a6 7f 00 00 40 52 ea c8 a6 7f 00 00 00 00 00 00 00 00

and a bt all from lldb:

* thread #1, name = 'a.out', stop reason = signal SIGSEGV: address access protected (fault address: 0x7ffff7fb3718)
    frame #0: 0x00007ffff7fb3718
->  0x7ffff7fb3718: andb   %cl, -0x5(%rsi)
    0x7ffff7fb371b: idivl  %edi
    0x7ffff7fb371d: jg     0x7ffff7fb371f
    0x7ffff7fb371f: addb   %al, 0x52(%rax)

@git-girl
Copy link
Author

git-girl commented Feb 16, 2024

what also worked was to bootstrap the compiler as you suggested @workingjubilee
at least after 250 (should be statistically significant compared to how often it occured prior {like maybe at minimum every 10 tries}) tries per method of compilation i couldn't reproduce the bug.

i hope i did everything right bootsrapping i was a bit afraid that i messed up
somewhere, because the cargo version seemed weird. however i tried with both

  • cargo +stage2 build && rm -rf target and
  • rustc +stage2 src/main.rs && ./main && rm -rf main

i built it like this:

#!/usr/bin/env bash 

source "$HOME/.cargo/env"
rustup toolchain link stage0 build/host/stage0-sysroot
rustup toolchain link stage1 build/host/stage1
rustup override set stage1

cd /home/rustc-1.76.0-src
./x.py build --stage 2

rustup toolchain link stage2 build/host/stage2

# i hate docker
bash

rustc versions:

username@hostname:~/helloworlc$ rustc +stage2 -Vv
rustc 1.76.0-dev (07dca489a 2024-02-04) (built from a source tarball)
binary: rustc
commit-hash: 07dca489ac2d933c78d3c5158e3f43beefeb02ce
commit-date: 2024-02-04
host: x86_64-unknown-linux-gnu
release: 1.76.0-dev
LLVM version: 17.0.6
username@hostname:~/helloworlc$ cargo +stage2 version -v
cargo 1.78.0-nightly (ccc84ccec 2024-02-07)
release: 1.78.0-nightly
commit-hash: ccc84ccec4b7340eb916aefda1cb3e2fe17d8e7b
commit-date: 2024-02-07
host: x86_64-unknown-linux-gnu
libgit2: 1.7.2 (sys:0.18.2 vendored)
libcurl: 8.6.0-DEV (sys:0.4.71+curl-8.6.0 vendored ssl:OpenSSL/1.1.1w)
ssl: OpenSSL 1.1.1w  11 Sep 2023
os: Debian 11 (bullseye) [64-bit]

@git-girl
Copy link
Author

sorry for the many comments, we are about to do a clean install on the machine and i just checked that setting the msr bit didnt prevent the compiliation segfaults @ds84182

@workingjubilee
Copy link
Member

workingjubilee commented Feb 17, 2024

thanks so much for everyones replies! i am still working on the reproduction with a docker and i think i got stuck a bit on the llvm bootstrapping

(just to make sure @workingjubilee i need to just follow the rustc build and that build already builds all the llvm things right?

Basically, yes, although IIRC the default config.toml you used would download its LLVM from CI. I don't think that matters too much, however. Knowing that the "default build" of rustc is seemingly free of these problems makes me wonder if this is BOLT or BOLT+strip or BOLT+PGO interactions again, as in:

Unfortunately I don't know an easy or even just tractable to enable running a BOLT-optimized or PGO-optimized build so that we can recombine the various optimizations and see what breaks on your machine...

sorry for the many comments, we are about to do a clean install on the machine and i just checked that setting the msr bit didnt prevent the compiliation segfaults

That is slightly concerning! Just to verify: How exactly did you set the MSR bit? And thank you for doing so much investigatory work!

@workingjubilee
Copy link
Member

workingjubilee commented Feb 17, 2024

@git-girl If you are brave enough to try using PGO, this is the command we use in the middle of our distribution build's opt pipeline:

RUST_BACKTRACE=full python3 ../x.py dist --host x86_64-unknown-linux-gnu --target x86_64-unknown-linux-gnu --include-default-paths build-manifest bootstrap --llvm-profile-use /tmp/tmp-multistage/opt-artifacts/llvm-pgo.profdata --rust-profile-use /tmp/tmp-multistage/opt-artifacts/rustc-pgo.profdata --keep-stage 0 --keep-stage 1 --reproducible-artifact /tmp/tmp-multistage/opt-artifacts/LLVM-bolt.profdata --reproducible-artifact /tmp/tmp-multistage/opt-artifacts/rustc-bolt.profdata

Apparently with a cwd of /checkout/obj? You... may need to change a few of the arguments based on the actual build paths you have in play, and such... and then the question becomes "does LLVM's PGO-optimized build produce a faulting compiler?" and then does strip do it and then etc. etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. I-crash Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics. S-needs-repro Status: This issue has no reproduction and needs a reproduction to make progress. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

6 participants