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 stack overflow #38408

Closed
ConnyOnny opened this issue Dec 16, 2016 · 4 comments
Closed

rustc stack overflow #38408

ConnyOnny opened this issue Dec 16, 2016 · 4 comments
Labels
A-MIR Area: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.html T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@ConnyOnny
Copy link
Contributor

ConnyOnny commented Dec 16, 2016

This code makes the current stable and nightly rustc overflow its stack:

assert_eq!(0,-(i32::max_value()));

It seems to be a combination of the macro invocation, the negation and the fact that i32::max_value is a somewhat special function. If I replace any of the three, compilation works fine (i.e. no assertion => works; no negation => works, get i32::max_value with an indirection to another function => works).

Exact code to reproduce ("lib.rs"):

fn foo() {
    assert_eq!(0,-(i32::max_value()));
}

Exact command prompt:

/tmp/blub$ rustup run nightly cargo build --verbose
   Compiling blub v0.1.0 (file:///tmp/blub)
     Running `rustc --crate-name blub src/lib.rs --crate-type lib -g -C metadata=9ae2a3c37cd740a3 -C extra-filename=-9ae2a3c37cd740a3 --out-dir /tmp/blub/target/debug/deps --emit=dep-info,link -L dependency=/tmp/blub/target/debug/deps`

thread 'rustc' has overflowed its stack
fatal runtime error: stack overflow
error: Could not compile `blub`.

Caused by:
  process didn't exit successfully: `rustc --crate-name blub src/lib.rs --crate-type lib -g -C metadata=9ae2a3c37cd740a3 -C extra-filename=-9ae2a3c37cd740a3 --out-dir /tmp/blub/target/debug/deps --emit=dep-info,link -L dependency=/tmp/blub/target/debug/deps` (exit code: 1)

EDIT: Oh and my platform is Ubuntu AMD64.

EDIT2:

$ rustup run nightly rustc --version --verbose
rustc 1.15.0-nightly (daf8c1dfc 2016-12-05)
binary: rustc
commit-hash: daf8c1dfce3b448fc581cc319f64632ec22bd0e1
commit-date: 2016-12-05
host: x86_64-unknown-linux-gnu
release: 1.15.0-nightly
LLVM version: 3.9

But as I said, it also works on stable.

@nagisa
Copy link
Member

nagisa commented Dec 16, 2016

Likely a duplicate of #37991.

@nikomatsakis nikomatsakis added P-high High priority T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. A-MIR Area: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.html and removed P-high High priority labels Dec 22, 2016
@nikomatsakis
Copy link
Contributor

@eddyb also thinks a likely duplicate.

@ghost
Copy link

ghost commented Feb 7, 2017

@arielb1 Is this fixed now, can we close this issue?

@ConnyOnny
Copy link
Contributor Author

yup (tested with stable 1.15 and nightly c49d102 2017-02-07)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-MIR Area: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.html 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

3 participants