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

error: internal compiler error: unexpected failure (expected item, found foreign item) #14227

Closed
dotnwat opened this issue May 15, 2014 · 4 comments
Labels
E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@dotnwat
Copy link

dotnwat commented May 15, 2014

I'm getting the following error compiling a simple FFI test (backtrace included below). I am creating a reference to a static pointer symbol in a C library. Then, I have a Rust object wrapper and want to create a static instance of that object that points to the pointer defined in the C library. Here is the gist of the library:

pub type MPI_Comm = *c_void;
extern {
   pub static MPI_COMM_WORLD: MPI_Comm;
}

pub struct Comm {
  ptr: ffi::MPI_Comm,
}

pub static COMM_WORLD: Comm = Comm { ptr: ffi::MPI_COMM_WORLD };

Backtrace

error: internal compiler error: unexpected failure
note: the compiler hit an unexpected failure path. this is a bug.
note: we would appreciate a bug report: http://static.rust-lang.org/doc/master/complement-bugreport.html
note: run with `RUST_BACKTRACE=1` for a backtrace
task 'rustc' failed at 'expected item, found foreign item ffi::MPI_COMM_WORLD::MPI_COMM_WORLD (id=47)', /home/nwatkins/rust/rust/src/libsyntax/ast_map.rs:264
stack backtrace:
   1:     0x7f389bbf6320 - rt::backtrace::imp::write::he4a96dd9becae7baQZF::v0.11.pre
   2:     0x7f389bb5e7f0 - rt::unwind::begin_unwind_inner::h429f42930e247ed3TzF::v0.11.pre
   3:     0x7f389bb5da40 - rt::unwind::begin_unwind_fmt::h2658199b4e21bf1d3yF::v0.11.pre
   4:     0x7f389a7d9f70 - ast_map::Map::expect_item::hfd129ba246eef9e7fmw::v0.11.pre
   5:     0x7f389cb333e0 - middle::check_const::CheckItemRecursionVisitor<'a>.Visitor<(*>::visit_expr::h5cd0b6fa8c9a4f2bGTx::v0.11.pre
   6:     0x7f389cb333e0 - middle::check_const::CheckItemRecursionVisitor<'a>.Visitor<(*>::visit_expr::h5cd0b6fa8c9a4f2bGTx::v0.11.pre
   7:     0x7f389cb321e0 - middle::check_const::CheckItemRecursionVisitor<'a>.Visitor<(*>::visit_item::hd092905fe77dd21cLSx::v0.11.pre
   8:     0x7f389cb2d7d0 - middle::check_const::check_item::h95a2cf717ce35925AHx::v0.11.pre
   9:     0x7f389cb306a0 - middle::check_const::check_crate::hb33f792abf387b41bHx::v0.11.pre
  10:     0x7f389cb13c40 - util::common::time::h2370236349741964365::v0.11.pre
  11:     0x7f389cef3780 - driver::driver::phase_3_run_analysis_passes::h6fe36fe1431dcb23Wci::v0.11.pre
  12:     0x7f389ceed280 - driver::driver::compile_input::h002d716c1383702at2h::v0.11.pre
  13:     0x7f389cf90af0 - driver::main_args::closure.92546
  14:     0x7f389cfa7310 - driver::monitor::closure.93721
  15:     0x7f389cfa1750 - task::TaskBuilder::try::closure.93488
  16:     0x7f389c15f1c0 - task::spawn_opts::closure.7382
  17:     0x7f389bbeccd0 - rt::task::Task::run::closure.28450
  18:     0x7f389bc0eaf0 - rust_try
  19:     0x7f389bbecb10 - rt::task::Task::run::h8aff154bc145518aBoD::v0.11.pre
  20:     0x7f389c15ef70 - task::spawn_opts::closure.7355
  21:     0x7f389bbf4d20 - rt::thread::thread_start::ha112b5063324e752M6D::v0.11.pre
  22:     0x7f38998ab0c0 - start_thread
  23:     0x7f389b8292d9 - __clone
  24:                0x0 - <unknown>
@dotnwat dotnwat changed the title error: internal compiler error: unexpected failure error: internal compiler error: unexpected failure (expected item, found foreign item) May 15, 2014
@lilyball
Copy link
Contributor

Simpler test case:

extern {
    pub static symbol: ();
}
static CRASH: () = symbol;

@lilyball
Copy link
Contributor

I suspect there's no valid way for this to work, so it should probably just raise an error.

@huonw
Copy link
Member

huonw commented May 15, 2014

See #9866, and #13325 is vaguely related.

@sanxiyn
Copy link
Member

sanxiyn commented Dec 8, 2014

This seems fixed by #18279.

@alexcrichton alexcrichton added the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label Dec 8, 2014
@ghost ghost self-assigned this Dec 12, 2014
@bors bors closed this as completed in b745a4f Dec 30, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

No branches or pull requests

5 participants