Skip to content

Borrowing an i32 an obscene amount of times (4770) results in SIGSEGV #135553

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

Closed
psprojectC opened this issue Jan 15, 2025 · 4 comments
Closed

Borrowing an i32 an obscene amount of times (4770) results in SIGSEGV #135553

psprojectC opened this issue Jan 15, 2025 · 4 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. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@psprojectC
Copy link

I was curious to see what was gonna happen if I borrowed something a stupid amount of times. Turns out at the very least rustc in playground (as well as mine under Ubuntu WSL) crashes.

Code

fn main() {
    let a = 5;
    let b = &&& /*won't include the remaining ampersands*/&&&a;
    dbg!(b);
}

Here's a playground link to all of the amperands

Meta

rustc --version --verbose:

owner@DESKTOP-G91GA1P:~/bug$ rustc --version --verbose
rustc 1.82.0 (f6e511eec 2024-10-15)
binary: rustc
commit-hash: f6e511eec7342f59a25f7c0534f1dbea00d01b14
commit-date: 2024-10-15
host: x86_64-unknown-linux-gnu
release: 1.82.0
LLVM version: 19.1.1

Bug is also reproducible on nightly:

owner@DESKTOP-G91GA1P:~/bug$ rustc +nightly --version --verbose
rustc 1.83.0-nightly (c52c23b6f 2024-09-16)
binary: rustc
commit-hash: c52c23b6f44cd19718721a5e3b2eeb169e9c96ff
commit-date: 2024-09-16
host: x86_64-unknown-linux-gnu
release: 1.83.0-nightly
LLVM version: 19.1.0

Error output

owner@DESKTOP-G91GA1P:~/bug$ cargo build
   Compiling bug v0.1.0 (/home/owner/bug)
error: rustc interrupted by SIGSEGV, printing backtrace

/home/owner/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-2d2db9d3929202cf.so(+0x33b6d83)[0x7fa17e9b6d83]
/lib/x86_64-linux-gnu/libc.so.6(+0x42520)[0x7fa17b419520]
/home/owner/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-2d2db9d3929202cf.so(+0x4ad1400)[0x7fa1800d1400]

### cycle encountered after 3 frames with period 4
/home/owner/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-2d2db9d3929202cf.so(+0x4ad14fd)[0x7fa1800d14fd]
/home/owner/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-2d2db9d3929202cf.so(+0x4ad14fd)[0x7fa1800d14fd]
/home/owner/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-2d2db9d3929202cf.so(+0x4ad14fd)[0x7fa1800d14fd]
/home/owner/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-2d2db9d3929202cf.so(+0x4ad14fd)[0x7fa1800d14fd]
### recursed 61 times

/home/owner/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-2d2db9d3929202cf.so(+0x54206bd)[0x7fa180a206bd]
/home/owner/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-2d2db9d3929202cf.so(+0x54206bd)[0x7fa180a206bd]
/home/owner/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-2d2db9d3929202cf.so(+0x54206bd)[0x7fa180a206bd]
/home/owner/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-2d2db9d3929202cf.so(+0x54206bd)[0x7fa180a206bd]
/home/owner/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-2d2db9d3929202cf.so(+0x54206bd)[0x7fa180a206bd]
/home/owner/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-2d2db9d3929202cf.so(+0x54206bd)[0x7fa180a206bd]
/home/owner/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-2d2db9d3929202cf.so(+0x54206bd)[0x7fa180a206bd]
/home/owner/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-2d2db9d3929202cf.so(+0x54206bd)[0x7fa180a206bd]
/home/owner/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-2d2db9d3929202cf.so(+0x54206bd)[0x7fa180a206bd]

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
help: you can increase rustc's stack size by setting RUST_MIN_STACK=16777216
note: backtrace dumped due to SIGSEGV! resuming signal
error: could not compile `bug` (bin "bug")

Caused by:
  process didn't exit successfully: `/home/owner/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/rustc --crate-name bug --edition=2021 src/main.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --diagnostic-width=155 --crate-type bin --emit=dep-info,link -C embed-bitcode=no -C debuginfo=2 --check-cfg 'cfg(docsrs)' --check-cfg 'cfg(feature, values())' -C metadata=2a965e89fdd8eba6 -C extra-filename=-2a965e89fdd8eba6 --out-dir /home/owner/bug/target/debug/deps -C incremental=/home/owner/bug/target/debug/incremental -L dependency=/home/owner/bug/target/debug/deps` (signal: 11, SIGSEGV: invalid memory reference)
Backtrace

owner@DESKTOP-G91GA1P:~/bug$ RUST_BACKTRACE=1 cargo build
   Compiling bug v0.1.0 (/home/owner/bug)
error: rustc interrupted by SIGSEGV, printing backtrace

/home/owner/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-2d2db9d3929202cf.so(+0x33b6d83)[0x7f4c72fb6d83]
/lib/x86_64-linux-gnu/libc.so.6(+0x42520)[0x7f4c6fa19520]
/home/owner/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-2d2db9d3929202cf.so(+0x4ad1400)[0x7f4c746d1400]

