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

Use of RWArc during unwind after failure poisons it, despite failure not occurring during write #11097

Closed
MicahChalmer opened this issue Dec 21, 2013 · 1 comment · Fixed by #11109

Comments

@MicahChalmer
Copy link
Contributor

If a task fails, and then during the unwind some code in a destructor calls write on a RWArc, the RWArc is poisoned. I think this is a bug. I would expect a failure that happened during one of the closures passed to write to poison it, but not a call to write that happened within a destructor during an unwind from a failure that had already occurred.

Here is some sample code that exhibits the problem--it gives the error message 'Poisoned rw_arc - another task failed inside!' whereas I would expect it to print 5:

extern mod extra;
use extra::arc::RWArc;
use std::task;

struct Unwinder{ i: RWArc<int> }
impl Drop for Unwinder {
    fn drop(&mut self) { 
        self.i.write(|num| {*num += 3;});
    }
}

fn main() {
    let a = RWArc::<int>::new(2);
    let a_copy = a.clone();
    do task::try::<()> {
        let _u = Unwinder{i:a_copy};
        fail!();
    };
    a.write(|num| { println!("{:d}", *num); });
}
@alexcrichton
Copy link
Member

Sounds like a bug!

bors added a commit that referenced this issue Dec 23, 2013
@bors bors closed this as completed in 7a1e486 Dec 23, 2013
flip1995 pushed a commit to flip1995/rust that referenced this issue Feb 8, 2024
Return `Some` from `walk_to_expr_usage` more

fixes rust-lang#11786
supersedes rust-lang#11097

The code removed in the first commit would have needed changes due to the second commit. Since it's useless it just gets removed instead.

changelog: `needless_borrow`: Fix linting in tuple and array expressions.
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

Successfully merging a pull request may close this issue.

2 participants