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

LLVM assertion returning ref pattern inside newtype #19593

Closed
nwin opened this issue Dec 6, 2014 · 3 comments
Closed

LLVM assertion returning ref pattern inside newtype #19593

nwin opened this issue Dec 6, 2014 · 3 comments
Labels
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) ❄️

Comments

@nwin
Copy link
Contributor

nwin commented Dec 6, 2014

The following code

struct Struct([u8]);


fn as_slice(s: &Struct) -> &[u8] {
    let &Struct(ref this) = s;
    this
} 

fn main() { }

fails to compile, the error message is:

Assertion failed: (Ty && "Invalid GetElementPtrInst indices for type!"), function checkGEPType, file /Users/rustbuild/src/rust-buildbot/slave/nightly-mac/build/src/llvm/include/llvm/IR/Instructions.h, line 782.
Abort trap: 6
@kmcallister kmcallister added 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 Jan 18, 2015
@kmcallister
Copy link
Contributor

Still get an LLVM assertion on rustc 1.0.0-dev (896cb36 2015-01-14 12:19:58 +0000):

rustc: /home/keegan/rust-master/src/llvm/include/llvm/Support/Casting.h:237: typename llvm::cast_retty<X, Y*>::ret_type llvm::cast(Y*) [with X = llvm::PointerType; Y = const llvm::Type; typename llvm::cast_retty<X, Y*>::ret_type = const llvm::PointerType*]: Assertion `isa<X>(Val) && "cast<Ty>() argument of incompatible type!"' failed.

@kmcallister kmcallister changed the title Assertion error in llvm backend LLVM assertion returning ref pattern inside newtype Jan 18, 2015
@cuviper
Copy link
Member

cuviper commented Mar 23, 2015

Still aborts on rustc 1.0.0-nightly (b0aad7d 2015-03-22) (built 2015-03-23):

$ RUST_BACKTRACE=1 rustc pr19593.rs
pr19593.rs:1:1: 1:21 warning: struct is never used: `Struct`, #[warn(dead_code)] on by default
pr19593.rs:1 struct Struct([u8]);
             ^~~~~~~~~~~~~~~~~~~~
pr19593.rs:4:1: 7:2 warning: function is never used: `as_slice`, #[warn(dead_code)] on by default
pr19593.rs:4 fn as_slice(s: &Struct) -> &[u8] {
pr19593.rs:5     let &Struct(ref this) = s;
pr19593.rs:6     this
pr19593.rs:7 } 
rustc: /home/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/llvm/include/llvm/Support/Casting.h:237: typename llvm::cast_retty<X, Y*>::ret_type llvm::cast(Y*) [with X = llvm::PointerType; Y = const llvm::Type; typename llvm::cast_retty<X, Y*>::ret_type = const llvm::PointerType*]: Assertion `isa<X>(Val) && "cast<Ty>() argument of incompatible type!"' failed.

Info from coredumpctl:

