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

ICE: Couldn't find field in struct type (middle::trans::expr::trans_rec_or_struc) #8044

Closed
smvv opened this issue Jul 25, 2013 · 2 comments · Fixed by #9805
Closed

ICE: Couldn't find field in struct type (middle::trans::expr::trans_rec_or_struc) #8044

smvv opened this issue Jul 25, 2013 · 2 comments · Fixed by #9805
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

@smvv
Copy link
Contributor

smvv commented Jul 25, 2013

There is a bug in either exporting or importing metadata from/to a crate. Consider the following test case:

pub struct BTree<V> {
    node: TreeItem<V>,
}

pub enum TreeItem<V> {
    TreeLeaf { value: V },
}

pub fn leaf<V>(value: V) -> TreeItem<V> {
    TreeLeaf { value: value }
}

fn main() {
    BTree::<int> { node: leaf(1) };
}

Invoking rustc minimal.rs results in a binary without any errors. However, the problem arises when the code listed above is compiled as a DSO and use'd in another file:

extern mod minimal;
use minimal::{BTree, leaf};

fn main() {
    BTree::<int> { node: leaf(1) };
}

Invoking rustc --libs minimal.rs && rustc -L. test_minimal.rs causes the failure:

test_minimal.rs:1:0: 1:0 error: internal compiler error: Couldn't find field in struct type

And the corresponding backtrace:

