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

ICE: Assertion failed: DestTy && "GEP indices invalid!" compiling reference to static defined in another crate #29265

Closed
briansmith opened this issue Oct 24, 2015 · 4 comments · Fixed by #63259
Labels
C-bug Category: This is a bug. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added.

Comments

@briansmith
Copy link
Contributor

Program:

extern crate test_1_lib;

static _UNUSED: &'static test_1_lib::SomeType = &test_1_lib::SOME_VALUE;

fn main() {
    vec![0u8; test_1_lib::SOME_VALUE.some_member];
}

Crate test_1_lib:

pub struct SomeType {
    pub some_member: usize,
}

pub static SOME_VALUE: SomeType = SomeType {
    some_member: 1,
};

Notice that this is a static in one crate referencing a static in another crate.

A complete cargo-buildable test case is at https://github.com/briansmith/rust-bug-1. This bug was found by a user of ring. The coding pattern in this test case commonly occurs when using ring.

To reproduce:

git clone https://github.com/briansmith/rust-bug-1
cd bin
cargo build

rustc crashes with

Assertion failed: DestTy && "GEP indices invalid!", file C:\bot\slave\nightly-dist-rustc-win-msvc-64\build\src\llvm\

Reproduced with (on x86_64-pc-windows-msvc):

  • rustc 1.3.0 (9a92aaf 2015-09-15) / cargo 0.4.0-nightly (553b363 2015-08-03) (built 2015-08-03)
  • rustc 1.4.0-nightly (fd302a9 2015-08-27) / cargo 0.5.0-nightly (53e51d5 2015-08-26)
  • rustc 1.5.0-nightly (7beebbe 2015-10-22) / cargo 0.6.0-nightly (e1ed995 2015-10-22)
@huonw huonw added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Oct 24, 2015
@briansmith
Copy link
Contributor Author

A complete cargo-buildable test case is at https://github.com/briansmith/rust-bug-1. This bug was found by a user of ring.

In particular, this was found by @badboy, who originally reported it as briansmith/ring#41.

@alexcrichton alexcrichton added the A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. label Oct 24, 2015
@bltavares
Copy link
Contributor

Triaging:

There is an error hapening on rustc 1.7.0 (a5d1e7a59 2016-02-29), but it is not the Assertion on GEP indices anymore.

$ cargo build --verbose

   Compiling test_1_lib v0.1.0 (file:///private/tmp/rust-bug-1/bin)
     Running `rustc /private/tmp/rust-bug-1/lib/src/lib.rs --crate-name test_1_lib --crate-type lib -g -C metadata=50d0c76dcbac1234 -C extra-filename=-50d0c76dcbac1234 --out-dir /private/tmp/rust-bug-1/bin/target/debug/deps --emit=dep-info,link -L dependency=/private/tmp/rust-bug-1/bin/target/debug/deps -L dependency=/private/tmp/rust-bug-1/bin/target/debug/deps`
   Compiling test_1_bin v0.1.0 (file:///private/tmp/rust-bug-1/bin)
     Running `rustc src/test_1_bin.rs --crate-name test_1_bin --crate-type bin -g --out-dir /private/tmp/rust-bug-1/bin/target/debug --emit=dep-info,link -L dependency=/private/tmp/rust-bug-1/bin/target/debug -L dependency=/private/tmp/rust-bug-1/bin/target/debug/deps --extern test_1_lib=/private/tmp/rust-bug-1/bin/target/debug/deps/libtest_1_lib-50d0c76dcbac1234.rlib`
Could not compile `test_1_bin`.

Caused by:
  Process didn't exit successfully: `rustc src/test_1_bin.rs --crate-name test_1_bin --crate-type bin -g --out-dir /private/tmp/rust-bug-1/bin/target/debug --emit=dep-info,link -L dependency=/private/tmp/rust-bug-1/bin/target/debug -L dependency=/private/tmp/rust-bug-1/bin/target/debug/deps --extern test_1_lib=/private/tmp/rust-bug-1/bin/target/debug/deps/libtest_1_lib-50d0c76dcbac1234.rlib` (signal: 11)

On nightly rustc 1.9.0-nightly (98f0a9128 2016-03-23) the example compiles without errors.

$ multirust run nightly cargo build --verbose

multirust: checking metadata version
multirust: got metadata version 2
   Compiling test_1_lib v0.1.0 (file:///private/tmp/rust-bug-1/lib)
     Running `rustc /private/tmp/rust-bug-1/lib/src/lib.rs --crate-name test_1_lib --crate-type lib -g -C metadata=fc60932e754a9e26 -C extra-filename=-fc60932e754a9e26 --out-dir /private/tmp/rust-bug-1/bin/target/debug/deps --emit=dep-info,link -L dependency=/private/tmp/rust-bug-1/bin/target/debug/deps -L dependency=/private/tmp/rust-bug-1/bin/target/debug/deps`
   Compiling test_1_bin v0.1.0 (file:///private/tmp/rust-bug-1/bin)
     Running `rustc src/test_1_bin.rs --crate-name test_1_bin --crate-type bin -g --out-dir /private/tmp/rust-bug-1/bin/target/debug --emit=dep-info,link -L dependency=/private/tmp/rust-bug-1/bin/target/debug -L dependency=/private/tmp/rust-bug-1/bin/target/debug/deps --extern test_1_lib=/private/tmp/rust-bug-1/bin/target/debug/deps/libtest_1_lib-fc60932e754a9e26.rlib`

@jonas-schievink
Copy link
Contributor

@bltavares Stable probably still hits the same assert, but LLVM assertions are disabled on stable and beta

@jonas-schievink
Copy link
Contributor

This no longer asserts on the current nightly.

@arielb1 arielb1 added the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label Jun 10, 2016
@Mark-Simulacrum Mark-Simulacrum added the C-bug Category: This is a bug. label Jul 22, 2017
@alexcrichton alexcrichton removed A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ labels Aug 25, 2017
Centril added a commit to Centril/rust that referenced this issue Aug 5, 2019
Centril added a commit to Centril/rust that referenced this issue Aug 6, 2019
Centril added a commit to Centril/rust that referenced this issue Aug 7, 2019
pietroalbini added a commit to pietroalbini/rust that referenced this issue Aug 7, 2019
Centril added a commit to Centril/rust that referenced this issue Aug 8, 2019
Centril added a commit to Centril/rust that referenced this issue Aug 8, 2019
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-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants