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

Calling spawn too many times crashes the program #15895

Closed
tomaka opened this issue Jul 22, 2014 · 2 comments · Fixed by #15944
Closed

Calling spawn too many times crashes the program #15895

tomaka opened this issue Jul 22, 2014 · 2 comments · Fixed by #15944
Labels
A-runtime Area: std's runtime and "pre-main" init for handling backtraces, unwinds, stack overflows

Comments

@tomaka
Copy link
Contributor

tomaka commented Jul 22, 2014

If you use native threads and call spawn() too many times, the program will simply crash with application terminated abnormally with signal 9 (Killed).

Example:

fn main() {
    use std::io::timer;
    use std::iter;

    for i in iter::count(1u, 1) {
        println!("thread num: {}", i);
        spawn(proc() {
            timer::sleep(10000)
        })
    }
}

A try_spawn(proc():Send) -> Result<(), ()> could be a good addition too.

@huonw
Copy link
Member

huonw commented Jul 22, 2014

it seems like it could theoretically be -> IoResult<()> (or at least some more descriptive error type).

@alexcrichton
Copy link
Member

This is a result of the destructor bomb of Task going off too soon. I believe the correct action is being taken because failing to spawn a thread is indicative of an OOM situation which generally involves failing. This is certainly a bug in that it should not cause the runtime to abort, it should be a proper task failure at the very least.

bors added a commit that referenced this issue Jul 30, 2014
Previously both spawning mechanisms were not resilient to task failures which were initiated from the task spawning infrastructure.

Closes #15895
bors added a commit to rust-lang-ci/rust that referenced this issue Nov 16, 2023
…ykril

Diagnose missing assoc items in trait impls
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-runtime Area: std's runtime and "pre-main" init for handling backtraces, unwinds, stack overflows
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants