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

Using -C codegen_units=N while bootstrapping rust generates an LLVM assertion #19826

Closed
japaric opened this issue Dec 14, 2014 · 7 comments
Closed
Assignees
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@japaric
Copy link
Member

japaric commented Dec 14, 2014

STR

$ git clone https://github.com/rust-lang/rust
$ cd rust
$ mkdir build
$ cd build
$ ../configure
$ RUSTFLAGS=-Ccodegen_units=2 make
rustc: x86_64-unknown-linux-gnu/stage0/lib/rustlib/x86_64-unknown-linux-gnu/lib/liblibc
rustc: x86_64-unknown-linux-gnu/stage0/lib/rustlib/x86_64-unknown-linux-gnu/lib/librand
rustc: x86_64-unknown-linux-gnu/stage0/lib/rustlib/x86_64-unknown-linux-gnu/lib/libunicode
rustc: x86_64-unknown-linux-gnu/stage0/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc
rustc: /home/rustbuild/src/rust-buildbot/slave/snap3-linux/build/src/llvm/lib/IR/Constants.cpp:1609: static llvm::Constant* llvm::ConstantExpr::getPointerCast(llvm::Constant*, llvm::Type*): Assertion `S->getType()->isPtrOrPtrVectorTy() && "Invalid cast"' failed.
Aborted (core dumped)

Version

444fa1b


Sadly, I couldn't generate a minimal script that reproduces the problem. But these seem to be the required ingredients:

  • Cross crate. The linked crate must use unboxed closures.
  • There must be some #[inline]d function in the root crate.
  • And, of course, the -C codegen_units flag.

cc @nikomatsakis @nick29581

@bkoropoff
Copy link
Contributor

I can reproduce this. Backtrace:

#0  0x00007f7760346877 in raise () from /lib64/libc.so.6
#1  0x00007f7760347f68 in abort () from /lib64/libc.so.6
#2  0x00007f776033f7d6 in __assert_fail_base () from /lib64/libc.so.6
#3  0x00007f776033f882 in __assert_fail () from /lib64/libc.so.6
#4  0x00007f7762a4d40b in llvm::ConstantExpr::getPointerCast(llvm::Constant*, llvm::Type*) ()
#5  0x00007f77629e97f5 in LLVMBuildPointerCast ()
#6  0x00007f7761b489f5 in trans::callee::trans_arg_datum::h03f85d308ba46cd1Oxh ()
#7  0x00007f7761b42988 in trans::callee::trans_args::h87945a0a00d776c99oh ()
#8  0x00007f7761b0aa5d in trans::callee::trans_call_inner::h3407dfe88b63d12913g ()
#9  0x00007f7761b4b8ef in trans::expr::trans_rvalue_dps_unadjusted::h9838b52bc02d24d9cgj ()
#10 0x00007f7761b020f8 in trans::expr::trans_into::h3e5c3cd16b2b4e12WMh ()
#11 0x00007f7761b02df4 in trans::controlflow::trans_block::hf81d152713271e77FYd ()
#12 0x00007f7761bb442f in trans::base::trans_closure::hd73aafc90fa3ac9cVfu ()
#13 0x00007f7761af54ce in trans::base::trans_fn::h8314c0146f176259cru ()
#14 0x00007f7761af7447 in trans::monomorphize::monomorphic_fn::ha2624864fe6af428Yqd ()
#15 0x00007f7761b2d402 in trans::callee::trans_fn_ref_with_substs::h15cf4988c4a3d900dIg ()
#16 0x00007f7761b0df29 in trans::meth::trans_method_callee::h2987066aa8871c6bwGz ()
#17 0x00007f7761b3a14e in trans::callee::trans_method_call::closure.38397 ()
#18 0x00007f7761b0957f in trans::callee::trans_call_inner::h3407dfe88b63d12913g ()
#19 0x00007f7761b4b8ef in trans::expr::trans_rvalue_dps_unadjusted::h9838b52bc02d24d9cgj ()
#20 0x00007f7761b020f8 in trans::expr::trans_into::h3e5c3cd16b2b4e12WMh ()
#21 0x00007f7761b02df4 in trans::controlflow::trans_block::hf81d152713271e77FYd ()
#22 0x00007f7761bb442f in trans::base::trans_closure::hd73aafc90fa3ac9cVfu ()
#23 0x00007f7761af54ce in trans::base::trans_fn::h8314c0146f176259cru ()
#24 0x00007f7761af1007 in trans::base::trans_item::hdac7426481f8746aeMu ()
#25 0x00007f7761bb5c49 in trans::base::trans_mod::h03145c37fc751d9cJRu ()
#26 0x00007f7761af0e7f in trans::base::trans_item::hdac7426481f8746aeMu ()
#27 0x00007f7761bb5c49 in trans::base::trans_mod::h03145c37fc751d9cJRu ()
#28 0x00007f7761bbad07 in trans::base::trans_crate::hff0a239bca25518eoIv ()
#29 0x00007f77615dd75d in driver::phase_4_translate_to_llvm::h1d8e5fa121da5744BCa ()
#30 0x00007f77615c4b98 in driver::compile_input::h99875561ae679834pba ()
#31 0x00007f776165fd38 in run_compiler::h68c8d9fcc09b1d69kYb ()
#32 0x00007f776165e62c in run::closure.21400 ()
#33 0x00007f776166ff3b in task::TaskBuilder::try_future::closure.22849 ()
#34 0x00007f776321d8f3 in task::TaskBuilder::spawn_internal::closure.30601 ()
#35 0x00007f7763238732 in task::Task::spawn::closure.5727 ()
#36 0x00007f776323ae9c in rust_try_inner ()
#37 0x00007f776323ae86 in rust_try ()
#38 0x00007f77632387d3 in unwind::try::h67138f1a9143bb4fTyc ()
#39 0x00007f77632385dc in task::Task::run::hd7a7ebf54ed491e4fKb ()
#40 0x00007f7763238228 in task::Task::spawn::closure.5703 ()
#41 0x00007f7763239655 in thread::thread_start::h69086febf2f5cecdw1b ()
#42 0x00007f7760fffee5 in start_thread () from /lib64/libpthread.so.0
#43 0x00007f7760405b8d in clone () from /lib64/libc.so.6

@jdm jdm added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Dec 14, 2014
@nrc
Copy link
Member

nrc commented Dec 15, 2014

We're hitting this on builds of rustc now, that makes me very, very sad.

@nikomatsakis is this the same bug you were hitting earlier? Did you get much of a handle on it?

@epdtry If you have any spare cycles over the Christmas break, we would appreciate a fix :-)

@japaric
Copy link
Member Author

japaric commented Dec 19, 2014

Managed to get a reduced test case (~100 lines). Check this gist for details.

@tomjakubowski
Copy link
Contributor

Here's an updated gist that ICEs on rustc 1.0.0-dev (ea6f65c5f 2015-01-06 19:47:08 +0000):

https://gist.github.com/tomjakubowski/9c49af9cd2582c37d0e8/a056ead1b0ba5bd29fae8b709fc031ebdc49e4fd

@Aatch Aatch self-assigned this Jan 15, 2015
@Aatch
Copy link
Contributor

Aatch commented Jan 15, 2015

To people from the future, I'm going to add notes of my investigation here.

It looks like we're getting some oddness with types appearing to be different when using multiple codegen units. Specifically, Rust is trying to cast an unboxed closure to an identical-looking unboxed closure.

@ghost
Copy link

ghost commented Jan 18, 2015

Don't know how related, but the same error comes with this, too (on linux and with no flags to rustc):

fn main() {
    let a: [u8; 2] = [97, 98];
    //if &a[0..2] == b"ab" {    // works
    if a[0..2] == *b"ab" {    // ICE
        println!("test");
    }
}

(rustc 1.0.0-nightly (f4f10db 2015-01-17 20:31:08 +0000))

@tamird
Copy link
Contributor

tamird commented Apr 21, 2015

Triage:

@lgvz's code no longer produces an error.

@tomjakubowski/@japaric's gist no longer compiles.

@nrc nrc self-assigned this May 26, 2015
bors added a commit that referenced this issue Jun 8, 2015
Closes #19826

r? @nikomatsakis 

There is still some work to do until parallel codegen is perfect - we don't pass make check due to missing the symbol for registering a macro. But we do bootstrap with codegen_units=4 and pass make check without codegen_units, so I think it should land.

For the curious, make rustc-stage2 -j8:

```
codegen_units=1:

real  9m18.074s
user  11m59.858s
sys 0m13.281s


codegen_units=4:

real  6m3.672s
user  13m5.474s
sys 0m12.146s
```

Which is a 33% speedup :-)
bors added a commit that referenced this issue Jun 8, 2015
Closes #19826

r? @nikomatsakis 

There is still some work to do until parallel codegen is perfect - we don't pass make check due to missing the symbol for registering a macro. But we do bootstrap with codegen_units=4 and pass make check without codegen_units, so I think it should land.

For the curious, make rustc-stage2 -j8:

```
codegen_units=1:

real  9m18.074s
user  11m59.858s
sys 0m13.281s


codegen_units=4:

real  6m3.672s
user  13m5.474s
sys 0m12.146s
```

Which is a 33% speedup :-)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

No branches or pull requests

7 participants