Skip to content

ICE: rust: task failed at 'Assertion fcx.locals.contains_key(nid) failed', #3021

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
dgryski opened this issue Jul 25, 2012 · 8 comments
Closed
Labels
A-resolve Area: Name/path resolution done by `rustc_resolve` specifically I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Milestone

Comments

@dgryski
Copy link
Contributor

dgryski commented Jul 25, 2012

This is with a build of master. I'm testing with now a build of incoming (but my poor laptop is taking a while to get through the build of llvm...)

MacBook-Pro-de-Damian-Gryski-2:siphash dgryski$ cat siphash-ice.rs
use std;

iface siphash {
    fn result() -> u64;
    fn reset();
}

fn siphash(k0 : u64, k1 : u64) -> siphash {
    type sipstate = {
        mut v0 : u64,
        mut v1 : u64,
    };

    fn mk_result(st : sipstate) -> u64 {

        let v0 = st.v0,
            v1 = st.v1;
        ret v0 ^ v1;
    }

   impl of siphash for sipstate {
        fn reset() {
            self.v0 = k0 ^ 0x736f6d6570736575;
            self.v1 = k1 ^ 0x646f72616e646f6d;
        }
        fn result() -> u64 { ret mk_result(self); }
    }
}
MacBook-Pro-de-Damian-Gryski-2:siphash dgryski$ RUST_LOG=rustc=0,::rt::backtrace rustc --test siphash-ice.rs
rust: task failed at 'Assertion fcx.locals.contains_key(nid) failed', /Users/dgryski/work/src/cvs/rust/src/rustc/middle/typeck/check.rs:1952
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=0,::rt::backtrace to get further details and report the results to github.com/mozilla/rust/issues
rust: task failed at 'explicit failure', /Users/dgryski/work/src/cvs/rust/src/rustc/driver/rustc.rs:256
rust: domain main @0x103800010 root task failed
rust: task failed at 'killed', /Users/dgryski/work/src/cvs/rust/src/libcore/task.rs:523
@ghost ghost assigned catamorphism Jul 25, 2012
@catamorphism
Copy link
Contributor

I'll take a look at this.

@catamorphism
Copy link
Contributor

FYI, I reproduced this with incoming. I'll investigate further.

@catamorphism
Copy link
Contributor

A more minimal example that pokes the same bug:

use std;

iface siphash {
    fn reset();
}

fn siphash(k0 : u64) -> siphash {
    type sipstate = {
        mut v0 : u64,
    };

   impl of siphash for sipstate {
        fn reset() {
           self.v0 = k0 ^ 0x736f6d6570736575;
        }
    }
    fail;
}

fn main() {}

If I comment out the body of the reset method, it works. It seems that methods in nested impls can't refer to upvars, but I'll keep looking.

@nikomatsakis
Copy link
Contributor

impls, like other items, are certainly not supposed to refer to upvars. I think this constraint is enforced in resolve for nested fns---seems like resolve ought to enforce a similar constraint for impls etc.

@catamorphism
Copy link
Contributor

Ok, I'll look at why resolve isn't doing that, then.

@catamorphism
Copy link
Contributor

I understand what the bug is: resolve was resolving impl methods with a NormalRibKind rather than an OpaqueFunctionRibKind. Fixing that fixed the test case, but then I realized the behavior should be the same for classes and traits (which is currently isn't). That's a problem because the obvious fix stops class methods from being able to refer to their class-bound ty params.

Resolve is doing something weird with def_ids for def_ty_params... so I'm still working on this.

@graydon
Copy link
Contributor

graydon commented Jul 26, 2012

Fwiw siphash itself arrived in libcore yesterday.

@catamorphism
Copy link
Contributor

Fixed in a0d0584

RalfJung pushed a commit to RalfJung/rust that referenced this issue Aug 11, 2023
Use Vec's binary search instead of hand-written one.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-resolve Area: Name/path resolution done by `rustc_resolve` specifically I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

No branches or pull requests

4 participants