rust-lang / rust

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
96.79k stars 12.5k forks source link

ICE in Earley Parser #2963

Closed eholk closed 12 years ago

eholk commented 12 years ago

This program causes an ICE in the early_parser. It ends up failing an assert of ln > 0u.

macro_rules! move {
    { $x:expr } => { unsafe { let y <- *ptr::addr_of($x); y } }
}

fn switch<T: send, U>(+endp: pipes::recv_packet<T>,
                      f: fn(+option<T>) -> U) -> U {
    f(pipes::try_recv(endp))
}

fn move<T>(-x: T) -> T { x }

macro_rules! follow_alts {
    {
        $id:ident, $($message:ident, $next:ident, $body:expr,
                     ($($pats: ident)+))|+
    } => (
        alt move($id) {
            $(some($message($($pats),+)) {
                let $next = move!{$next};
                $e
            })+
        }
    )
}

macro_rules! follow {
    { 
        $($message:ident$(($($x: ident),+))* => $next:ident $e:expr)+
    } => (|m| follow_alts!{m, $($message, $next, $e, ($($x),+ $next))|+})
}

fn main() { }

fn client_follow(+bank: bank::client::login) {
    import bank::*;

    let bank = client::login(bank, ~"theincredibleholk", ~"1234");
    let bank = switch(bank, follow! {
        ok => connected { connected }
        invalid => _next { fail ~"bank closed the connected" }
    });
}

Here's a partialbacktrace.

(gdb) bt
#0  upcall_fail (expr=0x1009cd200 "Assertion ln > 0u failed", file=0x1009cbff0 "/Users/eholk/Documents/projects/mozilla/rust/src/libsyntax/syntax.rc", line=1) at rust_upcall.cpp:95
#1  0x000000010093c786 in dvec::extensions::pop6678::_38beb4996b23a026::_03 ()
#2  0x000000010093c629 in vec::map6677::_ebfda22dd86673cd::_03 ()
#3  0x000000010093a64c in ext::tt::earley_parser::parse::_b64518845d3ed1cf::_03 ()
#4  0x000000010093db73 in ext::tt::macro_rules::add_new_extension::generic_extension::anon ()
#5  0x000000010093e98d in ext::tt::macro_rules::add_new_extension::anon ()
#6  0x0000000100902ce5 in ext::expand::expand_expr::_bc91e71a52102478::_03 ()
#7  0x00000001009067a5 in ext::expand::expand_crate::anon ()
#8  0x000000010079acfd in fold::ast_fold::meth3905::fold_expr::_446ea95290ef8f5d::_03 ()
#9  0x0000000100777329 in vec::map3204::_eee8c82645f9cfec::_03 ()
#10 0x000000010078d49c in fold::noop_map_exprs::_782b697b7da44a5f::_03 ()
#11 0x0000000100785328 in fold::noop_fold_expr::_53c6ded5b97655ba::_03 ()
#12 0x000000010079477f in fold::wrap3718::anon ()
#13 0x0000000100903405 in ext::expand::expand_expr::_bc91e71a52102478::_03 ()
#14 0x00000001009067a5 in ext::expand::expand_crate::anon ()
#15 0x000000010079acfd in fold::ast_fold::meth3905::fold_expr::_446ea95290ef8f5d::_03 ()
#16 0x000000010078d32a in fold::noop_fold_local::_834569e36112dd45::_03 ()
#17 0x000000010079537f in fold::wrap3751::anon ()
#18 0x000000010079bb4c in fold::ast_fold::meth3912::fold_local::_bbe472b17aef7c3a::_03 ()
#19 0x0000000100777329 in vec::map3204::_eee8c82645f9cfec::_03 ()
#20 0x00000001007840b7 in fold::noop_fold_decl::_1d7d107dc27b92d6::_03 ()
#21 0x000000010079437f in fold::wrap3707::anon ()
#22 0x000000010079ab53 in fold::ast_fold::meth3904::fold_decl::_93bd4fa850b1a954::_03 ()
#23 0x0000000100782af9 in fold::noop_fold_stmt::_f2da7627856ac392::_03 ()
#24 0x0000000100793b7f in fold::wrap3685::anon ()
#25 0x000000010079a6c3 in fold::ast_fold::meth3901::fold_stmt::_c89fca1658b205c4::_03 ()
#26 0x0000000100777329 in vec::map3204::_eee8c82645f9cfec::_03 ()
#27 0x0000000100782790 in fold::noop_fold_block::_b57952945ce2273b::_03 ()
#28 0x000000010079377f in fold::wrap3674::anon ()
#29 0x000000010079a515 in fold::ast_fold::meth3900::fold_block::_8bb4f7de413447a2::_03 ()
#30 0x000000010077e61f in fold::noop_fold_item_underscore::_b85de6394615a81d::_03 ()
#31 0x00000001009b16d9 in __morestack ()

It seems like the problem has something to do with the $(($($x: ident),+))* segment of the follow! macro.

paulstansifer commented 12 years ago

Closed by 9103e43 and f785ccc.