Skip to content

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

@MicahChalmer

Description

@MicahChalmer

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); });
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions