Skip to content

rustc stackoverflow (SIGSEGV) #122715

Closed
@womeier

Description

@womeier

I was trying to run rust code extracted from Coq using the https://github.com/AU-COBRA/coq-rust-extraction plugin resulting in this project: binom-extracted.zip
The original program is main in binom.v, some operations on a binomial queue.

It does compile when setting the RUST_MIN_STACK environment var, as suggested in the seemingly related #122357, so feel free to close.

It may be due to a deep nesting of function calls, __nat_succ (the successor constructor of the naive representation of natural numbers in Coq).

fn  __nat_succ(x: u64) -> u64 {
  x.checked_add(1).unwrap()
 }

...
           __nat_succ(
              __nat_succ(
                __nat_succ(
                   ... // like ~2000 more nested calls
                        0))))

I expected to see this happen: successful compilation

Instead, this happened: rustc stackoverflow

Run command

cargo build with this Cargo.toml:

[package]
name = "binom"
version = "0.1.0"
authors = ["Cobra"]
edition = "2018"

[dependencies]
bumpalo = "3.5.0"

[profile.release]
# Tell `rustc` to optimize for small code size.
opt-level = 3

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

Backtrace

error: rustc interrupted by SIGSEGV, printing backtrace

/home/wolfgang/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-ef0b2e016afc8182.so(+0x2c31aa6)[0x7f2380631aa6]
/nix/store/ksk3rnb0ljx8gngzk19jlmbjyvac4hw6-glibc-2.38-44/lib/libc.so.6(+0x3deb0)[0x7f237d703eb0]
/home/wolfgang/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-ef0b2e016afc8182.so(+0x3fbf79f)[0x7f23819bf79f]

### cycle encountered after 3 frames with period 4
/home/wolfgang/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-ef0b2e016afc8182.so(+0x3fbc9c6)[0x7f23819bc9c6]
/home/wolfgang/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-ef0b2e016afc8182.so(_RNvMs0_NtNtCs5wUc2TDgYSc_11rustc_parse6parser4exprNtB7_6Parser21parse_expr_assoc_with+0x79)[0x7f23819b9683]
/home/wolfgang/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-ef0b2e016afc8182.so(+0x3fb5bac)[0x7f23819b5bac]
/home/wolfgang/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-ef0b2e016afc8182.so(+0x3fc08af)[0x7f23819c08af]
### recursed 63 times

/home/wolfgang/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-ef0b2e016afc8182.so(+0x3fbc9c6)[0x7f23819bc9c6]

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
error: could not compile `binom` (bin "binom")

Caused by:
  process didn't exit successfully: `/home/wolfgang/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/rustc --crate-name binom --edition=2018 src/main.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --diagnostic-width=172 --crate-type bin --emit=dep-info,link -C embed-bitcode=no -C debuginfo=2 -C metadata=da589634616a0e94 -C extra-filename=-da589634616a0e94 --out-dir /home/wolfgang/ProjectsUni/Compilerstep/certicoqwasm-rustextraction/benchmarks/rust/binom-extracted/target/debug/deps -C incremental=/home/wolfgang/ProjectsUni/Compilerstep/certicoqwasm-rustextraction/benchmarks/rust/binom-extracted/target/debug/incremental -L dependency=/home/wolfgang/ProjectsUni/Compilerstep/certicoqwasm-rustextraction/benchmarks/rust/binom-extracted/target/debug/deps --extern bumpalo=/home/wolfgang/ProjectsUni/Compilerstep/certicoqwasm-rustextraction/benchmarks/rust/binom-extracted/target/debug/deps/libbumpalo-bea91fa79be86aae.rlib` (signal: 11, SIGSEGV: invalid memory reference)

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-parserArea: The lexing & parsing of Rust source code to an ASTC-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