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 traits, tuples, and anonymous functions #3314

Closed
erickt opened this issue Aug 31, 2012 · 4 comments
Closed

ICE with traits, tuples, and anonymous functions #3314

erickt opened this issue Aug 31, 2012 · 4 comments
Assignees
Labels
A-codegen Area: Code generation A-typesystem Area: The type system I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Milestone

Comments

@erickt
Copy link
Contributor

erickt commented Aug 31, 2012

I ran into some troubles trying to rewrite the serializer, and distilled an ICE down to the smallest form I could make:

https://gist.github.com/3548953

I've included the stack trace. The meat of it is:

#0  upcall_fail (expr=0x100c2f7ff "bounds check", file=0x100c303b0 "/Users/etryzelaar/Projects/rust/rust/src/rustc/middle/trans/base.rs", line=2186) at /Users/etryzelaar/Projects/rust/rust/src/rt/rust_upcall.cpp:96
#1  0x000000010075969e in middle::trans::base::make_mono_id::anon::anon ()
#2  0x00000001007594a7 in middle::trans::base::make_mono_id::anon ()
#3  0x0000000100758d12 in vec::map2_27038::_7f52c241d6fc91ca::_04 ()

The relevant code is:

fn make_mono_id(ccx: @crate_ctxt, item: ast::def_id, substs: ~[ty::t],
                vtables: Option<typeck::vtable_res>,
                param_uses: Option<~[type_use::type_uses]>) -> mono_id {
    let precise_param_ids = match vtables {
      Some(vts) => {
        let bounds = ty::lookup_item_type(ccx.tcx, item).bounds;
        let mut i = 0u;
        vec::map2(*bounds, substs, |bounds, subst| {
            let mut v = ~[];
            for vec::each(*bounds) |bound| {
                match bound {
                  ty::bound_trait(_) => {
                    vec::push(v, impl::vtable_id(ccx, vts[i]));  // <--- ICE HERE
                    i += 1u;
                  }
                  _ => ()
                }
            }
            (subst, if v.len() > 0u { Some(v) } else { None })
        })
      }
      None => {
        vec::map(substs, |subst| (subst, None))
      }
    };
...
@erickt
Copy link
Contributor Author

erickt commented Sep 5, 2012

A couple new datapoints. I slimmed down the example that triggers the bug to here: https://gist.github.com/3629787. I think the bug is in monomorphization, as a vtable based version with casting doesn't trigger the bug: https://gist.github.com/3629900

@ghost ghost assigned nikomatsakis Sep 5, 2012
@erickt
Copy link
Contributor Author

erickt commented Sep 7, 2012

And here are a couple similar variations that also don't trigger the bug: https://gist.github.com/3637839.

@nikomatsakis
Copy link
Contributor

I'm pretty sure I know what the problem is here, but i'm digging in a bit more for more context. Still I think the error is that trans_monomorphized_callee does not combine the substitutions/vtables from the receiver and from the method.

@nikomatsakis
Copy link
Contributor

Yeah, after studying this more I am pretty certain that monomorphization around method vtables is generally broken. Doesn't seem too hard to fix though, but (as so often happens) I'm amazed we got this far.

RalfJung pushed a commit to RalfJung/rust that referenced this issue Feb 25, 2024
jaisnan pushed a commit to jaisnan/rust-dev that referenced this issue Jul 29, 2024
Upgrade toolchain to `nightly-2024-07-01` so we're up to date. No other
changes are required.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-codegen Area: Code generation A-typesystem Area: The type system I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

No branches or pull requests

2 participants