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 with per-type serializer #3741

Closed
nikomatsakis opened this issue Oct 12, 2012 · 4 comments
Closed

ICE with per-type serializer #3741

nikomatsakis opened this issue Oct 12, 2012 · 4 comments
Assignees
Labels
A-codegen Area: Code generation I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Milestone

Comments

@nikomatsakis
Copy link
Contributor

@erickt's implementation of #3740 leads to an ICE with this backtrace:

#0  upcall_fail (expr=0x1293624f0 "option::get none", file=0x1016671c0 "/Users/nmatsakis/versioned/rust-green/src/rustc/rustc.rc", line=1) at rust_upcall.cpp:94
#1  0x00000001001120f7 in rt::rustrt::rust_upcall_fail::_74a64c4360d2dcec::_04 ()
#2  0x000000010003c5c7 in rt::rt_fail_::_74a64c4360d2dcec::_04 ()
#3  0x0000000100b8d5a8 in option::get_23338::_29fe71a392a4924::_04 ()
#4  0x0000000100b8d43d in option::__extensions__::get_23335::_f0c217aeadcb2131::_04 ()
#5  0x00000001015012b9 in metadata::decoder::get_impl_method::_783f8d1a39c49ab::_04 ()
#6  0x0000000100d3b393 in metadata::csearch::get_impl_method::_6b7fc67f87eddc92::_04 ()
#7  0x0000000100d38f74 in middle::trans::meth::method_with_name::_ba3c2a2e023f72d::_04 ()
#8  0x0000000100bd2362 in middle::trans::meth::trans_static_method_callee::_f9ec6ca09ccac979::_04 ()
#9  0x0000000100bcb78d in middle::trans::callee::trans::trans_def::_67363582be12cd36::_04 ()
#10 0x0000000100bcb2ce in middle::trans::callee::trans::_f48ed4270a0c3c0::_04 ()
#11 0x0000000100bd6cd8 in middle::trans::callee::trans_call::anon::expr_fn_24271 ()
#12 0x0000000100bef739 in middle::trans::callee::trans_call_inner::anon::expr_fn_25077 ()
#13 0x0000000100b8ca0f in middle::trans::base::with_scope::_996fb23bb7f2845::_04 ()
#14 0x0000000100bd6bdb in middle::trans::callee::trans_call_inner::_ff61dbd7aaf3bd3::_04 ()
#15 0x0000000100bd6983 in middle::trans::callee::trans_call::_64631445544261e3::_04 ()
#16 0x0000000100c06c0c in middle::trans::expr::trans_rvalue_dps_unadjusted::_ead42a4b3d1be38a::_04 ()
#17 0x0000000100bff841 in middle::trans::expr::trans_into_unadjusted::_ead42a4b3d1be38a::_04 ()
#18 0x0000000100b73177 in middle::trans::expr::trans_into::_ead42a4b3d1be38a::_04 ()
#19 0x0000000100c8de0b in middle::trans::base::init_local::_a0ad6e37ca3614::_04 ()
#20 0x0000000100c8f93a in middle::trans::base::trans_stmt::anon::expr_fn_27842 ()
#21 0x0000000100b71492 in vec::each_22729::anon::expr_fn_22735 ()
#22 0x0000000100b713ba in vec::as_imm_buf_22732::_2bccd72f7286ea4a::_04 ()
#23 0x0000000100b71298 in vec::each_22729::_74aecc843b4616d::_04 ()
#24 0x0000000100b72f0a in middle::trans::base::trans_stmt::_cb45203fc1c777f9::_04 ()
#25 0x0000000100b7162b in middle::trans::controlflow::trans_block::anon::expr_fn_22743 ()
#26 0x0000000100b71492 in vec::each_22729::anon::expr_fn_22735 ()
#27 0x0000000100b713ba in vec::as_imm_buf_22732::_2bccd72f7286ea4a::_04 ()
#28 0x0000000100b71298 in vec::each_22729::_74aecc843b4616d::_04 ()
#29 0x0000000100b6fafe in middle::trans::controlflow::trans_block::_2448b950a43ba10::_04 ()
#30 0x0000000100c0e499 in middle::trans::expr::trans_rvalue_dps_unadjusted::anon::expr_fn_25395 ()
#31 0x0000000100b8ca0f in middle::trans::base::with_scope::_996fb23bb7f2845::_04 ()
#32 0x0000000100c0585b in middle::trans::expr::trans_rvalue_dps_unadjusted::_ead42a4b3d1be38a::_04 ()
#33 0x0000000100bff841 in middle::trans::expr::trans_into_unadjusted::_ead42a4b3d1be38a::_04 ()
#34 0x0000000100b73177 in middle::trans::expr::trans_into::_ead42a4b3d1be38a::_04 ()
#35 0x0000000100b6fba2 in middle::trans::controlflow::trans_block::_2448b950a43ba10::_04 ()
#36 0x00000001015b6a3a in __morestack ()
#37 0x0000000100b6f8fc in middle::trans::controlflow::trans_block::_2448b950a43ba10::_04 ()
#38 0x0000000100bdccdb in vec::__extensions__::each_24341::anon::expr_fn_24344 ()
#39 0x0000000100b71492 in vec::each_22729::anon::expr_fn_22735 ()
#40 0x0000000100b713ba in vec::as_imm_buf_22732::_2bccd72f7286ea4a::_04 ()
#41 0x0000000100b71298 in vec::each_22729::_74aecc843b4616d::_04 ()
#42 0x0000000100bdcc64 in vec::__extensions__::each_24341::_f660f04d53d71191::_04 ()
#43 0x0000000100d1ea90 in middle::trans::alt::trans_alt_inner::_a9d346c11893b647::_04 ()
#44 0x0000000100d1ded1 in middle::trans::alt::trans_alt::anon::expr_fn_30846 ()
#45 0x0000000100b8ca0f in middle::trans::base::with_scope::_996fb23bb7f2845::_04 ()
#46 0x0000000100c0e33f in middle::trans::alt::trans_alt::_9296d11856c4ec4::_04 ()
#47 0x0000000100c04fd2 in middle::trans::expr::trans_rvalue_dps_unadjusted::_ead42a4b3d1be38a::_04 ()
#48 0x0000000100bff841 in middle::trans::expr::trans_into_unadjusted::_ead42a4b3d1be38a::_04 ()
#49 0x0000000100b73177 in middle::trans::expr::trans_into::_ead42a4b3d1be38a::_04 ()
#50 0x0000000100b6fba2 in middle::trans::controlflow::trans_block::_2448b950a43ba10::_04 ()
#51 0x0000000100c9d86f in middle::trans::base::trans_closure::_de391e1ab6ebccc::_04 ()
#52 0x0000000100ac4296 in middle::trans::base::trans_fn::_f5531fab3be1a3c1::_04 ()
#53 0x0000000100abcdb9 in middle::trans::base::trans_item::_85f94bc13edd0::_04 ()
#54 0x0000000100cad24d in middle::trans::base::trans_mod::anon::expr_fn_28568 ()
#55 0x0000000100b71492 in vec::each_22729::anon::expr_fn_22735 ()
#56 0x0000000100b713ba in vec::as_imm_buf_22732::_2bccd72f7286ea4a::_04 ()
#57 0x0000000100b71298 in vec::each_22729::_74aecc843b4616d::_04 ()
#58 0x0000000100cac801 in middle::trans::base::trans_mod::_a57b1d56f5ce85ad::_04 ()
#59 0x0000000100abc4d1 in middle::trans::base::trans_item::_85f94bc13edd0::_04 ()
#60 0x0000000100cad24d in middle::trans::base::trans_mod::anon::expr_fn_28568 ()
#61 0x0000000100b71492 in vec::each_22729::anon::expr_fn_22735 ()
#62 0x0000000100b713ba in vec::as_imm_buf_22732::_2bccd72f7286ea4a::_04 ()
#63 0x0000000100b71298 in vec::each_22729::_74aecc843b4616d::_04 ()
#64 0x0000000100cac801 in middle::trans::base::trans_mod::_a57b1d56f5ce85ad::_04 ()
#65 0x0000000100abc4d1 in middle::trans::base::trans_item::_85f94bc13edd0::_04 ()
#66 0x0000000100cad24d in middle::trans::base::trans_mod::anon::expr_fn_28568 ()
#67 0x0000000100b71492 in vec::each_22729::anon::expr_fn_22735 ()
#68 0x0000000100b713ba in vec::as_imm_buf_22732::_2bccd72f7286ea4a::_04 ()
#69 0x0000000100b71298 in vec::each_22729::_74aecc843b4616d::_04 ()
#70 0x0000000100cac801 in middle::trans::base::trans_mod::_a57b1d56f5ce85ad::_04 ()
#71 0x0000000100cdf908 in middle::trans::base::trans_crate::_3c3db3d1abf0159a::_04 ()
#72 0x00000001015b6a3a in __morestack ()

