Skip to content

Better error message when the compiler runs out of stack #6455

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
madhuvenu opened this issue May 13, 2013 · 4 comments
Closed

Better error message when the compiler runs out of stack #6455

madhuvenu opened this issue May 13, 2013 · 4 comments
Labels
A-diagnostics Area: Messages for errors, warnings, and lints I-crash Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.

Comments

@madhuvenu
Copy link

Hi,

I am new to rust and was trying to write a simple program when I ran into this failure. The failure message with backtrace enabled is as follows :

RUST_LOG=rustc=1,::rt::backtrace rustc list.rs
rust: task 7f8a7b415f20 ran out of stack
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
rust: task failed at 'explicit failure', /private/tmp/rust-xCH0/rust-0.6/src/librustc/rustc.rc:357
rust: domain main @0x7f8a7b815e10 root task failed

The source code that gets the compiler to fail is pasted below. I realize that I made a mistake by not making the "next" field an owned pointer in the structure below. Correcting this by making "next" an owned pointer using Option<~Node> fixes the problem.

struct Node {
  number : uint,
  next : Option<Node>
}

fn main() {

  let mut head = Node{ number : 0, next : None };
  let mut node  = Node{ number : 10, next : None };
  head.next = Some( node );
}

Is this expected ? Can the compiler instead catch such mistakes instead of running out of stack.

Thanks,
Madhu

@bstrie
Copy link
Contributor

bstrie commented May 14, 2013

What platform are you on and what version of the compiler are you using? When I run the example, I get this instead:

$ rustc 6455.rs
6455.rs:9:10: 9:14 warning: variable does not need to be mutable [-W unused_mut]
6455.rs:9   let mut node  = Node{ number : 10, next : None };
                    ^~~~
Aborted

Which is still bad, but not as bad as an ICE. I'll change the title of this bug to represent that this is a diagnostic error.

@huonw
Copy link
Member

huonw commented May 14, 2013

@bstrie It still crashes, but silently:

$ RUST_LOG=::rt::backtrace rustc 6455.rs
6455.rs:9:10: 9:14 warning: variable does not need to be mutable [-W unused_mut]
6455.rs:9   let mut node  = Node{ number : 10, next : None };
                    ^~~~
rust: task 7f6068204720 ran out of stack

@metajack
Copy link
Contributor

@bstrie It looks to me like that warning is just fine. There's no reason for node to be mut since it is never modified.

@jdm
Copy link
Contributor

jdm commented May 14, 2013

The error here has been reported many other times - the compiler doesn't do a good job of dealing with self-referential types and goes into a tailspin. Duplicate of #4363.

@jdm jdm closed this as completed May 14, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints I-crash Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.
Projects
None yet
Development

No branches or pull requests

5 participants