### cycle encountered after 3 frames with period 4
/home/owner/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-2d2db9d3929202cf.so(+0x4ad14fd)[0x7f4c746d14fd]
/home/owner/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-2d2db9d3929202cf.so(+0x4ad14fd)[0x7f4c746d14fd]
/home/owner/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-2d2db9d3929202cf.so(+0x4ad14fd)[0x7f4c746d14fd]
/home/owner/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-2d2db9d3929202cf.so(+0x4ad14fd)[0x7f4c746d14fd]
### recursed 61 times

/home/owner/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-2d2db9d3929202cf.so(+0x54206bd)[0x7f4c750206bd]
/home/owner/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-2d2db9d3929202cf.so(+0x54206bd)[0x7f4c750206bd]
/home/owner/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-2d2db9d3929202cf.so(+0x54206bd)[0x7f4c750206bd]
/home/owner/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-2d2db9d3929202cf.so(+0x54206bd)[0x7f4c750206bd]
/home/owner/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-2d2db9d3929202cf.so(+0x54206bd)[0x7f4c750206bd]
/home/owner/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-2d2db9d3929202cf.so(+0x54206bd)[0x7f4c750206bd]
/home/owner/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-2d2db9d3929202cf.so(+0x54206bd)[0x7f4c750206bd]
/home/owner/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-2d2db9d3929202cf.so(+0x54206bd)[0x7f4c750206bd]
/home/owner/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-2d2db9d3929202cf.so(+0x54206bd)[0x7f4c750206bd]

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
help: you can increase rustc's stack size by setting RUST_MIN_STACK=16777216
note: backtrace dumped due to SIGSEGV! resuming signal
error: could not compile `bug` (bin "bug")

Caused by:
  process didn't exit successfully: `/home/owner/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/rustc --crate-name bug --edition=2021 src/main.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --diagnostic-width=155 --crate-type bin --emit=dep-info,link -C embed-bitcode=no -C debuginfo=2 --check-cfg 'cfg(docsrs)' --check-cfg 'cfg(feature, values())' -C metadata=2a965e89fdd8eba6 -C extra-filename=-2a965e89fdd8eba6 --out-dir /home/owner/bug/target/debug/deps -C incremental=/home/owner/bug/target/debug/incremental -L dependency=/home/owner/bug/target/debug/deps` (signal: 11, SIGSEGV: invalid memory reference)

If this bug is stupid then I'm sorry for wasting your time. Many thanks for your work!

@psprojectC psprojectC 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 Jan 15, 2025
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jan 15, 2025
@workingjubilee
Copy link
Member

well, how many ampersands was it?

@workingjubilee
Copy link
Member

ah, 4770

@workingjubilee workingjubilee 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) ❄️ labels Jan 15, 2025
@workingjubilee
Copy link
Member

workingjubilee commented Jan 15, 2025

Hm. If I delete enough &s (leaving "only" about 3800) I get this:

error: rustc interrupted by SIGSEGV, printing backtrace

/playground/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-7bea7fca18409d2b.so(+0x3634d23)[0x7a6ccb434d23]
/lib/x86_64-linux-gnu/libc.so.6(+0x45320)[0x7a6ccf04d320]
/playground/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-7bea7fca18409d2b.so(+0x4d81214)[0x7a6cccb81214]

### cycle encountered after 3 frames with period 4
/playground/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-7bea7fca18409d2b.so(_RNvXs_NtNtNtCsjMhp1yRiiv2_11rustc_infer5infer6relate13type_relatingNtB4_12TypeRelatingINtNtCsb6W7wrEpiwi_13rustc_type_ir6relate12TypeRelationNtNtNtCs8gpmYOs1YsA_12rustc_middle2ty7context6TyCtxtE3tys+0x2e7)[0x7a6cccb7e9b7]
/playground/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-7bea7fca18409d2b.so(+0x4d81de5)[0x7a6cccb81de5]
/playground/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-7bea7fca18409d2b.so(_RNvXs_NtNtNtCsjMhp1yRiiv2_11rustc_infer5infer6relate13type_relatingNtB4_12TypeRelatingINtNtCsb6W7wrEpiwi_13rustc_type_ir6relate12TypeRelationNtNtNtCs8gpmYOs1YsA_12rustc_middle2ty7context6TyCtxtE3tys+0x2e7)[0x7a6cccb7e9b7]
/playground/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-7bea7fca18409d2b.so(+0x4d81de5)[0x7a6cccb81de5]
### recursed 63 times

/playground/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-7bea7fca18409d2b.so(_RNvXs_NtNtNtCsjMhp1yRiiv2_11rustc_infer5infer6relate13type_relatingNtB4_12TypeRelatingINtNtCsb6W7wrEpiwi_13rustc_type_ir6relate12TypeRelationNtNtNtCs8gpmYOs1YsA_12rustc_middle2ty7context6TyCtxtE3tys+0x2e7)[0x7a6cccb7e9b7]

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
help: you can increase rustc's stack size by setting RUST_MIN_STACK=16777216

So even if I fixed the stack overflow here, I'd hit another stack overflow.

That or the overflow is already in inference.

@matthiaskrgr
Copy link
Member

this is probably a duplicate of #121808

@jieyouxu jieyouxu removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jan 16, 2025
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. 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

5 participants