I haven't gotten very far in tracking this down. It seems to have something to do with cross-crate static functions.

@ghost ghost assigned nikomatsakis Oct 12, 2012
@nikomatsakis
Copy link
Contributor Author

Oh, I think this may be a dup of #3446.

@nikomatsakis
Copy link
Contributor Author

Oh, well, not precisely, but I think it's related to this FIXME in the code:

    // FIXME(#3446) -- I am pretty sure index 0 is not the right one,
    // if the static method is implemented on a generic type. (NDM)

@nikomatsakis
Copy link
Contributor Author

I believe this is a minified example:

trait Deserializer {
    fn read_int() -> int;
}

trait Deserializable<D: Deserializer> {
    static fn deserialize(d: &D) -> self;
}

impl<D: Deserializer> int: Deserializable<D> {
    static fn deserialize(d: &D) -> int {
        return d.read_int();
    }
}

struct FromThinAir { dummy: () }

impl FromThinAir: Deserializer {
    fn read_int() -> int { 22 }
}

fn main() {
    let d = FromThinAir { dummy: () };
    let i: int = deserialize(&d);
    assert i == 22;
}

The stack track is slightly different owing to the fact that this is not the cross-crate case, but I think the relevant parts are the same:

#0  upcall_fail (expr=0x102b0ef50 "option::get none", file=0x101668170 "/Users/nmatsakis/versioned/rust-green/src/rustc/rustc.rc", line=1) at rust_upcall.cpp:94
#1  0x00000001001120f7 in rt::rustrt::rust_upcall_fail::_74a64c4360d2dcec::_04 ()
#2  0x000000010003c5c7 in rt::rt_fail_::_74a64c4360d2dcec::_04 ()
#3  0x0000000100b62952 in option::get_22339::_89c15131464a9573::_04 ()
#4  0x0000000100d3b2a5 in middle::trans::meth::method_from_methods::_6b67243aebfac69::_04 ()
#5  0x0000000100d38f98 in middle::trans::meth::method_with_name::_19b276bbd665a346::_04 ()
#6  0x0000000100bd2592 in middle::trans::meth::trans_static_method_callee::_f9ec6ca09ccac979::_04 ()
#7  0x0000000100bcb9bd in middle::trans::callee::trans::trans_def::_67363582be12cd36::_04 ()
#8  0x0000000100bcb4fe in middle::trans::callee::trans::_f48ed4270a0c3c0::_04 ()
#9  0x00000001015b78fa in __morestack ()

@nikomatsakis
Copy link
Contributor Author

Fixing this is I think as "simple" as changing the [0] to be [x] where x is the number of bounds on the impl's type parameters (sigh, what a complex encoding we have) --- but finding out the number of impl type parameters is a bit of a pain. I think the right information is not available in the cross-crate case. So right now I'm experimenting with the best way to encode that.

RalfJung pushed a commit to RalfJung/rust that referenced this issue Jul 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-codegen Area: Code generation I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

No branches or pull requests

1 participant