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

Cross-crate inlined drop methods don't work. #7793

Closed
mstewartgallus opened this issue Jul 15, 2013 · 2 comments · Fixed by #10242
Closed

Cross-crate inlined drop methods don't work. #7793

mstewartgallus opened this issue Jul 15, 2013 · 2 comments · Fixed by #10242
Labels
A-destructors Area: Destructors (`Drop`, …) A-metadata Area: Crate metadata I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@mstewartgallus
Copy link
Contributor

Consider the following crate myextra.rs, and user of the crate main.rs. After the myextra.rs crate is succesfully compiled, and when main.rs is compiled, and linked with myextra.rs the following internal compiler error occurs, and the following error is logged (with RUST_LOG=1)

rust: ~"failed to find block with tag 13"
rust: task failed at 'explicit failure', /home/steven/others/src/rust/src/libextra/ebml.rs:219
error: internal compiler error: unexpected failure
note: the compiler hit an unexpected failure path. this is a bug
note: try running with RUST_LOG=rustc=1,::rt::backtrace to get further details and report the results to github.com/mozilla/rust/issues
rust: task failed at 'explicit failure', /home/steven/others/src/rust/src/librustc/rustc.rs:362
rust: domain main @0xad8010 root task failed

myextra.rs

#[link(name = "myextra")];
#[crate_type = "lib"];


pub struct WriteLock;

impl WriteLock {
    pub fn new() -> WriteLock { fail!() }
}

impl Drop for WriteLock {
    // Removing the inline attribute fixes the problem
    #[inline(always)]
    fn drop(&mut self) { }
}

main.rs

extern mod myextra;

use myextra::WriteLock;


fn main() {
    let _foo = WriteLock::new();
}

Commands to reproduce:

% rustc --lib myextra.rs && RUST_LOG=rustc=1 rustc -L. main.rs
warning: missing crate link meta `vers`, using `0.0` as default
warning: no debug symbols in executable (-arch x86_64)
failed to find block with tag 13
task <unnamed> failed at 'explicit failure', /Users/fklock/Dev/Mozilla/rust.git/src/libextra/ebml.rs:220
error: internal compiler error: unexpected failure
note: the compiler hit an unexpected failure path. this is a bug
note: try running with RUST_LOG=rustc=1 to get further details and report the results to github.com/mozilla/rust/issues
task <unnamed> failed at 'explicit failure', /Users/fklock/Dev/Mozilla/rust.git/src/librustc/rustc.rs:377
% 

Stack trace from gdb:

