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

rustc unexpectedly overflowed its stack! this is a bug #125223

Closed
fmckeogh opened this issue May 17, 2024 · 7 comments
Closed

rustc unexpectedly overflowed its stack! this is a bug #125223

fmckeogh opened this issue May 17, 2024 · 7 comments
Labels
C-bug Category: This is a bug. E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example I-crash Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@fmckeogh
Copy link
Member

Steps to reproduce:

  1. Clone https://github.com/fmckeogh/rust_stack_repro
  2. cd foo
  3. cargo b

I have reproduced this on x86_64 Linux and ARM64 macOS hosts. The Linux host had the stack limit removed with ulimit -s unlimited. The workspace has around 11M lines of Rust across 10K crates.

foo is a regular binary target to simplify the reproduction, but I get the same error when using the workspace as a dependency in a cdylib.

Output:

    Blocking waiting for file lock on build directory
   Compiling foo v0.1.0 (/home/fm208/Documents/rust_stack_repro/foo)
error: rustc interrupted by SIGSEGV, printing backtrace

/home/fm208/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-d6f66a8619a171d6.so(+0x2e40fd3)[0x711437e40fd3]
/lib/x86_64-linux-gnu/libc.so.6(+0x42520)[0x711434c42520]
/home/fm208/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/libLLVM.so.18.1-rust-1.78.0-stable(_ZN4llvm9MCContext16createTempSymbolERKNS_5TwineEb+0x11)[0x7114330e98a7]
/home/fm208/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/libLLVM.so.18.1-rust-1.78.0-stable(_ZN4llvm9DwarfFile8addRangeERKNS_16DwarfCompileUnitENS_11SmallVectorINS_9RangeSpanELj2EEE+0x46)[0x7114332a6786]
/home/fm208/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/libLLVM.so.18.1-rust-1.78.0-stable(_ZN4llvm16DwarfCompileUnit23attachRangesOrLowHighPCERNS_3DIEERKNS_15SmallVectorImplISt4pairIPKNS_12MachineInstrES7_EEE+0x677)[0x7114332a63b7]
/home/fm208/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/libLLVM.so.18.1-rust-1.78.0-stable(_ZN4llvm16DwarfCompileUnit25createAndAddScopeChildrenEPNS_12LexicalScopeERNS_3DIEE+0xa5e)[0x7114332a776e]

### cycle encountered after 6 frames with period 7
/home/fm208/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/libLLVM.so.18.1-rust-1.78.0-stable(_ZN4llvm16DwarfCompileUnit25createAndAddScopeChildrenEPNS_12LexicalScopeERNS_3DIEE+0xa95)[0x7114332a77a5]
/home/fm208/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/libLLVM.so.18.1-rust-1.78.0-stable(_ZN4llvm16DwarfCompileUnit25createAndAddScopeChildrenEPNS_12LexicalScopeERNS_3DIEE+0xa95)[0x7114332a77a5]
/home/fm208/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/libLLVM.so.18.1-rust-1.78.0-stable(_ZN4llvm16DwarfCompileUnit25createAndAddScopeChildrenEPNS_12LexicalScopeERNS_3DIEE+0xa95)[0x7114332a77a5]
/home/fm208/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/libLLVM.so.18.1-rust-1.78.0-stable(_ZN4llvm16DwarfCompileUnit25createAndAddScopeChildrenEPNS_12LexicalScopeERNS_3DIEE+0xa95)[0x7114332a77a5]
/home/fm208/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/libLLVM.so.18.1-rust-1.78.0-stable(_ZN4llvm16DwarfCompileUnit25createAndAddScopeChildrenEPNS_12LexicalScopeERNS_3DIEE+0xa95)[0x7114332a77a5]
/home/fm208/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/libLLVM.so.18.1-rust-1.78.0-stable(_ZN4llvm16DwarfCompileUnit25createAndAddScopeChildrenEPNS_12LexicalScopeERNS_3DIEE+0xa95)[0x7114332a77a5]
/home/fm208/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/libLLVM.so.18.1-rust-1.78.0-stable(_ZN4llvm16DwarfCompileUnit25createAndAddScopeChildrenEPNS_12LexicalScopeERNS_3DIEE+0xa95)[0x7114332a77a5]
### recursed 35 times

