Skip to content

LLVM assert failure with struct pointers and foreign functions #6504

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

Closed
brandonson opened this issue May 15, 2013 · 5 comments
Closed

LLVM assert failure with struct pointers and foreign functions #6504

brandonson opened this issue May 15, 2013 · 5 comments
Labels
A-codegen Area: Code generation A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. I-crash Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.

Comments

@brandonson
Copy link
Contributor

Say we have a crate file A.rc which includes mod A and mod B, file B is a module that defines an extern function that takes a pointer to a struct, and file C is a module that uses file B using mod B.

I get the following error:

rust/src/llvm/include/llvm/Support/Casting.h:231: typename llvm::enable_if<llvm::is_same<Y, typename llvm::simplify_type<From>::SimpleType>, typename llvm::cast_retty<X, Y*>::ret_type>::type llvm::cast(Y*) [with X = llvm::Function; Y = llvm::Value; typename llvm::enable_if<llvm::is_same<Y, typename llvm::simplify_type<From>::SimpleType>, typename llvm::cast_retty<X, Y*>::ret_type>::type = llvm::Function*]: Assertion `isa<X>(Val) && "cast<Ty>() argument of incompatible type!"' failed.

I managed to bring it down to a simple example that reproduces the problem:

crate.rc

#[crate_type = "lib"];
mod other;
mod other2;

other.rs

struct Foo{
  bar: libc::c_int
}

#[link_args = "-lSDL2"]
extern{
  fn externFunc(param:&Foo) -> libc::c_int;
}

other2.rs

mod other;

Note that this does not happen when the parameters to the extern fn are not pointers to a struct. It also does not happen when compiling just other.rs, or without crate.rc depending on other2.rs.

I'm running ubuntu 13.04 with gcc 4.7.3, and I've had this occur with rust builds from both the master and auto branches, and also with rust 0.6.

@bblum
Copy link
Contributor

bblum commented Aug 7, 2013

Thanks for reporting this. I confirm that it crashes, and that it can't be minimized smaller than 3 files.

Here's a slightly more minimal version of other.rs that reproduces:

struct Foo;

extern{
      fn externFunc(param:&Foo);
}

Nominating well-covered milestone.

MicahChalmer added a commit to MicahChalmer/rust-fuse-mc-original that referenced this issue Aug 27, 2013
MicahChalmer added a commit to MicahChalmer/rust-fuse-mc-original that referenced this issue Aug 27, 2013
@catamorphism
Copy link
Contributor

Accepted for production-ready

@luqmana
Copy link
Member

luqmana commented Oct 11, 2013

I can't seem to reproduce this. @singingboyo, @bblum is this still an issue?

@thestinger
Copy link
Contributor

I might have fixed this with f504461.

@luqmana
Copy link
Member

luqmana commented Oct 11, 2013

In that case, I'll close this now but feel free to reopen if this is still an issue.

@luqmana luqmana closed this as completed Oct 11, 2013
flip1995 pushed a commit to flip1995/rust that referenced this issue Jan 2, 2021
fix ci on master branch; run the --fix test in the correct directory

Turned out the --fix test was run in the wrong directory.

*Please write a short comment explaining your change (or "none" for internal only changes)*
changelog: none
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-codegen Area: Code generation A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. I-crash Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.
Projects
None yet
Development

No branches or pull requests

5 participants