#0 upcall_fail (expr=0x7ffff6f6f040 <str10057> "explicit failure", file=0x7ffff6f6f060 <str10058> "/home/smvv/work/rust/rust/src/libsyntax/diagnostic.rs",
line=70) at /home/smvv/work/rust/rust/src/rt/rust_upcall.cpp:126
#1 0x00007ffff7872119 in sys::begin_unwind_::_89e154cd0915671::_0$x2e8$x2dpre () from /usr/local/bin/../lib/libstd-6c65cf4b443341b1-0.8-pre.so
#2 0x00007ffff7872262 in sys::__extensions__::fail_with::anon::anon::expr_fn_24055 () from /usr/local/bin/../lib/libstd-6c65cf4b443341b1-0.8-pre.so
#3 0x00007ffff7871ad1 in str::as_buf_24046::_f8c6f4a6f9cb738::_0$x2e8$x2dpre () from /usr/local/bin/../lib/libstd-6c65cf4b443341b1-0.8-pre.so
#4 0x00007ffff7872214 in sys::__extensions__::fail_with::anon::expr_fn_24053 () from /usr/local/bin/../lib/libstd-6c65cf4b443341b1-0.8-pre.so
#5 0x00007ffff7871ad1 in str::as_buf_24046::_f8c6f4a6f9cb738::_0$x2e8$x2dpre () from /usr/local/bin/../lib/libstd-6c65cf4b443341b1-0.8-pre.so
#6 0x00007ffff77e544c in sys::__extensions__::meth_12737::fail_with::_db4c44d01ce4116::_0$x2e8$x2dpre ()
from /usr/local/bin/../lib/libstd-6c65cf4b443341b1-0.8-pre.so
#7 0x00007ffff6d87bf3 in diagnostic::__extensions__::meth_9933::span_fatal::_fc67b1b346df3193::_0$x2e8$x2dpre ()
from /usr/local/bin/../lib/libsyntax-64629f7f0c6a9bc-0.8-pre.so
#8 0x00007ffff6d891b0 in diagnostic::__extensions__::meth_10066::span_bug::_fc67b1b346df3193::_0$x2e8$x2dpre ()
from /usr/local/bin/../lib/libsyntax-64629f7f0c6a9bc-0.8-pre.so
#9 0x00007ffff61b2e5d in driver::session::__extensions__::meth_25990::span_bug::_26e752c09216d039::_0$x2e8$x2dpre ()
from /usr/local/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.8-pre.so
#10 0x00007ffff6217a34 in middle::trans::expr::trans_rec_or_struct::anon::anon::expr_fn_28753 ()
from /usr/local/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.8-pre.so
#11 0x00007ffff6216f68 in middle::trans::expr::trans_rec_or_struct::anon::expr_fn_28696 () from /usr/local/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.8-pre.so
#12 0x00007ffff62169b2 in middle::trans::expr::with_field_tys_28693::_46c42f8efbb7710::_0$x2e8$x2dpre ()
from /usr/local/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.8-pre.so
#13 0x00007ffff620dea2 in middle::trans::expr::trans_rec_or_struct::_f1d929df4f373015::_0$x2e8$x2dpre ()
from /usr/local/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.8-pre.so
#14 0x00007ffff6204419 in middle::trans::expr::trans_rvalue_dps_unadjusted::_52aa9592cca04dcc::_0$x2e8$x2dpre ()
from /usr/local/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.8-pre.so
#15 0x00007ffff61a386d in middle::trans::expr::trans_into::_52aa9592cca04dcc::_0$x2e8$x2dpre ()
from /usr/local/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.8-pre.so
#16 0x00007ffff61a1462 in middle::trans::controlflow::trans_block::_f728e2a436e2a6b2::_0$x2e8$x2dpre ()
from /usr/local/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.8-pre.so
#17 0x00007ffff6291cb8 in middle::trans::base::trans_closure::_bc51cb85933ff9::_0$x2e8$x2dpre ()
from /usr/local/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.8-pre.so
#18 0x00007ffff617206d in middle::trans::base::trans_fn::_3aa03f2e3e3fce2::_0$x2e8$x2dpre () from /usr/local/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.8-pre.so
#19 0x00007ffff61746c2 in middle::trans::monomorphize::monomorphic_fn::_6499bc6a823bb5c::_0$x2e8$x2dpre ()
from /usr/local/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.8-pre.so
#20 0x00007ffff61dbb4c in middle::trans::callee::trans_fn_ref_with_vtables::_e9ec05ff0b8ebc4::_0$x2e8$x2dpre ()
from /usr/local/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.8-pre.so
#21 0x00007ffff61d698f in middle::trans::callee::trans_fn_ref::_9877de3bec13e::_0$x2e8$x2dpre ()
from /usr/local/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.8-pre.so
#22 0x00007ffff61d55b3 in middle::trans::callee::trans::trans_def::_d82b599c5e1c7e18::_0$x2e8$x2dpre ()
from /usr/local/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.8-pre.so
#23 0x00007ffff61d52a6 in middle::trans::callee::trans::_db93df2569643ca::_0$x2e8$x2dpre () from /usr/local/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.8-pre.so
#24 0x00007ffff61e12c1 in middle::trans::callee::trans_call::anon::expr_fn_26985 () from /usr/local/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.8-pre.so
#25 0x00007ffff61f6c65 in middle::trans::callee::trans_call_inner::anon::expr_fn_28295 () from /usr/local/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.8-pre.so
#26 0x00007ffff61ac379 in middle::trans::base::with_scope_result::_8ca66caf8a1eb974::_0$x2e8$x2dpre ()
from /usr/local/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.8-pre.so
#27 0x00007ffff61e11f5 in middle::trans::callee::trans_call_inner::_98e174452c12d4e9::_0$x2e8$x2dpre ()
from /usr/local/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.8-pre.so
#28 0x00007ffff61e0ede in middle::trans::callee::trans_call::_9df111b4560fe68::_0$x2e8$x2dpre ()
from /usr/local/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.8-pre.so
#29 0x00007ffff62034cf in middle::trans::expr::trans_rvalue_dps_unadjusted::_52aa9592cca04dcc::_0$x2e8$x2dpre ()
from /usr/local/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.8-pre.so
#30 0x00007ffff61a386d in middle::trans::expr::trans_into::_52aa9592cca04dcc::_0$x2e8$x2dpre ()
from /usr/local/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.8-pre.so
#31 0x00007ffff620e6f8 in middle::trans::expr::trans_adt::_a1e1c692111e8722::_0$x2e8$x2dpre () from /usr/local/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.8-pre.so
#32 0x00007ffff6217560 in middle::trans::expr::trans_rec_or_struct::anon::expr_fn_28696 () from /usr/local/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.8-pre.so
#33 0x00007ffff6216861 in middle::trans::expr::with_field_tys_28693::_46c42f8efbb7710::_0$x2e8$x2dpre ()
from /usr/local/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.8-pre.so
#34 0x00007ffff620dea2 in middle::trans::expr::trans_rec_or_struct::_f1d929df4f373015::_0$x2e8$x2dpre ()
from /usr/local/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.8-pre.so
#35 0x00007ffff6204419 in middle::trans::expr::trans_rvalue_dps_unadjusted::_52aa9592cca04dcc::_0$x2e8$x2dpre ()
from /usr/local/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.8-pre.so
#36 0x00007ffff61a386d in middle::trans::expr::trans_into::_52aa9592cca04dcc::_0$x2e8$x2dpre ()
from /usr/local/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.8-pre.so
#37 0x00007ffff61a2a71 in middle::trans::base::trans_stmt::_edae6a8d38ffec1d::_0$x2e8$x2dpre ()
from /usr/local/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.8-pre.so
#38 0x00007ffff61a1360 in middle::trans::controlflow::trans_block::_f728e2a436e2a6b2::_0$x2e8$x2dpre ()
from /usr/local/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.8-pre.so
#39 0x00007ffff62919b1 in middle::trans::base::trans_closure::_bc51cb85933ff9::_0$x2e8$x2dpre ()
from /usr/local/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.8-pre.so
#40 0x00007ffff617206d in middle::trans::base::trans_fn::_3aa03f2e3e3fce2::_0$x2e8$x2dpre () from /usr/local/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.8-pre.so
#41 0x00007ffff616dbc0 in middle::trans::base::trans_item::_f11a90e765a54937::_0$x2e8$x2dpre ()
from /usr/local/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.8-pre.so
#42 0x00007ffff629634b in middle::trans::base::trans_mod::_255ce5fb2ba5e654::_0$x2e8$x2dpre () from /usr/local/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.8-pre.so
#43 0x00007ffff62a4595 in middle::trans::base::trans_crate::_e066cf236fc41::_0$x2e8$x2dpre () from /usr/local/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.8-pre.so
#44 0x00007ffff681e67c in driver::driver::compile_rest::anon::expr_fn_96428 () from /usr/local/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.8-pre.so
#45 0x00007ffff681c012 in driver::driver::compile_rest::_3f28b012f09a987::_0$x2e8$x2dpre () from /usr/local/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.8-pre.so
#46 0x00007ffff681e984 in driver::driver::compile_upto::_abb8df857e5aa01f::_0$x2e8$x2dpre () from /usr/local/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.8-pre.so
#47 0x00007ffff681ece5 in driver::driver::compile_input::_d058c8129ed82b4e::_0$x2e8$x2dpre () from /usr/local/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.8-pre.so
#48 0x00007ffff68427d4 in run_compiler::_5a6aa77181df60c7::_0$x2e8$x2dpre () from /usr/local/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.8-pre.so
#49 0x00007ffff6861c4e in main::anon::expr_fn_102251 () from /usr/local/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.8-pre.so
#50 0x00007ffff685d8f4 in monitor::anon::expr_fn_102010 () from /usr/local/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.8-pre.so
#51 0x00007ffff6856f72 in task::__extensions__::try_100954::anon::expr_fn_101400 () from /usr/local/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.8-pre.so
#52 0x00007ffff784898f in task::spawn::spawn_raw_oldsched::make_child_wrapper::anon::expr_fn_20828 ()
from /usr/local/bin/../lib/libstd-6c65cf4b443341b1-0.8-pre.so
#53 0x00007ffff4403e52 in task_start_wrapper (a=0x7ffff25c1820) at /home/smvv/work/rust/rust/src/rt/rust_task.cpp:164
#54 0x0000000000000000 in ?? ()
@smvv
Copy link
Contributor Author

smvv commented Jul 25, 2013

It's important to note that the type parameter V cannot be removed from the test case. If I substitute V with int and remove the type parameter from the declaration, the library can be use'd in the other file.

File minimal_int.rs:

pub struct BTree {
    node: TreeItem,
}

pub enum TreeItem {
    TreeLeaf { value: int },
}

pub fn leaf(value: int) -> TreeItem {
    TreeLeaf { value: value }
}

fn main() {
    BTree { node: leaf(1) };
}

File test_minimal.rs:

extern mod minimal_int;
use minimal_int::{BTree, leaf};

fn main() {
    BTree { node: leaf(1) };
}

The test case above works fine. No errors or warnings whatsoever.

So this issue is related to importing/exporting of generic structs and enums from/to a library.

@bluss
Copy link
Member

bluss commented Sep 16, 2013

It appears this is fixed.

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