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

Stack overflow (still) in `cargo build` #1897

Closed
SimonSapin opened this Issue Aug 12, 2015 · 5 comments

Comments

Projects
None yet
3 participants
@SimonSapin
Copy link
Contributor

SimonSapin commented Aug 12, 2015

When upgrading from Cargo nightly 2015-06-24 to 2015-08-05, Servo hit an issue with the same symptoms as #1875. On Mac (not Linux), cargo build ends with thread '<main>' has overflowed its stack after Updating lines but before any Compiling line in the output.

Upgrading to bfadd9a 2015-08-12, which as far as I can tell includes #1887 which closed #1875, does not fix this for Servo.

I haven’t managed to get a stack trace out of LLDB yet, but I can try some more if it helps.

@olsonjeffery

This comment has been minimized.

Copy link

olsonjeffery commented Aug 14, 2015

Same here, on OSX Yosemite

bash-3.2$ cargo run
    Updating git repository `http://github.com/mattyhall/rs-tiled`
    Updating git repository `https://github.com/netvl/xml-rs.git`

thread '<main>' has overflowed its stack
Illegal instruction: 4
bash-3.2$ ls
#README.org#    Cargo.lock      Cargo.toml      Cargo.toml~     README.org      README.org~     content         src             target
bash-3.2$ cargo --version
cargo 0.4.0-nightly (c033770 2015-08-09) (built 2015-08-09)
bash-3.2$ rustc --version
rustc 1.4.0-nightly (5aca49c69 2015-08-10)
bash-3.2$
@olsonjeffery

This comment has been minimized.

Copy link

olsonjeffery commented Aug 14, 2015

updating to latest nightly seems to have fixed this for me. hm.

@SimonSapin

This comment has been minimized.

Copy link
Contributor Author

SimonSapin commented Aug 15, 2015

@olsonjeffery Which nightly is that? I’m still seeing the issue in 1f24be7 2015-08-13.

@olsonjeffery

This comment has been minimized.

Copy link

olsonjeffery commented Aug 15, 2015

@SimonSapin happy to oblige! btw i'm on the nightly default in multirust.

bash-3.2$ rustc --version
rustc 1.4.0-nightly (e2bebf32f 2015-08-14)
bash-3.2$ cargo --version
cargo 0.5.0-nightly (1f24be7 2015-08-13)

As an aside, I've also noticed the issue was transient when I was experiencing it, and often seemed tied to when cargo was making a trip to github to get dependent crate info.

alexcrichton added a commit to alexcrichton/cargo that referenced this issue Aug 16, 2015

Run cargo with a large stack
There have been a number of reports of Cargo triggering a stack overflow in the
algorithm implemented in `cargo::core::resolve`, and although many attempts have
been made to reduce the stack space of the two relevant recursive functions it
seems likely that this will not always be enough. For now, before moving the
recursion to the heap manually, spawn the main thread with a large stack (e.g.
mirror what the compiler does) to ensure that the same scenarios happen across
platforms at least.

Currently on my machine I get a 2MB stack on Linux and a 512K stack on OSX, so
bumping this up to 8MB should be more than enough for the recursion in this
algorithm. I also hope that with nonzeroing drop a few of the recursive calls
will be able to become tail recursive, which should also help with stack space!

Closes rust-lang#1897
@alexcrichton

This comment has been minimized.

Copy link
Member

alexcrichton commented Aug 16, 2015

The failure mode here is definitely dependent on the system and the size of the dependency graph in question. Servo, for example, has a very large dependency graph and OSX has a smaller default stack size than Linux, which explains the OSX-only failure for what looks like only Servo and also why I didn't catch it on Linux :).

I've submitted #1908 which should fix this for now.

bors added a commit that referenced this issue Aug 17, 2015

Auto merge of #1908 - alexcrichton:moar-stack, r=huonw
There have been a number of reports of Cargo triggering a stack overflow in the
algorithm implemented in `cargo::core::resolve`, and although many attempts have
been made to reduce the stack space of the two relevant recursive functions it
seems likely that this will not always be enough. For now, before moving the
recursion to the heap manually, spawn the main thread with a large stack (e.g.
mirror what the compiler does) to ensure that the same scenarios happen across
platforms at least.

Currently on my machine I get a 2MB stack on Linux and a 512K stack on OSX, so
bumping this up to 8MB should be more than enough for the recursion in this
algorithm. I also hope that with nonzeroing drop a few of the recursive calls
will be able to become tail recursive, which should also help with stack space!

Closes #1897

@bors bors closed this in #1908 Aug 17, 2015

@matthewkmayer matthewkmayer referenced this issue May 20, 2016

Merged

Add `travis-cargo` Support #248

18 of 18 tasks complete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.