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

Tasks should not hold a ref to their parent #1789

Closed
brson opened this issue Feb 9, 2012 · 8 comments
Closed

Tasks should not hold a ref to their parent #1789

brson opened this issue Feb 9, 2012 · 8 comments
Labels
A-runtime Area: std's runtime and "pre-main" init for handling backtraces, unwinds, stack overflows

Comments

@brson
Copy link
Contributor

brson commented Feb 9, 2012

Tasks are reference counted and every child task holds a reference to its parent until the child is destroyed or becomes unsupervised. This could have many bizarre consequences, keeping lots of resources around long after they should be released.

@nikomatsakis
Copy link
Contributor

I am not sure... I rather think that parents with outstanding supervised children should not be considered dead until those children are dead (in particular, they should not send out their join message, because even if they succeed, they may yet fail due to failure propagation). Of course this doesn't mean that the parent's resources shouldn't be collected, but the child will probably need sort of ref.

@brson
Copy link
Contributor Author

brson commented Feb 9, 2012

Yes, failure propagation is the reason this situation exists. Needs some deep thinking all around.

See also #1189 and #1078

@brson
Copy link
Contributor Author

brson commented Feb 9, 2012

I should point out that the reason I brought this up now is because tasks keep their schedulers alive, so now we can have zombie tasks holding onto entire threads.

@ghost ghost assigned brson Apr 12, 2012
@ghost ghost assigned bblum Jul 2, 2012
@bblum
Copy link
Contributor

bblum commented Jul 2, 2012

hope it's ok if I take this out from under you. the new linked failure should subsume this.

@bblum
Copy link
Contributor

bblum commented Jul 17, 2012

Fixing this bug will make this no longer segfault.

const generations: uint = 1024+256+128+49;

fn child_no(x: uint) -> fn~() {
    ret || {
        if x < generations {
            task::spawn(child_no(x+1));
        }
    }
}

fn main() {
    task::spawn(child_no(0));
}

@bblum
Copy link
Contributor

bblum commented Jul 17, 2012

Also, after fixing this, I believe nothing will ever refcount a task apart from itself (well, its sched_loop is the one that derefs it, but same thing)?

I'll leave the refcount in in case it's needed for work stealing, I think. It's an atomic operation but it won't cost anything because it never contends.

@bblum bblum closed this as completed in 4cf6b4d Jul 18, 2012
@bblum
Copy link
Contributor

bblum commented Aug 2, 2012

Note: #2671 required making use of the reference count, so it still isn't deadcode.

@brson
Copy link
Contributor Author

brson commented Aug 2, 2012

I'm glad to see this issue fixed.

@brson brson unassigned bblum Jun 16, 2014
celinval added a commit to celinval/rust-dev that referenced this issue Jun 4, 2024
When running MIR Linker with multiple targets (e.g., unit tests), we
were failing to compile since the call to `cargo rustc` would have
multiple targets.

Invoke separate calls for each target for now.
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

No branches or pull requests

3 participants