Skip to content

Recursive enum type causes compiler task to run out of stack #1626

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

Closed
jameshfisher opened this issue Jan 24, 2012 · 2 comments
Closed

Recursive enum type causes compiler task to run out of stack #1626

jameshfisher opened this issue Jan 24, 2012 · 2 comments

Comments

@jameshfisher
Copy link

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:

$ 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.)

@jameshfisher
Copy link
Author

Presumably the correct behavior here would be to give an infinite type error. In writing the above, I was thinking in haskell-mode, as may be many others. Back in pointer land, the correct code should, I guess, be:

enum list { nil, cons(int, @list) }

which compiles without error.

@brson
Copy link
Contributor

brson commented Jan 24, 2012

You are correct that this is the same issue as #742, and tag is the old keyword for enum. Somebody should really fix this one as pretty much everyone hits it. Closing as duplicate. Thanks!

@brson brson closed this as completed Jan 24, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants