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 has overflowed its stack #10400

Closed
aeqwa opened this issue Nov 10, 2013 · 3 comments
Closed

rustc has overflowed its stack #10400

aeqwa opened this issue Nov 10, 2013 · 3 comments

Comments

@aeqwa
Copy link

aeqwa commented Nov 10, 2013

Guten Tag!
For my project i used the 0.8 version of rust.
After i started to work on a parser module for my project.
rustc crashed at compile time and i decided to go and use the git version now i get an error message.

task 'rustc' has overflowed its stack
[1]    2625 illegal hardware instruction (core dumped)  rustc main.rs

My project compiles without

pub mod parser;

in my main.rs perfectly.

But i don't get an error message, what says what goes wrong.
So I think thats an issue so thats reason you read that.

Thanks for every help on the irc and for my problem!

Sebastian Pielawa

@ben0x539
Copy link
Contributor

The problem appears to be the definition of Node in parser.rs:

pub struct Node {
    token: Token,
    left: Option<Node>,
    right: Option<Node>,
    index: uint
}

That makes for an infinite size struct because every Node contains another two Nodes inside the Option enums there. The standard solution is to use Option<~Node> or similar, so that the size of those fields is fixed by the pointer size rather than recursive. Of course, the issue here is that rustc doesn't catch that which frankly surprises me given that this is pretty much our go-to example for motivating ~ boxes now. ;)

(ps: sorry for the prematurely submitted comment, my fingers slipped)

@aeqwa
Copy link
Author

aeqwa commented Nov 10, 2013

Thank you ben0x539 it works!
But i think the compiler should give the user in that case an error message.

@pnkfelix
Copy link
Member

@aeqwa Yes, it should be. But is not yet so.

closing as duplicate of #3779

flip1995 pushed a commit to flip1995/rust that referenced this issue Mar 10, 2023
…rcho

chore: remove unneeded rustfmt skip

---

The associated rustfmt bug that originally necessitated these skips was resolved a while back, so these are no longer necessary

changelog: none
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

3 participants