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 in LLVM innards when calling an extern fn with a slice #25581

Closed
geofft opened this issue May 18, 2015 · 1 comment · Fixed by #25653
Closed

ICE in LLVM innards when calling an extern fn with a slice #25581

geofft opened this issue May 18, 2015 · 1 comment · Fixed by #25653
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@geofft
Copy link
Contributor

geofft commented May 18, 2015

I found an ICE in nightly on playpen:

extern {
    fn f(t: &[i32]);
}

fn main() {
    unsafe {
        f(&[0i32]);
    }
}
rustc: /home/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/llvm/lib/IR/Instructions.cpp:1083: void llvm::StoreInst::AssertOK(): Assertion `getOperand(0)->getType() == cast<PointerType>(getOperand(1)->getType())->getElementType() && "Ptr must be a pointer to Val type!"' failed.
Aborted (core dumped)
playpen: application terminated with error code 134

You get a slightly different error on 1.0 stable:

Stored value type does not match pointer operand type!
  store { i32*, i64 }* %arg, [1 x i32]** %__arg
 [1 x i32]*Call parameter type does not match function signature!
  %1 = load [1 x i32]** %__arg
 { i64, i64 }  call void @f([1 x i32]* %1)
LLVM ERROR: Broken function found, compilation aborted!
playpen: application terminated with error code 1

(There's a variant of this using a function taking an extern fn, instead of an extern block, to avoid the unsafe.)

If it helps, I got here by tracking down the claim in the x86-64 SysV ABI (pdf, page 19) that if you have a struct with two 8-byte elements, it gets passed as if you just had two separate 8-byte parameters (i.e., in two registers), instead of being passed on the stack as structs usually are. I'm not quite sure if this is related, but the errors imply there might be some confusion here.

I realize that passing Rust-specific objects like slices using the extern "C" ABI isn't very meaningful, but I figured you might want the ICE report anyway.

@steveklabnik steveklabnik added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label May 18, 2015
dotdash added a commit to dotdash/rust that referenced this issue May 20, 2015
dotdash added a commit to dotdash/rust that referenced this issue May 21, 2015
Manishearth added a commit to Manishearth/rust that referenced this issue May 22, 2015
oli-obk pushed a commit to oli-obk/rust that referenced this issue May 23, 2015
bors added a commit that referenced this issue May 23, 2015
@tshepang
Copy link
Member

such a nice report @geofft

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

Successfully merging a pull request may close this issue.

3 participants