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

assertion failed: !is_undef(wrapped) #8506

Closed
carl-eastlund opened this issue Aug 14, 2013 · 3 comments
Closed

assertion failed: !is_undef(wrapped) #8506

carl-eastlund opened this issue Aug 14, 2013 · 3 comments
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@carl-eastlund
Copy link

I'm running on a Mac, using a checkout of the github sources. I run this command:

RUST_LOG=rustc=1,::rt::backtrace ./inst/bin/rust run ~/Desktop/sample.rs

I get this error message:

task <unnamed> failed at 'assertion failed: !is_undef(wrapped)', /Users/cce/git/rust/src/librustc/middle/trans/adt.rs:562
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=1,::rt::backtrace to get further details and report the results to github.com/mozilla/rust/issues
task <unnamed> failed at 'explicit failure', /Users/cce/git/rust/src/librustc/rustc.rs:371

And the rest is the contents of ~/Desktop/sample.rs:

enum Sexp {
    List(Sexp_List),
    Number(int),
    String(@str)
}

enum Sexp_List {
    Null,
    Cons{head:@Sexp,tail:@Sexp_List}
}

fn main () {
    write_sexp( l(cons(n(1), cons(s(@"two"), null))) );
    println("");
}

fn n(i:int) -> Sexp {Number(i)}
fn s(t:@str) -> Sexp {String(t)}
fn l(s:Sexp_List) -> Sexp{List(s)}
fn cons(x:Sexp, y:Sexp_List) -> Sexp_List {Cons{ head: @x, tail: @y }}
static null : Sexp_List = Null;

fn write_sexp (sexp : Sexp) {
    match sexp {
        List(list) => write_list(list),
        Number(num) => print(std::int::to_str(num)),
        String(st) => print(st),
    }
}

fn write_list (list : Sexp_List) {
    match list {
        Null => print ("()"),
        Cons{ head: hd, tail: tl } => {
            print("(");
            write_sexp(*hd);
            let mut rest = tl;
            loop {
                match *rest {
                    Null => { break; }
                    Cons{ head: hd2, tail: tl2 } => {
                        print(" ");
                        write_sexp(*hd2);
                        rest = tl2;
                        loop;
                    }
                }
            }
            print(")");
        }
    }
}
@carl-eastlund
Copy link
Author

I've simplified the reproducing program:

enum Either {
    One,
    Other{left:@str,right:@str}
}

static one : Either = One;

fn main () {
}

If I remove the Other case, or change its contents to non-pointers, or remove one of its fields, the code compiles and runs successfully. If I remove the static definition of one = One, the code compiles and runs successfully.

@huonw
Copy link
Member

huonw commented Jan 19, 2014

Triage. Example that doesn't require gated features.

#[allow(dead_code)];

enum Either {
    One,
    Other(~int, int)
}

static one : Either = One;

fn main () {}

The things that @carl-eastlund noticed still hold: Other needs to have more than one thing, with at least one a pointer (any of ~, @ or & cause the crash, but * doesn't: so presumably this is caused by something to do with non-nullable pointers).

cc @jld.

@jld
Copy link
Contributor

jld commented Jan 21, 2014

What happens in that case is that adt::trans_const puts a C_null in the field with the pointer and a C_undef in any others; build_const_struct wraps the undef in a layer of struct to distinguish it from the regular undefs used for alignment padding. Except apparently that's not how it works (anymore? ever?), and the wrapped undef actually is undef.

So we could just make those fields null instead, and get rid of the wrapped stuff.

Another approach would be to precompute all the field offsets and const-padding-ness when the adt::Struct is created, instead of testing whether the fields of the const are undef, because we'd want that info anyway for TBAA metadata.

bors added a commit that referenced this issue Mar 6, 2014
@jld jld closed this as completed in d908302 Mar 6, 2014
flip1995 pushed a commit to flip1995/rust that referenced this issue Mar 24, 2022
fix suggestion on `[map_flatten]` being cropped causing possible information loss

fixes rust-lang#8506

Multi-line suggestion given by the lint is missing its bottom part, which could potentially contains useful information about the fix.

---

changelog: [`map_flatten`]: Long suggestions will now be splitup into two help messages
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants