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

Panic while trying to cast raw pointer to Fn #22034

Closed
xymostech opened this issue Feb 7, 2015 · 0 comments · Fixed by #24259
Closed

Panic while trying to cast raw pointer to Fn #22034

xymostech opened this issue Feb 7, 2015 · 0 comments · Fixed by #24259
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

@xymostech
Copy link

I'm getting a rustc panic while trying to compile code like this:

extern crate libc;

fn main() {
    let userdata: *mut libc::c_void;
    let cb: &mut Fn() = unsafe {
        &mut *(userdata as *mut Fn())
    };
}

Here's the error, and the rustc backtrace:

client.rs:6:16: 6:24 error: internal compiler error: expected object type
client.rs:6         &mut *(userdata as *mut Fn())
                           ^~~~~~~~
note: the compiler unexpectedly panicked. this is a bug.
note: we would appreciate a bug report: http://doc.rust-lang.org/complement-bugreport.html
note: run with `RUST_BACKTRACE=1` for a backtrace
thread 'rustc' panicked at 'Box<Any>', /home/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libsyntax/diagnostic.rs:129

stack backtrace:
   1:     0x7f7130839d60 - sys::backtrace::write::h932393543d112c054sy
   2:     0x7f713085d460 - failure::on_fail::h4947072b7f324f9aVWF
   3:     0x7f71307be800 - rt::unwind::begin_unwind_inner::had7a395ab2928a1fsBF
   4:     0x7f712dbcc920 - rt::unwind::begin_unwind::h6569531574505901365
   5:     0x7f712dbcc8b0 - diagnostic::SpanHandler::span_bug::h7d8e654a08708b434CE
   6:     0x7f712e6dffc0 - session::Session::span_bug::h30c717681b947e2e5aq
   7:     0x7f712ffd3a80 - check::check_cast::h7a31a3aa7ba43ff5aGn
   8:     0x7f7130013ae0 - check::check_expr_with_unifier::h11644655964435566975
   9:     0x7f7130013ae0 - check::check_expr_with_unifier::h11644655964435566975
  10:     0x7f7130013ae0 - check::check_expr_with_unifier::h11644655964435566975
  11:     0x7f7130002810 - check::check_expr_with_unifier::h7412840087484647266
  12:     0x7f712ffce450 - check::check_block_with_expected::h964ea164203d003cLDr
  13:     0x7f7130002810 - check::check_expr_with_unifier::h7412840087484647266
  14:     0x7f7130028dd0 - check::check_decl_local::h83b0a86db28fb770yxr
  15:     0x7f712ffce450 - check::check_block_with_expected::h964ea164203d003cLDr
  16:     0x7f712ffaf2f0 - check::check_fn::h650b0fe39307a8593Qm
  17:     0x7f712ffcb050 - check::check_bare_fn::hf9d06c1c6656a93clGm
  18:     0x7f712ffc2950 - check::check_item::h1e6dbfd08cc874a6CZm
  19:     0x7f713008e9d0 - check_crate::closure.34504
  20:     0x7f71300893b0 - check_crate::h141ffcbde406cd95ZKA
  21:     0x7f7130e2c4e0 - driver::phase_3_run_analysis_passes::hdbd51c532175b9f1pGa
  22:     0x7f7130e12a30 - driver::compile_input::h3abd4b23cefb4912Cba
  23:     0x7f7130ee3f80 - run_compiler::hf6c7680d20cecff97ac
  24:     0x7f7130ee2610 - thunk::F.Invoke<A, R>::invoke::h12458147831130807544
  25:     0x7f7130ee1540 - rt::unwind::try::try_fn::h13767943623378092967
  26:     0x7f71308c93b0 - rust_try_inner
  27:     0x7f71308c93a0 - rust_try
  28:     0x7f7130ee17f0 - thunk::F.Invoke<A, R>::invoke::h15079797001481760000
  29:     0x7f7130849950 - sys::thread::thread_start::h426dd27d44093655UCB
  30:     0x7f712a8d2250 - start_thread
  31:     0x7f713044b219 - clone
  32:                0x0 - <unknown>

I'm using:

$ rustc --version
rustc 1.0.0-nightly (ba2f13ef0 2015-02-04 20:03:55 +0000)
@jdm jdm added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Feb 7, 2015
@ghost ghost added the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label Apr 3, 2015
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

Successfully merging a pull request may close this issue.

2 participants