/home/fm208/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/libLLVM.so.18.1-rust-1.78.0-stable(_ZN4llvm16DwarfCompileUnit25createAndAddScopeChildrenEPNS_12LexicalScopeERNS_3DIEE+0xa95)[0x7114332a77a5]
/home/fm208/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/libLLVM.so.18.1-rust-1.78.0-stable(_ZN4llvm16DwarfCompileUnit25createAndAddScopeChildrenEPNS_12LexicalScopeERNS_3DIEE+0xa95)[0x7114332a77a5]
/home/fm208/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/libLLVM.so.18.1-rust-1.78.0-stable(_ZN4llvm16DwarfCompileUnit25createAndAddScopeChildrenEPNS_12LexicalScopeERNS_3DIEE+0xa95)[0x7114332a77a5]
/home/fm208/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/libLLVM.so.18.1-rust-1.78.0-stable(_ZN4llvm16DwarfCompileUnit25createAndAddScopeChildrenEPNS_12LexicalScopeERNS_3DIEE+0xa95)[0x7114332a77a5]
/home/fm208/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/libLLVM.so.18.1-rust-1.78.0-stable(_ZN4llvm16DwarfCompileUnit25createAndAddScopeChildrenEPNS_12LexicalScopeERNS_3DIEE+0xa95)[0x7114332a77a5]

note: rustc unexpectedly overflowed its stack! this is a bug
note: maximum backtrace depth reached, frames may have been lost
note: we would appreciate a report at https://github.com/rust-lang/rust
note: backtrace dumped due to SIGSEGV! resuming signal
error: could not compile `foo` (bin "foo")

Caused by:
  process didn't exit successfully: `/home/fm208/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/rustc --crate-name foo --edition=2021 foo/src/main.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --diagnostic-width=100 --crate-type bin --emit=dep-info,link -C embed-bitcode=no -C debuginfo=2 -C metadata=c7d09ec5d3af88a5 -C extra-filename=-c7d09ec5d3af88a5 --out-dir /home/fm208/.cargo/target/debug/deps -C incremental=/home/fm208/.cargo/target/debug/incremental -L dependency=/home/fm208/.cargo/target/debug/deps --extern arch=/home/fm208/.cargo/target/debug/deps/libarch-f47278908c860fa1.rlib` (signal: 11, SIGSEGV: invalid memory reference)

Meta

rustc --version --verbose:

rustc 1.78.0 (9b00956e5 2024-04-29)
binary: rustc
commit-hash: 9b00956e56009bab2aa15d7bff10916599e3d6d6
commit-date: 2024-04-29
host: x86_64-unknown-linux-gnu
release: 1.78.0
LLVM version: 18.1.2
@fmckeogh fmckeogh added the C-bug Category: This is a bug. label May 17, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label May 17, 2024
@fmease fmease added I-crash Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels May 17, 2024
@fmckeogh
Copy link
Member Author

After testing, this only occurs on opt-level=0 and opt-level=1.

@fmckeogh
Copy link
Member Author

Adding either inline(always and inline(never) attributes to all functions has no effect

@fmckeogh
Copy link
Member Author

Fixed by setting RUST_MIN_STACK to 128MiB

@workingjubilee
Copy link
Contributor

...sweet mother of mercy...

@workingjubilee
Copy link
Contributor

...a CPU simulator?!

@workingjubilee
Copy link
Contributor

After testing, this only occurs on opt-level=0 and opt-level=1.

Yes, this code seems to crash inside LLVM's debuginfo emitter, I'm not sure if we're even capable of meaningfully influencing it at this point (beyond setting the big stack, as noted). This seems to be a duplicate of #122357

@fmckeogh
Copy link
Member Author

@workingjubilee understood, thank you!:)

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. E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example I-crash Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics. 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

4 participants