(gdb) bt
#0  0x00007fff8fb6a521 in __cxa_throw ()
#1  0x0000000102c21c27 in rust_begin_unwind (token=<value temporarily unavailable, due to optimizations>) at /Users/fklock/Dev/Mozilla/rust.git/src/rt/rust_builtin.cpp:533
#2  0x000000010008ecc6 in rt::task::Unwinder::begin_unwind::h7c12263797ed078Twao::v0.8$x2dpre ()
#3  0x000000010008dff2 in sys::begin_unwind_::h89e154cd0915671aJ::v0.8$x2dpre ()
#4  0x000000010008e152 in sys::__extensions__::fail_with::anon::anon::expr_fn::af ()
#5  0x000000010008da48 in c_str::ToCStr::with_c_str::hc6798931b183a7aa::v0.8$x2dpre ()
#6  0x000000010008e101 in sys::__extensions__::fail_with::anon::expr_fn::ae ()
#7  0x000000010008da48 in c_str::ToCStr::with_c_str::hc6798931b183a7aa::v0.8$x2dpre ()
#8  0x000000010000ca7c in sys::FailWithCause$__extensions__::fail_with::hdb4c44d01ce4116AHa0::v0.8$x2dpre ()
#9  0x00000001005d0211 in ebml::reader::get_doc::h48e2c3d9cf8ec3d8aG::v0.8$x2dpre ()
#10 0x00000001013c50d5 in metadata::decoder::item_symbol::h67beac06c34ecebaJ::v0.8$x2dpre ()
#11 0x00000001013cb63c in metadata::decoder::get_symbol::h18a6afa78b26cbf3ay::v0.8$x2dpre ()
#12 0x0000000100d9f6d6 in metadata::csearch::get_symbol::h20f8f2c15a6feb90ax::v0.8$x2dpre ()
#13 0x0000000100d44f6b in middle::trans::base::get_res_dtor::hda2a82128fbf9c23a8::v0.8$x2dpre ()
#14 0x0000000100d44637 in middle::trans::glue::trans_struct_drop_flag::anon::expr_fn::aJ ()
#15 0x0000000100d441b1 in middle::trans::base::with_cond::hcf4955b2b88de3daG::v0.8$x2dpre ()
#16 0x0000000100d42f86 in middle::trans::glue::trans_struct_drop_flag::heaa8734681d4d6baD::v0.8$x2dpre ()
#17 0x0000000100d3eb06 in middle::trans::glue::make_drop_glue::h5d8c6f0d36ac2e4ae::v0.8$x2dpre ()
#18 0x0000000100d4ce16 in middle::trans::glue::make_generic_glue_inner::hc8fa84edf7bf7faF::v0.8$x2dpre ()
#19 0x0000000100d3dceb in middle::trans::glue::make_generic_glue::ha7ad711b993f6f80ag::v0.8$x2dpre ()
#20 0x0000000100d3ba6a in middle::trans::glue::lazily_emit_tydesc_glue::h30c42fc3732305dad::v0.8$x2dpre ()
#21 0x0000000100d3f8ce in middle::trans::glue::call_tydesc_glue_full::hfc61d796e17b57cbaC::v0.8$x2dpre ()
#22 0x0000000100d39cb2 in middle::trans::glue::call_tydesc_glue::hc5996dd21893fag::v0.8$x2dpre ()
#23 0x0000000100d39fa2 in middle::trans::glue::drop_ty::h5d8c6f0d36ac2e4aD::v0.8$x2dpre ()
#24 0x0000000100dda6af in middle::trans::common::add_clean::anon::anon::expr_fn::aC ()
#25 0x0000000100e1853c in middle::trans::base::trans_block_cleanups_::hec4ff651426f5a6aI::v0.8$x2dpre ()
#26 0x0000000100e18e34 in middle::trans::base::cleanup_block::h6561f3b8f40496aB::v0.8$x2dpre ()
#27 0x0000000100e21e38 in middle::trans::base::trans_closure::h24546ef980e82cc9a8::v0.8$x2dpre ()
#28 0x0000000100cf3fa0 in middle::trans::base::trans_fn::h4aa9be3f4a84a92ar::v0.8$x2dpre ()
#29 0x0000000100cea483 in middle::trans::base::trans_item::h7140b0485824492aa::v0.8$x2dpre ()
#30 0x0000000100e2864f in middle::trans::base::trans_mod::h5661676b3713944av::v0.8$x2dpre ()
#31 0x0000000100e33e1e in middle::trans::base::trans_crate::ha032f53ebcceafac::v0.8$x2dpre ()
#32 0x00000001013f1d7e in driver::driver::phase_4_translate_to_llvm::h58f312694ff58822ah::v0.8$x2dpre ()
#33 0x00000001013f2af0 in driver::driver::compile_input::h97189be1b4289193ah::v0.8$x2dpre ()
#34 0x0000000101418924 in run_compiler::h728412684e5354f9ar::v0.8$x2dpre ()
#35 0x000000010142e4de in main_args::anon::expr_fn::a0 ()
#36 0x000000010142c2fd in monitor::anon::expr_fn::az ()
#37 0x00000001014293bf in task::TaskBuilder::try::anon::expr_fn::BPaoah ()
#38 0x0000000100065ea0 in task::spawn::spawn_raw::anon::expr_fn::aU ()
#39 0x00000001000ac1c0 in rt::task::__extensions__::build_start_wrapper::anon::anon::expr_fn::ar ()
#40 0x00000001000aa6e7 in rt::task::__extensions__::run::anon::expr_fn::aJ ()
#41 0x0000000102c21ba3 in rust_try (f=<value temporarily unavailable, due to optimizations>, fptr=<value temporarily unavailable, due to optimizations>, env=<value temporarily unavailable, due to optimizations>) at /Users/fklock/Dev/Mozilla/rust.git/src/rt/rust_builtin.cpp:523
#42 0x00000001000aa61c in rt::task::Unwinder::try::h199ab8d6eb226980TwaI::v0.8$x2dpre ()
#43 0x00000001000aa491 in rt::task::Task::run::h199ab8d6eb226980EUaH::v0.8$x2dpre ()
#44 0x00000001000abd9c in rt::task::__extensions__::build_start_wrapper::anon::expr_fn::ai ()
@pnkfelix
Copy link
Member

visiting for triage, email from 2013 sep 23.

bug still occurs. (updated it to match new signature for Drop trait.)

@erickt
Copy link
Contributor

erickt commented May 11, 2014

I've updated this to HEAD, and it works with this code:

myextra.rs:

#![crate_type = "lib"]

pub struct WriteLock;

impl WriteLock {
    pub fn new() -> WriteLock { fail!() }
}

impl Drop for WriteLock {
    // Removing the inline attribute fixes the problem
    #[inline(always)]
    fn drop(&mut self) { }
}

main.rs:

extern crate myextra;

use myextra::WriteLock;

fn main() {
    let _foo = WriteLock::new();
}

Closing.

@erickt erickt reopened this May 11, 2014
@erickt erickt closed this as completed May 11, 2014
flip1995 pushed a commit to flip1995/rust that referenced this issue Oct 21, 2021
Add option to `new_lint` to generate MSRV enabled lint

changelog: none
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-destructors Area: Destructors (`Drop`, …) A-metadata Area: Crate metadata 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.

3 participants