Skip to content

feature(drop_types_in_const): type with drop flag in a const causes ICE/trap #35654

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
durka opened this issue Aug 13, 2016 · 9 comments
Closed
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@durka
Copy link
Contributor

durka commented Aug 13, 2016

Code:

#![feature(drop_types_in_const)]

struct Dropper;

impl Drop for Dropper { fn drop(&mut self) { println!("dropping"); } }

static mut D: Dropper = Dropper;

fn main() {
    unsafe { D = Dropper; }
}

With MIR on:

thread 'rustc' panicked at 'assertion failed: `(left == right)` (left: `0`, right: `1`)', ../src/librustc_trans/adt.rs:1424
stack backtrace:
   1:        0x1121b57fe - std::sys::backtrace::tracing::imp::write::h29f5fdb9fc0a7395
   2:        0x1121c48ef - std::panicking::default_hook::_{{closure}}::h2cc84f0378700526
   3:        0x1121c2dfd - std::panicking::default_hook::hbbe7fa36a995aca0
   4:        0x1121c3497 - std::panicking::rust_panic_with_hook::h105c3d42fcd2fb5e
   5:        0x1121c3354 - std::panicking::begin_panic::hbf62ea4a5ff3f9de
   6:        0x1121c3262 - std::panicking::begin_panic_fmt::h20f5943904e5791d
   7:        0x10dbaea73 - rustc_trans::adt::build_const_struct::h553d38025453e4ea
   8:        0x10dbad8d5 - rustc_trans::adt::trans_const::h31bc6eab0284c8f0
   9:        0x10dc7188d - rustc_trans::mir::constant::MirConstContext::trans::hf3d43154f4de3a91
  10:        0x10dc6f80e - rustc_trans::mir::constant::MirConstContext::trans_def::hc17841f2936ef79b
  11:        0x10dc7565e - rustc_trans::mir::constant::trans_static_initializer::h98e4a45ec90977e8
  12:        0x10dc875d1 - rustc_trans::trans_item::TransItem::define::h1e5a74077917a073
  13:        0x10dbc4f7b - rustc_trans::base::trans_crate::h9baf3a0389546061
  14:        0x10d6cad8a - rustc_driver::driver::phase_4_translate_to_llvm::h54e99578fb1bb696
  15:        0x10d707fcc - rustc_driver::driver::compile_input::_{{closure}}::h7236bd0d96fe8ce9
  16:        0x10d6fac3a - rustc_driver::driver::phase_3_run_analysis_passes::_{{closure}}::h7f2cec505064b4bf
  17:        0x10d656565 - rustc::ty::context::TyCtxt::create_and_enter::hab8fd8369376d0f6
  18:        0x10d6b6721 - rustc_driver::driver::compile_input::hb4cc34cf85dc1edf
  19:        0x10d6dd5b0 - rustc_driver::run_compiler::h50f95674bd902ab5
  20:        0x10d62d29e - std::panicking::try::call::h4577500a5284c6ff
  21:        0x1121cb76a - __rust_maybe_catch_panic
  22:        0x10d645791 - _<F as alloc..boxed..FnBox<A>>::call_box::h24f3eb0b42327962
  23:        0x1121c1ba5 - std::sys::thread::Thread::new::thread_start::h8f3bd45211e9f5ea
  24:     0x7fff84dd9898 - _pthread_body
  25:     0x7fff84dd9729 - _pthread_start

With MIR off, the code compiles but traps (Trace/BPT trap: 5) at runtime.

@Aatch
Copy link
Contributor

Aatch commented Aug 15, 2016

I assume this is related to the drop flag (which I believe still exists, even if it is on it's last legs).

/cc @rust-lang/compiler

@Aatch Aatch added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Aug 15, 2016
@eddyb
Copy link
Member

eddyb commented Aug 15, 2016

Indeed, the drop_types_in_const feature doesn't work with drop flags yet. Hopefully we'll sort this out after the beta branches off.

@durka
Copy link
Contributor Author

durka commented Aug 15, 2016

@eddyb you mean, doesn't work with stack drop flags? Note that it's broken (in different ways) with and without MIR, so I'm not sure this is new...

@eddyb
Copy link
Member

eddyb commented Aug 15, 2016

@durka No, I mean the drop flags, the old ones embedded in every type implementing Drop.

@durka
Copy link
Contributor Author

durka commented Aug 15, 2016

OK, so the drop_types_in_const feature has never actually worked so far?

On Mon, Aug 15, 2016 at 1:22 AM, Eduard-Mihai Burtescu <
[email protected]> wrote:

@durka https://github.com/durka No, I mean the drop flags, the old
ones embedded in every type implementing Drop.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#35654 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAC3n6uN7mkgosU5E4JXXgGI_wo0r1Wjks5qf_d9gaJpZM4JjtxT
.

@Aatch
Copy link
Contributor

Aatch commented Aug 15, 2016

@durka presumably types with #[unsafe_no_drop_flag] work.

@eddyb
Copy link
Member

eddyb commented Aug 15, 2016

@durka presumably types with #[unsafe_no_drop_flag] worked.

Indeed, Option<Box<T>> and Option<Vec<T>> included.

@durka
Copy link
Contributor Author

durka commented Aug 15, 2016

OK. Should I leave this open then?

@durka durka changed the title ICE or trap with drop_types_in_const feature(drop_types_in_const): type with drop flag in a const causes ICE/trap Aug 15, 2016
@durka
Copy link
Contributor Author

durka commented Aug 28, 2016

Looks like maybe a dupe of #34053. Anyway, works fine with nightly since in-struct drop flags are gone.

@durka durka closed this as completed Aug 28, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

No branches or pull requests

3 participants