Skip to content

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

Closed

Description

@dgryski

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

Activity

  1. catamorphism commented on Jul 25, 2012

    @catamorphism
    Contributor

    I'll take a look at this.

  2. catamorphism commented on Jul 25, 2012

    @catamorphism
    Contributor

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

  3. catamorphism commented on Jul 25, 2012

    @catamorphism
    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.

  4. nikomatsakis commented on Jul 25, 2012

    @nikomatsakis
    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.

  5. catamorphism commented on Jul 25, 2012

    @catamorphism
    Contributor

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

  6. catamorphism commented on Jul 26, 2012

    @catamorphism
    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.

  7. graydon commented on Jul 26, 2012

    @graydon
    Contributor

    Fwiw siphash itself arrived in libcore yesterday.

  8. catamorphism commented on Jul 28, 2012

    @catamorphism
    Contributor

    Fixed in a0d0584

  9. added a commit that references this issue on Aug 11, 2023
  10. added a commit that references this issue on Sep 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-resolveArea: Name/path resolution done by `rustc_resolve` specificallyI-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions