Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

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

Closed
dgryski opened this Issue · 8 comments

4 participants

Damian Gryski Tim Chevalier Niko Matsakis Graydon Hoare
Damian Gryski

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
Tim Chevalier catamorphism was assigned
Tim Chevalier

I'll take a look at this.

Tim Chevalier

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

Tim Chevalier

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.

Niko Matsakis

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.

Tim Chevalier

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

Tim Chevalier

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 Hoare

Fwiw siphash itself arrived in libcore yesterday.

Tim Chevalier catamorphism was unassigned by dgryski
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.