Skip to content

Conflict between ports and tasks wanting to destroy channels #783

Closed
@brson

Description

@brson

Test case:

use std;
import std::task;

fn a() {
    fn doit() {
        fn b(c: chan[chan[int]]) {
            let p = port[int]();   
            task::send(c, chan(p));
        }
        let p = port[chan[int]]();
        spawn b(chan(p));
        task::recv(p);
    }
    let i = 0;
    while i < 100 {
        doit();
        i += 1;
    }
}

fn main() {
    while (true) {
        let t = spawn a();
        task::join(t);
    }
}

This eventually fail somewhere in the channel destruction path, either from trying to grab a lock that doesn't exist or double freeing memory. I believe it's because the port (on one thread) and the task sending to that port (on another thread) are both trying to destroy the same channel. Run with RUST_THREADS>1.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions