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

Miri crashes on fat ptr to thin ptr conversion #50495

Closed
bjorn3 opened this issue May 7, 2018 · 1 comment · Fixed by #50530
Closed

Miri crashes on fat ptr to thin ptr conversion #50495

bjorn3 opened this issue May 7, 2018 · 1 comment · Fixed by #50530

Comments

@bjorn3
Copy link
Member

bjorn3 commented May 7, 2018

At

(Value::ByVal(_), _) => bug!("expected fat ptr"),

This is used by is_null()

rust/src/libcore/ptr.rs

Lines 527 to 531 in 428ea5f

pub fn is_null(self) -> bool {
// Compare via a cast to a thin pointer, so fat pointers are only
// considering their "data" part for null-ness.
(self as *const u8) == null()
}

Backtrace:

error: internal compiler error: librustc_mir/interpret/eval_context.rs:671: expected fat ptr

thread 'main' panicked at 'Box<Any>', librustc_errors/lib.rs:554:9
stack backtrace:
   0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
             at libstd/sys/unix/backtrace/tracing/gcc_s.rs:49
   1: std::sys_common::backtrace::print
             at libstd/sys_common/backtrace.rs:71
             at libstd/sys_common/backtrace.rs:59
   2: std::panicking::default_hook::{{closure}}
             at libstd/panicking.rs:211
   3: std::panicking::default_hook
             at libstd/panicking.rs:227
   4: rustc::util::common::panic_hook
   5: std::panicking::rust_panic_with_hook
             at libstd/panicking.rs:467
   6: std::panicking::begin_panic
   7: rustc_errors::Handler::bug
   8: rustc::session::opt_span_bug_fmt::{{closure}}
   9: rustc::ty::context::tls::with_opt::{{closure}}
  10: rustc::ty::context::tls::with_context_opt
  11: rustc::ty::context::tls::with_opt
  12: rustc::session::opt_span_bug_fmt
  13: rustc::session::bug_fmt
  14: <rustc_mir::interpret::eval_context::EvalContext<'a, 'mir, 'tcx, M>>::eval_rvalue_into_place
             at /home/bjorn/Documenten/miri/<bug macros>:4
  15: rustc_mir::interpret::step::<impl rustc_mir::interpret::eval_context::EvalContext<'a, 'mir, 'tcx, M>>::statement
             at /checkout/src/librustc_mir/interpret/step.rs:59
  16: rustc_mir::interpret::step::<impl rustc_mir::interpret::eval_context::EvalContext<'a, 'mir, 'tcx, M>>::step
             at /checkout/src/librustc_mir/interpret/step.rs:35
  17: priroda::step::step
             at src/step.rs:82
  18: priroda::step::step_routes::single::{{closure}}
             at src/step.rs:214
  19: <F as alloc::boxed::FnBox<A>>::call_box
             at /checkout/src/liballoc/boxed.rs:638
  20: priroda::act
             at src/main.rs:213
  21: <priroda::MiriCompilerCalls as rustc_driver::CompilerCalls<'a>>::build_controller::{{closure}}
             at src/main.rs:101
  22: rustc::ty::context::tls::with_context
  23: rustc_driver::driver::compile_input::{{closure}}
  24: rustc::ty::context::tls::enter_context
  25: <std::thread::local::LocalKey<T>>::with
  26: rustc::ty::context::TyCtxt::create_and_enter
  27: rustc_driver::driver::compile_input
  28: rustc_driver::run_compiler_impl
  29: <scoped_tls::ScopedKey<T>>::set
  30: syntax::with_globals
  31: rustc_driver::run_compiler
  32: priroda::main
             at src/main.rs:249
  33: std::rt::lang_start::{{closure}}
             at /checkout/src/libstd/rt.rs:74
  34: std::panicking::try::do_call
             at libstd/rt.rs:59
             at libstd/panicking.rs:310
  35: __rust_maybe_catch_panic
             at libpanic_unwind/lib.rs:105
  36: std::rt::lang_start_internal
             at libstd/panicking.rs:289
             at libstd/panic.rs:374
             at libstd/rt.rs:58
  37: std::rt::lang_start
             at /checkout/src/libstd/rt.rs:74
  38: main
  39: __libc_start_main
  40: _start
query stack during panic:
end of query stack

cc rust-lang/miri#368

@oli-obk
Copy link
Contributor

oli-obk commented May 7, 2018

Minimal repro:

#![feature(extern_types)]

extern {
    type Opaque;
}

const FOO: *const u8 = &42 as *const _ as *const Opaque as *const u8;

fn main() {
    let foo = FOO;
}

bors added a commit that referenced this issue May 8, 2018
Fix thinning pointers to extern types in miri

r? @kennytm as an alternative to disabling the miri build

fixes #50495
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants