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 dyn method receiver calls with arbitrary-self type #71427

Closed
puckipedia opened this issue Apr 22, 2020 · 4 comments
Closed

Miri crashes on dyn method receiver calls with arbitrary-self type #71427

puckipedia opened this issue Apr 22, 2020 · 4 comments
Labels
A-DSTs Area: Dynamically-sized types (DSTs) A-miri Area: The miri tool C-enhancement Category: An issue proposing an enhancement or a PR with one. F-arbitrary_self_types `#![feature(arbitrary_self_types)]` I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@puckipedia
Copy link

Code

trait Foo {
    fn bar(self: Pin<&mut Self>) -> bool;
}

impl Foo for &'static str {
    fn bar(self: Pin<&mut Self>) -> bool {
        true
    }
}

fn main() {
    let mut test: Pin<Box<dyn Foo>> = Box::pin("foo");
    test.as_mut().bar();
}

Meta

rustc --version --verbose:

rustc 1.44.0-nightly (7f3df5772 2020-04-16)
binary: rustc
commit-hash: 7f3df5772439eee1c512ed2eb540beef1124d236
commit-date: 2020-04-16
host: x86_64-unknown-linux-gnu
release: 1.44.0-nightly
LLVM version: 9.0

Error output

error: internal compiler error: src/librustc_mir/interpret/place.rs:231: vtable not supported on type std::pin::Pin<&mut dyn Foo>
Backtrace

thread 'rustc' panicked at 'Box<Any>', src/librustc_errors/lib.rs:904:9
stack backtrace:
   0: backtrace::backtrace::libunwind::trace
             at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.46/src/backtrace/libunwind.rs:86
   1: backtrace::backtrace::trace_unsynchronized
             at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.46/src/backtrace/mod.rs:66
   2: std::sys_common::backtrace::_print_fmt
             at src/libstd/sys_common/backtrace.rs:78
   3: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt
             at src/libstd/sys_common/backtrace.rs:59
   4: core::fmt::write
             at src/libcore/fmt/mod.rs:1069
   5: std::io::Write::write_fmt
             at src/libstd/io/mod.rs:1504
   6: std::sys_common::backtrace::_print
             at src/libstd/sys_common/backtrace.rs:62
   7: std::sys_common::backtrace::print
             at src/libstd/sys_common/backtrace.rs:49
   8: std::panicking::default_hook::{{closure}}
             at src/libstd/panicking.rs:198
   9: std::panicking::default_hook
             at src/libstd/panicking.rs:218
  10: rustc_driver::report_ice
  11: std::panicking::rust_panic_with_hook
             at src/libstd/panicking.rs:515
  12: std::panicking::begin_panic
  13: rustc_errors::HandlerInner::bug
  14: rustc_errors::Handler::bug
  15: rustc_middle::util::bug::opt_span_bug_fmt::{{closure}}
  16: rustc_middle::ty::context::tls::with_opt::{{closure}}
  17: rustc_middle::ty::context::tls::with_opt
  18: rustc_middle::util::bug::opt_span_bug_fmt
  19: rustc_middle::util::bug::bug_fmt
  20: rustc_mir::interpret::terminator::<impl rustc_mir::interpret::eval_context::InterpCx<M>>::eval_fn_call
  21: rustc_mir::interpret::step::<impl rustc_mir::interpret::eval_context::InterpCx<M>>::terminator
  22: miri::eval::eval_main
  23: rustc_middle::ty::context::tls::enter_global
  24: <miri::MiriCompilerCalls as rustc_driver::Callbacks>::after_analysis
  25: rustc_interface::interface::run_compiler_in_existing_thread_pool
  26: scoped_tls::ScopedKey<T>::set
  27: rustc_ast::attr::with_globals

@puckipedia puckipedia added C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Apr 22, 2020
@jonas-schievink jonas-schievink added the A-miri Area: The miri tool label Apr 22, 2020
@RalfJung
Copy link
Member

This is basically a duplicate of rust-lang/miri#1038. Not sure if it is better to track this on the Miri side or the rustc side.

Miri simply has no support for dynamic arbitrary-self receivers yet, hence the ICE. This is not really a bug, just a missing feature.

Implementing dynamic arbitrary-self receivers is blocked on #56166.

@RalfJung RalfJung added A-DSTs Area: Dynamically-sized types (DSTs) C-enhancement Category: An issue proposing an enhancement or a PR with one. F-arbitrary_self_types `#![feature(arbitrary_self_types)]` and removed C-bug Category: This is a bug. labels Apr 26, 2020
@RalfJung RalfJung changed the title Miri crashes on dyn method receiver calls Miri crashes on dyn method receiver calls with arbitrary-self type Apr 26, 2020
@fanninpm
Copy link

I have a few questions for reproducibility reasons:

  1. What level of MIR are you using? (I'd like to know a specific cargo or rustc command so I can add it to the glacier.)
  2. Does this still ICE on the latest nightly?

@RalfJung
Copy link
Member

What level of MIR are you using? (I'd like to know a specific cargo or rustc command so I can add it to the glacier.)

You need to use Miri to trigger this ICE. I am not sure if it makes sense to track it in glacier.

@RalfJung
Copy link
Member

Actually, I think it is probably best to just close this in favor of rust-lang/miri#1038, so let me do that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-DSTs Area: Dynamically-sized types (DSTs) A-miri Area: The miri tool C-enhancement Category: An issue proposing an enhancement or a PR with one. F-arbitrary_self_types `#![feature(arbitrary_self_types)]` I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

4 participants