Stack trace of thread 21279:
#0  0x00007fa9e09548d7 __GI_raise (libc.so.6)
#1  0x00007fa9e095653a __GI_abort (libc.so.6)
#2  0x00007fa9e094d47d __assert_fail_base (libc.so.6)
#3  0x00007fa9e094d532 __GI___assert_fail (libc.so.6)
#4  0x00007fa9dcba214c _ZN4llvm4castINS_11PointerTypeEKNS_4TypeEEENS_10cast_rettyIT_PT0_E8ret_typeES7_.part.121 (librustc_llvm-4e7c5e5c.so)
#5  0x00007fa9dcba2911 _ZNK4llvm4Type22getPointerAddressSpaceEv (librustc_llvm-4e7c5e5c.so)
#6  0x00007fa9dba34a1b _ZN4llvm17GetElementPtrInst16getGEPReturnTypeEPNS_5ValueENS_8ArrayRefIS2_EE (librustc_llvm-4e7c5e5c.so)
#7  0x00007fa9dba34ade _ZN4llvm17GetElementPtrInstC2EPNS_5ValueENS_8ArrayRefIS2_EEjRKNS_5TwineEPNS_11InstructionE (librustc_llvm-4e7c5e5c.so)
#8  0x00007fa9dba36c8f _ZN4llvm9IRBuilderILb1ENS_14ConstantFolderENS_24IRBuilderDefaultInserterILb1EEEE17CreateInBoundsGEPEPNS_5ValueENS_8ArrayRefIS6_EERKNS_5TwineE (librustc_llvm-4e7c5e5c.so)
#9  0x00007fa9dcab92ec LLVMBuildInBoundsGEP (librustc_llvm-4e7c5e5c.so)
#10 0x00007fa9e04c3926 _ZN5trans5build4GEPi20hc71b126e77a04cc55jpE (librustc_trans-4e7c5e5c.so)
#11 0x00007fa9e04d366c _ZN5trans3adt15trans_field_ptr20h2c44062b2fcc6ce2FPHE (librustc_trans-4e7c5e5c.so)
#12 0x00007fa9e05b07ff _ZN5trans6_match20bind_irrefutable_pat20ha0879b0a078c12b9uHwE (librustc_trans-4e7c5e5c.so)
#13 0x00007fa9e05b0545 _ZN5trans6_match20bind_irrefutable_pat20ha0879b0a078c12b9uHwE (librustc_trans-4e7c5e5c.so)
#14 0x00007fa9e04b17b5 _ZN5trans4base10init_local20h96ebc929e2d1c887ljsE (librustc_trans-4e7c5e5c.so)
#15 0x00007fa9e04b2df3 _ZN5trans11controlflow11trans_block20h5e8ab5bfa7f25c74R5dE (librustc_trans-4e7c5e5c.so)
#16 0x00007fa9e05786a9 _ZN5trans4base13trans_closure20heebe9acc13fc14ffh4sE (librustc_trans-4e7c5e5c.so)
#17 0x00007fa9e049ccb9 _ZN5trans4base8trans_fn20h62bbdc2e4afebf2baftE (librustc_trans-4e7c5e5c.so)
#18 0x00007fa9e0497eb0 _ZN5trans4base10trans_item20h2d3492d7aac778f52CtE (librustc_trans-4e7c5e5c.so)
#19 0x00007fa9e0580563 _ZN5trans4base11trans_crate20h108b0034c5a4b22bwzuE (librustc_trans-4e7c5e5c.so)
#20 0x00007fa9e14a7df4 _ZN6driver25phase_4_translate_to_llvm20hf17d08192b3ac5damOaE (librustc_driver-4e7c5e5c.so)
#21 0x00007fa9e14830d4 _ZN6driver13compile_input20h1bce257423e85508RbaE (librustc_driver-4e7c5e5c.so)
#22 0x00007fa9e153a963 _ZN12run_compiler20hfa1f33f48bbd87bfv2bE (librustc_driver-4e7c5e5c.so)
#23 0x00007fa9e1538734 _ZN5thunk26F.Invoke$LT$A$C$$u20$R$GT$6invoke21h13820398192623214751E (librustc_driver-4e7c5e5c.so)
#24 0x00007fa9e1537bca _ZN2rt6unwind3try6try_fn20h6363273809121808659E (librustc_driver-4e7c5e5c.so)
#25 0x00007fa9e0eed359 rust_try_inner (libstd-4e7c5e5c.so)
#26 0x00007fa9e0eed346 rust_try (libstd-4e7c5e5c.so)
#27 0x00007fa9e1537eed _ZN5thunk26F.Invoke$LT$A$C$$u20$R$GT$6invoke20h7786282715581345346E (librustc_driver-4e7c5e5c.so)
#28 0x00007fa9e0e63b19 _ZN3sys6thread6create12thread_start20h05349c15f3b249d8oUHE (libstd-4e7c5e5c.so)
#29 0x00007fa9dad3b52a start_thread (libpthread.so.0)
#30 0x00007fa9e0a2022d __clone (libc.so.6)

Stack trace of thread 21277:
#0  0x00007fa9dad3c5e5 pthread_join (libpthread.so.0)
#1  0x00007fa9e0e3fef3 _ZN6thread10JoinHandle4join20h8b3b5dfc3089534c7mwE (libstd-4e7c5e5c.so)
#2  0x00007fa9e15367ad _ZN3run20h063ba822e25c126bb2bE (librustc_driver-4e7c5e5c.so)
#3  0x00007fa9e154ac6c _ZN4main20h01390c9895ee9e70k9cE (librustc_driver-4e7c5e5c.so)
#4  0x00007fa9e0eed359 rust_try_inner (libstd-4e7c5e5c.so)
#5  0x00007fa9e0eed346 rust_try (libstd-4e7c5e5c.so)
#6  0x00007fa9e0e792ac _ZN2rt10lang_start20h9704c9322344f817UdJE (libstd-4e7c5e5c.so)
#7  0x00007fa9e093ffe0 __libc_start_main (libc.so.6)
#8  0x00007fa9e19a8749 _start (rustc)

@ghost
Copy link

ghost commented Apr 16, 2015

Closing as a duplicate of #19064.

@ghost ghost closed this as completed Apr 16, 2015
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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) ❄️
Projects
None yet
Development

No branches or pull requests

3 participants