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

rustc guards ICE: Assertion m.len() > 0u || chk.is_some() failed #3895

Closed
dckc opened this issue Nov 1, 2012 · 5 comments
Closed

rustc guards ICE: Assertion m.len() > 0u || chk.is_some() failed #3895

dckc opened this issue Nov 1, 2012 · 5 comments
Labels
A-codegen Area: Code generation I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Milestone

Comments

@dckc
Copy link
Contributor

dckc commented Nov 1, 2012

$ rustc -v
rustc 0.5 (57b4d10 2012-10-12 16:41:32 -0700)
host: x86_64-unknown-linux-gnu

I don't see how to attach files, so...

RUST_LOG=rustc=0,::rt::backtrace rustc mmfsm.rs --test
rust: task failed at 'Assertion m.len() > 0u || chk.is_some() failed', /home/connolly/src/rust/src/rustc/middle/trans/alt.rs:866
/usr/local/bin/../lib/librustrt.so(_ZN9rust_task13begin_failureEPKcS1_m+0x5d)[0x2b977f842fdd]
/usr/local/bin/../lib/librustrt.so(+0x3325d)[0x2b977f85b25d]
/usr/local/bin/../lib/librustrt.so(upcall_fail+0x1d0)[0x2b977f845930]
/usr/local/bin/../lib/librustc-c84825241471686d-0.5.so(_ZN6middle5trans3alt16compile_submatch16_fb9e6315b8870463_05E+0xa0b)[0x2b977effab2b]
/usr/local/bin/../lib/librustc-c84825241471686d-0.5.so(+0x2370aa)[0x2b977effa0aa]
/usr/local/bin/../lib/librustc-c84825241471686d-0.5.so(_ZN6middle5trans4base9with_cond16_fae091854fffba33_05E+0x143)[0x2b977ef34893]
/usr/local/bin/../lib/librustc-c84825241471686d-0.5.so(_ZN6middle5trans3alt13compile_guard16_5e7459203dd95c83_05E+0x9b1)[0x2b977eff9891]
/usr/local/bin/../lib/librustc-c84825241471686d-0.5.so(_ZN6middle5trans3alt16compile_submatch16_fb9e6315b8870463_05E+0x63a)[0x2b977effa75a]
/usr/local/bin/../lib/librustc-c84825241471686d-0.5.so(_ZN6middle5trans3alt16compile_submatch16_fb9e6315b8870463_05E+0x2c55)[0x2b977effcd75]
/usr/local/bin/../lib/librustc-c84825241471686d-0.5.so(_ZN6middle5trans3alt16compile_submatch16_fb9e6315b8870463_05E+0x2b50)[0x2b977effcc70]
/usr/local/bin/../lib/librustc-c84825241471686d-0.5.so(_ZN6middle5trans3alt16compile_submatch16_fb9e6315b8870463_05E+0x2c55)[0x2b977effcd75]
/usr/local/bin/../lib/librustc-c84825241471686d-0.5.so(_ZN6middle5trans3alt16compile_submatch16_fb9e6315b8870463_05E+0x2c55)[0x2b977effcd75]
/usr/local/bin/../lib/librustc-c84825241471686d-0.5.so(_ZN6middle5trans3alt16compile_submatch16_fb9e6315b8870463_05E+0x2c55)[0x2b977effcd75]
/usr/local/bin/../lib/librustc-c84825241471686d-0.5.so(_ZN6middle5trans3alt16compile_submatch16_fb9e6315b8870463_05E+0x11e6)[0x2b977effb306]
/usr/local/bin/../lib/librustc-c84825241471686d-0.5.so(_ZN6middle5trans3alt15trans_alt_inner16_ad10ecb481ad2223_05E+0x895)[0x2b977efffb15]
/usr/local/bin/../lib/librustc-c84825241471686d-0.5.so(+0x689840)[0x2b977f44c840]
/usr/local/bin/../lib/librustc-c84825241471686d-0.5.so(+0x23c278)[0x2b977efff278]
/usr/local/bin/../lib/librustc-c84825241471686d-0.5.so(_ZN6middle5trans4base10with_scope17_f715e64d24b410333_05E+0x442)[0x2b977ef34fc2]
/usr/local/bin/../lib/librustc-c84825241471686d-0.5.so(_ZN6middle5trans3alt9trans_alt17_4eb9527c11b030193_05E+0x1c5)[0x2b977ef76c45]
/usr/local/bin/../lib/librustc-c84825241471686d-0.5.so(+0x1afdda)[0x2b977ef72dda]
/usr/local/bin/../lib/librustc-c84825241471686d-0.5.so(+0x1ab21e)[0x2b977ef6e21e]
/usr/local/bin/../lib/librustc-c84825241471686d-0.5.so(_ZN6middle5trans4expr14trans_to_datum15_1cbfbbbca52c293_05E+0x434)[0x2b977ef29ba4]
/usr/local/bin/../lib/librustc-c84825241471686d-0.5.so(+0x1aed27)[0x2b977ef71d27]
/usr/local/bin/../lib/librustc-c84825241471686d-0.5.so(_ZN6middle5trans4expr10trans_into16_6c850bd8fee452e3_05E+0x738)[0x2b977ef27338]
/usr/local/bin/../lib/librustc-c84825241471686d-0.5.so(_ZN6middle5trans4base10trans_stmt17_902f2bbc1f1bf65e3_05E+0x3c8)[0x2b977ef269f8]
/usr/local/bin/../lib/librustc-c84825241471686d-0.5.so(_ZN6middle5trans11controlflow11trans_block16_26b9d945b6471483_05E+0x17d)[0x2b977ef250cd]
/usr/local/bin/../lib/librustc-c84825241471686d-0.5.so(_ZN6middle5trans4base10with_scope17_f715e64d24b410333_05E+0x442)[0x2b977ef34fc2]
/usr/local/bin/../lib/librustc-c84825241471686d-0.5.so(+0x1b03ee)[0x2b977ef733ee]
/usr/local/bin/../lib/librustc-c84825241471686d-0.5.so(_ZN6middle5trans4expr10trans_into16_6c850bd8fee452e3_05E+0x69e)[0x2b977ef2729e]
/usr/local/bin/../lib/librustc-c84825241471686d-0.5.so(_ZN6middle5trans11controlflow11trans_block16_26b9d945b6471483_05E+0x1d1)[0x2b977ef25121]
/usr/local/bin/../lib/librustc-c84825241471686d-0.5.so(_ZN6middle5trans4base13trans_closure15_5fd055394070353_05E+0x76b)[0x2b977efbe08b]
/usr/local/bin/../lib/librustc-c84825241471686d-0.5.so(+0x2438c3)[0x2b977f0068c3]
/usr/local/bin/../lib/librustc-c84825241471686d-0.5.so(_ZN6middle5trans7closure13trans_expr_fn15_a663c1c9738d993_05E+0x7f7)[0x2b977ef6bbd7]
/usr/local/bin/../lib/librustc-c84825241471686d-0.5.so(+0x1b013c)[0x2b977ef7313c]
/usr/local/bin/../lib/librustc-c84825241471686d-0.5.so(_ZN6middle5trans4expr10trans_into16_6c850bd8fee452e3_05E+0x69e)[0x2b977ef2729e]
/usr/local/bin/../lib/librustc-c84825241471686d-0.5.so(+0x1b024c)[0x2b977ef7324c]
/usr/local/bin/../lib/librustc-c84825241471686d-0.5.so(+0x1ab21e)[0x2b977ef6e21e]
/usr/local/bin/../lib/librustc-c84825241471686d-0.5.so(_ZN6middle5trans4expr14trans_to_datum15_1cbfbbbca52c293_05E+0x434)[0x2b977ef29ba4]
/usr/local/bin/../lib/librustc-c84825241471686d-0.5.so(_ZN6middle5trans6callee14trans_arg_expr17_1658b0a3d6341f653_05E+0x700)[0x2b977ef69620]
/usr/local/bin/../lib/librustc-c84825241471686d-0.5.so(+0x1a5e7c)[0x2b977ef68e7c]
/usr/local/bin/../lib/librustc-c84825241471686d-0.5.so(_ZN6middle5trans6callee10trans_args16_c46359aa314c3803_05E+0x391)[0x2b977ef68521]
/usr/local/bin/../lib/librustc-c84825241471686d-0.5.so(+0x1a4af9)[0x2b977ef67af9]
/usr/local/bin/../lib/librustc-c84825241471686d-0.5.so(_ZN6middle5trans4base10with_scope17_f715e64d24b410333_05E+0x442)[0x2b977ef34fc2]
/usr/local/bin/../lib/librustc-c84825241471686d-0.5.so(_ZN6middle5trans6callee16trans_call_inner17_bce4bdcb48562e5c3_05E+0x114)[0x2b977ef5c914]
/usr/local/bin/../lib/librustc-c84825241471686d-0.5.so(_ZN6middle5trans6callee10trans_call17_adf4ba1882312adc3_05E+0x281)[0x2b977ef5c7a1]
/usr/local/bin/../lib/librustc-c84825241471686d-0.5.so(+0x1afb3f)[0x2b977ef72b3f]
/usr/local/bin/../lib/librustc-c84825241471686d-0.5.so(+0x689840)[0x2b977f44c840]
/usr/local/bin/../lib/librustc-c84825241471686d-0.5.so(_ZN6middle5trans4expr10trans_into16_6c850bd8fee452e3_05E+0x69e)[0x2b977ef2729e]
/usr/local/bin/../lib/librustc-c84825241471686d-0.5.so(_ZN6middle5trans4base10trans_stmt17_902f2bbc1f1bf65e3_05E+0x3c8)[0x2b977ef269f8]
/usr/local/bin/../lib/librustc-c84825241471686d-0.5.so(_ZN6middle5trans11controlflow11trans_block16_26b9d945b6471483_05E+0x17d)[0x2b977ef250cd]
/usr/local/bin/../lib/librustc-c84825241471686d-0.5.so(_ZN6middle5trans4base13trans_closure15_5fd055394070353_05E+0x76b)[0x2b977efbe08b]
/usr/local/bin/../lib/librustc-c84825241471686d-0.5.so(_ZN6middle5trans4base8trans_fn17_7b6cbffb898dd1b73_05E+0x145)[0x2b977eeb77b5]
/usr/local/bin/../lib/librustc-c84825241471686d-0.5.so(_ZN6middle5trans4base10trans_item16_45a6cab39b2a9983_05E+0x92a)[0x2b977eeb3f2a]
/usr/local/bin/../lib/librustc-c84825241471686d-0.5.so(_ZN6middle5trans4base9trans_mod17_917c80e8ce495a1d3_05E+0x8f)[0x2b977efc536f]
/usr/local/bin/../lib/librustc-c84825241471686d-0.5.so(_ZN6middle5trans4base11trans_crate17_51569cb9b4ec671c3_05E+0x149a)[0x2b977efdeb5a]
/usr/local/bin/../lib/librustc-c84825241471686d-0.5.so(_ZN6driver6driver12compile_upto17_f866b092d9b7dfd43_05E+0x2560)[0x2b977f422ac0]
/usr/local/bin/../lib/librustc-c84825241471686d-0.5.so(+0x689840)[0x2b977f44c840]
/usr/local/bin/../lib/librustc-c84825241471686d-0.5.so(_ZN6driver6driver13compile_input17_c85efee3d65e343b3_05E+0xbd)[0x2b977f424ead]
rustc[0x408eb7]
rustc[0x412214]
rustc[0x40e693]
rustc[0x40d34c]
/usr/local/bin/../lib/libcore-c3ca5d77d81b46c1-0.5.so(+0x7580f)[0x2b977e19b80f]
/usr/local/bin/../lib/libcore-c3ca5d77d81b46c1-0.5.so(+0xb50e0)[0x2b977e1db0e0]
/usr/local/bin/../lib/librustrt.so(_Z18task_start_wrapperP10spawn_args+0x24)[0x2b977f843784]
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', /home/connolly/src/rust/src/rustc/driver/rustc.rs:275
/usr/local/bin/../lib/librustrt.so(_ZN9rust_task13begin_failureEPKcS1_m+0x5d)[0x2b977f842fdd]
/usr/local/bin/../lib/librustrt.so(+0x3325d)[0x2b977f85b25d]
/usr/local/bin/../lib/librustrt.so(upcall_fail+0x1d0)[0x2b977f845930]
rustc(_rust_main+0x838)[0x411a28]
rustc[0x412214]
/usr/local/bin/../lib/librustrt.so(_Z18task_start_wrapperP10spawn_args+0x24)[0x2b977f843784]
rust: domain main @0xf19200 root task failed
rust: task failed at 'killed', /home/connolly/src/rust/src/libcore/task.rs:663
/usr/local/bin/../lib/librustrt.so(_ZN9rust_task13begin_failureEPKcS1_m+0x5d)[0x2b977f842fdd]
/usr/local/bin/../lib/librustrt.so(+0x3325d)[0x2b977f85b25d]
/usr/local/bin/../lib/librustrt.so(upcall_fail+0x1d0)[0x2b977f845930]
/usr/local/bin/../lib/libcore-c3ca5d77d81b46c1-0.5.so(_ZN4task5yield16_9531951b4f79f8b3_05E+0xbd)[0x2b977e184ddd]
/usr/local/bin/../lib/libcore-c3ca5d77d81b46c1-0.5.so(+0x90246)[0x2b977e1b6246]
/usr/local/bin/../lib/libcore-c3ca5d77d81b46c1-0.5.so(_ZN7private11weaken_task16_cf742a1b771015c3_05E+0xd2)[0x2b977e1b6082]
/usr/local/bin/../lib/libcore-c3ca5d77d81b46c1-0.5.so(+0x8ff7b)[0x2b977e1b5f7b]
/usr/local/bin/../lib/libcore-c3ca5d77d81b46c1-0.5.so(+0xb50e0)[0x2b977e1db0e0]
/usr/local/bin/../lib/libcore-c3ca5d77d81b46c1-0.5.so(+0x8f2d0)[0x2b977e1b52d0]
/usr/local/bin/../lib/libcore-c3ca5d77d81b46c1-0.5.so(+0x8ec6e)[0x2b977e1b4c6e]
/usr/local/bin/../lib/libcore-c3ca5d77d81b46c1-0.5.so(+0x8e2d6)[0x2b977e1b42d6]
/usr/local/bin/../lib/libcore-c3ca5d77d81b46c1-0.5.so(+0x7580f)[0x2b977e19b80f]
/usr/local/bin/../lib/libcore-c3ca5d77d81b46c1-0.5.so(+0xb50e0)[0x2b977e1db0e0]
/usr/local/bin/../lib/librustrt.so(_Z18task_start_wrapperP10spawn_args+0x24)[0x2b977f843784]

