Skip to content

Illegal instruction building struct that recurses inside boxed array #24732

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
emosenkis opened this issue Apr 23, 2015 · 6 comments
Closed

Illegal instruction building struct that recurses inside boxed array #24732

emosenkis opened this issue Apr 23, 2015 · 6 comments
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@emosenkis
Copy link
Contributor

The following code produces an "Illegal instruction (core dumped)" when run (on linux/x86_64, both in debug and release mode):

fn main() {
    let x = T {f: Box::new([None])};
}

struct T {
    f: Box<[Option<T>; 1]>
}
@nagisa
Copy link
Member

nagisa commented Apr 23, 2015

@emosenkis does “when run” mean you could compile the code successfully?


On rustc with LLVM assertions enabled this ICEs:

rustc: /home/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/llvm/lib/IR/DataLayout.cpp:655: unsigned int llvm::DataLayout::getAlignment(llvm::Type*, bool) const: Assertion `Ty->isSized() && "Cannot getTypeInfo() on a type that is unsized!"' failed.
fish: Job 2, “rustc test.rs ” terminated by signal SIGABRT (Abort)

Backtrace:

#0  0x00007ffff71214b7 in raise () from /usr/lib/libc.so.6
#1  0x00007ffff712288a in abort () from /usr/lib/libc.so.6
#2  0x00007ffff711a41d in __assert_fail_base () from /usr/lib/libc.so.6
#3  0x00007ffff711a4d2 in __assert_fail () from /usr/lib/libc.so.6
#4  0x00007ffff33cbaa0 in llvm::DataLayout::getAlignment(llvm::Type*, bool) const () from /usr/lib/librustc_llvm-4e7c5e5c.so
#5  0x00007ffff3264a9a in LLVMABISizeOfType () from /usr/lib/librustc_llvm-4e7c5e5c.so
#6  0x00007ffff633d3de in trans::type_of::in_memory_type_of::h83e5272cbb0b91f16lL () from /usr/lib/librustc_trans-4e7c5e5c.so
#7  0x00007ffff633d931 in trans::type_of::in_memory_type_of::h83e5272cbb0b91f16lL () from /usr/lib/librustc_trans-4e7c5e5c.so
#8  0x00007ffff633cffc in vec::Vec$LT$T$GT$.FromIterator$LT$T$GT$::from_iter::h8527532148302774489 () from /usr/lib/librustc_trans-4e7c5e5c.so
#9  0x00007ffff633dc11 in trans::type_of::in_memory_type_of::h83e5272cbb0b91f16lL () from /usr/lib/librustc_trans-4e7c5e5c.so
#10 0x00007ffff635465d in trans::base::alloc_ty::h44f852cb49026c27Yah () from /usr/lib/librustc_trans-4e7c5e5c.so
#11 0x00007ffff645d79c in trans::_match::mk_binding_alloca::h7664614637246624964 () from /usr/lib/librustc_trans-4e7c5e5c.so
#12 0x00007ffff63531ff in trans::base::init_local::he80f7b701a7c3086EWg () from /usr/lib/librustc_trans-4e7c5e5c.so
#13 0x00007ffff636368f in trans::controlflow::trans_block::he2b0363ba483aa5723u () from /usr/lib/librustc_trans-4e7c5e5c.so
#14 0x00007ffff6362387 in trans::base::trans_closure::h0dc61076718b152eBDh () from /usr/lib/librustc_trans-4e7c5e5c.so
#15 0x00007ffff6363f8b in trans::base::trans_fn::h017a63e4b4f1d383jOh () from /usr/lib/librustc_trans-4e7c5e5c.so
#16 0x00007ffff6367008 in trans::base::trans_item::h694a5c0c3e92277bvci () from /usr/lib/librustc_trans-4e7c5e5c.so
#17 0x00007ffff63753be in trans::base::trans_crate::h93b35940c9d58579v1i () from /usr/lib/librustc_trans-4e7c5e5c.so
#18 0x00007ffff7af8d5b in driver::phase_4_translate_to_llvm::h0cea9caf6133630enOa () from /usr/lib/librustc_driver-4e7c5e5c.so
#19 0x00007ffff7ad105c in driver::compile_input::h4642f691e22278cbQba () from /usr/lib/librustc_driver-4e7c5e5c.so
#20 0x00007ffff7b91332 in run_compiler::he528ba831532b90aF4b () from /usr/lib/librustc_driver-4e7c5e5c.so
#21 0x00007ffff7b8ef83 in boxed::F.FnBox$LT$A$GT$::call_box::h13568337174014462877 () from /usr/lib/librustc_driver-4e7c5e5c.so
#22 0x00007ffff7b8e4ba in rt::unwind::try::try_fn::h15381261312250239500 () from /usr/lib/librustc_driver-4e7c5e5c.so
#23 0x00007ffff7608529 in rust_try_inner () from /usr/lib/libstd-4e7c5e5c.so
#24 0x00007ffff7608516 in rust_try () from /usr/lib/libstd-4e7c5e5c.so
#25 0x00007ffff7b8e769 in boxed::F.FnBox$LT$A$GT$::call_box::h6713016946069099629 () from /usr/lib/librustc_driver-4e7c5e5c.so
#26 0x00007ffff758fac2 in sys::thread::create::thread_start::hbe89fbdfc755452dxjw () from /usr/lib/libstd-4e7c5e5c.so
#27 0x00007ffff165c374 in start_thread () from /usr/lib/libpthread.so.0
#28 0x00007ffff71d627d in clone () from /usr/lib/libc.so.6

@emosenkis
Copy link
Contributor Author

@nagisa, yes, it builds just fine (rustc 1.0.0-beta.2 (e9080ec 2015-04-16) (built 2015-04-16))

@steveklabnik steveklabnik added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Apr 28, 2015
@WaDelma
Copy link

WaDelma commented May 22, 2015

Just stumbled to this same problem with code:
https://play.rust-lang.org/?gist=a4461127fde85e760fad&version=nightly

@emosenkis
Copy link
Contributor Author

Not sure if it helps any, but @WaDelma's code runs fine on play.rust-lang.org with Stable and Beta now (same error on Nightly) while my code fails with a different error playpen: application terminated abnormally with signal 4 (Illegal instruction) with Stable and Beta (still same error on nightly)

@ldanko
Copy link

ldanko commented Jul 29, 2015

Sorry, reference to 27337 was added accidentially

@arielb1
Copy link
Contributor

arielb1 commented Oct 27, 2015

duplicate of #19001.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

No branches or pull requests

6 participants