Skip to content

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

Closed as duplicate of#121808
@psprojectC

Description

@psprojectC

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.I-crashIssue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions