mozilla/rust — Issue #1626: Recursive enum type causes compiler task to run out of stack
Author: eegg
Created: 2012-01-24 01:29:51+00:00
State: open

Any `enum` type that references itself in a constructor appears to cause the compiler to run out of stack. As a simple example, here's `ll.rs`:

enum list { nil, cons(int, list) }
fn main() {}

On compiling with backtrace:

```shell
$ RUST_LOG=rustc=0,::rt::backtrace rustc ll.rs
rust: task eaed20 ran out of stack
/usr/local/bin/../lib/librustrt.so(_ZN9rust_task4failEv+0x25)[0x7f44bdd105f5]
/usr/local/bin/../lib/librustrt.so(+0x199b5)[0x7f44bdd109b5]
/usr/local/bin/../lib/librustrt.so(_ZN9rust_task9new_stackEmPvm+0x3c)[0x7f44bdd10d1c]
/usr/local/bin/../lib/librustrt.so(upcall_s_new_stack+0x1d)[0x7f44bdd1305d]
/usr/local/bin/../lib/librustrt.so(+0x2cd39)[0x7f44bdd23d39]
/usr/local/bin/../lib/librustrt.so(upcall_new_stack+0x42)[0x7f44bdd14192]
/usr/local/bin/../lib/libstd-79ca5fac56b63fde-0.1.so(+0x5d7d5)[0x7f44be6517d5]
/usr/local/bin/../lib/libstd-79ca5fac56b63fde-0.1.so(_ZN3map7chained3get17_b22fd9d6e1cb5e02E+0x1dd)[0x7f44be62173d]
/usr/local/bin/../lib/libstd-79ca5fac56b63fde-0.1.so(+0x4ee94)[0x7f44be642e94]
/usr/local/bin/../lib/librustc-4171d83aef249987-0.1.so(_ZN6middle2ty12tag_variants17_438379e850418683E+0x5c)[0x7f44be06e0bc]
/usr/local/bin/../lib/librustc-4171d83aef249987-0.1.so(_ZN6middle2ty26type_structurally_contains17_ebae492368cb31bcE+0xa5)[0x7f44be060fb5]
/usr/local/bin/../lib/librustc-4171d83aef249987-0.1.so(_ZN6middle2ty26type_structurally_contains17_ebae492368cb31bcE+0x27d)[0x7f44be06118d]
error: internal compiler error unexpected failure
note: The compiler hit an unexpected failure path. This is a bug. Try running with RUST_LOG=rustc=0,::rt::backtrace to get further details and report the results to github.com/mozilla/rust/issues
rust: upcall fail 'explicit failure', src/comp/driver/rustc.rs:176
/usr/local/bin/../lib/librustrt.so(_ZN9rust_task4failEv+0x25)[0x7f44bdd105f5]
/usr/local/bin/../lib/librustrt.so(+0x2cd39)[0x7f44bdd23d39]
/usr/local/bin/../lib/librustrt.so(upcall_fail+0x39)[0x7f44bdd13ad9]
rustc[0x405222]
rustc[0x40545c]
/usr/local/bin/../lib/librustrt.so(task_start_wrapper+0x32)[0x7f44bdd0f812]
rust: domain main @0xe9cc60 root task failed
$ rustc --version
rustc 0.1
host: x86_64-unknown-linux-gnu
$
```

(There appears to be many issues similar to this but I lack the expertise to determine whether they are the same bug. Those issues include #742. Is `tag` an old keyword for `enum`? My compiler doesn't know about it.)