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

Pipe should get terminated if a blocked receiver is killed & punted awake. #3168

Closed
bblum opened this issue Aug 9, 2012 · 1 comment
Closed
Labels
A-concurrency Area: Concurrency

Comments

@bblum
Copy link
Contributor

bblum commented Aug 9, 2012

I claim the assert at the end here should not trip, yet it does.

fn main() {
    let (c,p) = pipes::stream();
    do task::try {
        let (c2,p2) = pipes::stream();
        do task::spawn {
            p2.recv();
            #error["brother fails"];
            fail;
        }   
        let (c3,p3) = pipes::stream();
        c.send(c3);
        c2.send(());
        #error["child blocks"];
        p3.recv();
    };  
    #error["parent tries"];
    assert !p.recv().try_send(());
}

Output: (note: only the first three lines are nondeterministic)

rust: ~"child blocks"
rust: ~"brother fails"
rust: task failed at 'explicit failure', pipe.rs:8
rust: task failed at 'killed', /home/bblum/rust/src/libcore/pipes.rs:284
rust: ~"parent tries"
rust: task failed at 'Assertion !p.recv().try_send(()) failed', pipe.rs:17
rust: domain main @0xd7eb80 root task failed

This is relevant for mutexes/cvars, exhibited here: https://github.com/mozilla/rust/blob/incoming/src/libcore/sync.rs#L490

I believe the fix should be in fn try_recv; somewhere in the loop, it should use a flagged destructor.

@ghost ghost assigned eholk Aug 9, 2012
@bblum
Copy link
Contributor Author

bblum commented Aug 10, 2012

I bet select() needs a similar change. It will probably have to accumulate destructors for each pipe that it marks itself as blocked on. Or use task::unkillable (maybe also task::rekillable but probably not), and just one destructor to do all of the post-blocked work. I expect the latter will be a lot easier.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-concurrency Area: Concurrency
Projects
None yet
Development

No branches or pull requests

2 participants