and the code:

/**
start = space start
      | statement start
      | comment start
      | EOF

statement = '${' space+ | '$}' tspace | keyword_statement
keyword_statement = label? keyword expr proof? '$.' tspace
label = label_char+ space+
keyword = ($a | $p | ...) space+
expr = symbol*
symbol = symbol_char+ space+

comment = '$(' space (not_$) space)* '$)' tspace
ispace = (space+ comment?)*  # inter-token space

tspace = space+ | EOF

proof = '$=' space+ label+ '$'  # TODO: compressed proof
 */
use core::vec::{any};

extern mod std;
use std::rope;

fn each_statement(text: rope::Rope) -> bool {
    enum IsSpace { Space, Printable }
    enum IsLabel { Label, NotLabel }

    enum State {
        Start,
        StLabel,
        StKeyword,
        StExpr,
        TSpace,

        BadChar,  // TODO: line, col?
        BadSyntax, // line, col?
    }

    let mut state = Start;
    let mut ch1 = '\u0000'; // LL(2)

    do rope::loop_chars(text) |ch| {
        let is_space = " \t\r\n\x0A".contains_char(ch);
        let is_label = any(&[('A', 'Z'), ('a', 'z'), ('0', '9')],
                           |r| match r { &(lo, hi) => ch >= lo && ch <= hi })
            || "'-_.".contains_char(ch);

        state = match (state, ch1, ch,
               if (is_space) { Space } else { Printable },
               if (is_label) { Label } else { NotLabel }) {
          (_, _, _, Printable, _) if ch > '\u007F' || ch < ' ' => BadChar,

          (Start, _, _, Space, _) => Start,
          (Start, _, _, _, Label) => StLabel,
          (Start, _, _, _, _) => BadSyntax,  // not implemented

          (StLabel, _, _, _, Label) => StLabel,
          (StLabel, _, _, Space, _) => StKeyword,
          (StLabel, _, _, _, _) => BadSyntax,

          (StKeyword, _, _, Space, _) => StKeyword,
          (StKeyword, '$', 'a', _, _) => StExpr,
          (StKeyword, _, _, _, _) => BadSyntax,

          (StExpr, '$', '.', _, _) => TSpace,
          (StExpr, '$', _, _, _) => BadSyntax,
          (StExpr, _, _, Printable, _) => StExpr,
          (StExpr, _, _, Space, _) => StExpr,

          (TSpace, _, _, Space, _) => TSpace,
          (TSpace, _, _, Printable, _) => BadSyntax,

          (BadChar, _, _, _, _)
          | (BadSyntax, _, _, _, _) => fail fmt!("unexpected state: %?", state)
        };

        ch1 = ch;
        debug!("hi: %c", ch);
        match state {
            BadChar | BadSyntax => false,
            _ => true
        }
    };

    match state {
      TSpace => true,
      _ => false
    }
}

#[cfg(test)]
mod test {
    #[test]
    fn each_statement1() {
        let doc = rope::of_str(@~"axiom.1 $a |- x = x $.");
        each_statement(doc);
    }
}

@dckc
Copy link
Contributor Author

dckc commented Nov 1, 2012

Reducing the complexity of the tuple is no help:

use core::vec::{any};

extern mod std;
use std::rope;

fn each_statement(text: rope::Rope) -> bool {
    enum IsSpace { Space, Printable }

    enum State {
        Start,
        StLabel,
        StKeyword,
        StExpr,
        TSpace,

        BadChar,  // TODO: line, col?
        BadSyntax, // line, col?
    }

    let mut state = Start;
    let mut ch1 = '\u0000'; // LL(2)

    do rope::loop_chars(text) |ch| {
        let cclass = if(" \t\r\n\x0A".contains_char(ch))
                        { Space } else { Printable };
        let is_label = any(&[('A', 'Z'), ('a', 'z'), ('0', '9')],
                           |r| match r { &(lo, hi) => ch >= lo && ch <= hi })
            || "'-_.".contains_char(ch);

        state = match (state, cclass) {
          (_, Printable) if ch > '\u007F' || ch < ' ' => BadChar,

          (Start, Space) => Start,
          (Start, _) if is_label => StLabel,
          (Start, _) => BadSyntax,  // not implemented

          (StLabel, _) if is_label => StLabel,
          (StLabel, Space) => StKeyword,
          (StLabel, _) => BadSyntax,

          (StKeyword, Space) => StKeyword,
          (StKeyword, _) if ch1 == '$' && ch == 'a' => StExpr,
          (StKeyword, _) => BadSyntax,

          (StExpr, _) if ch1 == '$' && ch == '.' => TSpace,
          (StExpr, _) if ch1 == '$' => BadSyntax,
          (StExpr, _) => StExpr,

          (TSpace, Space) => TSpace,
          (TSpace, Printable) => BadSyntax,  // not implemented

          (BadChar, _)
          | (BadSyntax, _) => fail fmt!("unexpected state: %?", state)
        };

        ch1 = ch;
        debug!("hi: %c", ch);
        match state {
            BadChar | BadSyntax => false,
            _ => true
        }
    };

    match state {
      TSpace => true,
      _ => false
    }
}

#[cfg(test)]
mod test {
    #[test]
    fn each_statement1() {
        let doc = rope::of_str(@~"axiom.1 $a |- x = x $.");
        each_statement(doc);
    }
}

@dckc
Copy link
Contributor Author

dckc commented Nov 1, 2012

eliminating guards makes the problem go away

use core::vec::{any};

extern mod std;
use std::rope;

fn each_statement(text: rope::Rope) -> bool {
    enum CharClass { Space, Printable, BadChar }

    enum State {
        Start,
        StLabel,
        StKeyword,
        StExpr,
        TSpace,

        BadSyntax, // line, col?
    }

    let mut state = Start;
    let mut ch1 = '\u0000'; // LL(2)

    do rope::loop_chars(text) |ch| {
        let cclass =
            if(" \t\r\n\x0A".contains_char(ch)) { Space }
            else if (ch > '\u007F' || ch < ' ') { BadChar }
            else { Printable };

        let is_label = any(&[('A', 'Z'), ('a', 'z'), ('0', '9')],
                           |r| match r { &(lo, hi) => ch >= lo && ch <= hi })
            || "'-_.".contains_char(ch);

        state = match (state, cclass, is_label, ch1, ch) {
          (_, BadChar, _, _, _) => BadSyntax,

          (Start, Space, _, _, _) => Start,
          (Start, Printable, true, _, _) => StLabel,
          (Start, _, _, _, _) => BadSyntax,  // not implemented

          (StLabel, Printable, true, _, _) => StLabel,
          (StLabel, Space, _, _, _) => StKeyword,
          (StLabel, _, _, _, _) => BadSyntax,

          (StKeyword, Space, _, _, _) => StKeyword,
          (StKeyword, Printable, _, '$', 'a') => StExpr,
          (StKeyword, _, _, _, _) => BadSyntax,

          (StExpr, _, _, '$', '.') => TSpace,
          (StExpr, _, _, '$', _)  => BadSyntax,
          (StExpr, _, _, _, _) => StExpr,

          (TSpace, Space, _, _, _) => TSpace,
          (TSpace, Printable, _, _, _) => BadSyntax,  // not implemented

          (BadSyntax, _, _, _, _) => fail fmt!("unexpected state: %?", state)
        };

        ch1 = ch;
        debug!("hi: %c", ch);
        match state {
            BadSyntax => false,
            _ => true
        }
    };

    match state {
      TSpace => true,
      _ => false
    }
}

#[cfg(test)]
mod test {
    #[test]
    fn each_statement1() {
        let doc = rope::of_str(@~"axiom.1 $a |- x = x $.");
        each_statement(doc);
    }
}

@catamorphism
Copy link
Contributor

Could be related to #2869

@catamorphism
Copy link
Contributor

Minimized version:

fn main() {
    enum State { BadChar, BadSyntax }

    match BadChar {
        _ if true => BadChar,
        BadChar | BadSyntax => fail
    };
}

I'm still not sure if this is a dup of #2869 or not. The combination of a disjunctive pattern and a guard in a different pattern seems to be essential.

@ghost ghost assigned catamorphism Dec 8, 2012
@catamorphism
Copy link
Contributor

This is indeed a dup of #2869.

RalfJung pushed a commit to RalfJung/rust that referenced this issue Oct 5, 2024
Implement LLVM x86 gfni intrinsics
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-codegen Area: Code generation I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

No branches or pull requests

2 participants