Skip to content

Ilooping senders starve other tasks #8827

Closed

Description

@brson

Depending on number of threads and steal results this test case may livelock, and probably exhaust memory:

fn periodical(n: int) -> Port<bool> {
    let (port, chan) = stream();
    do spawn {
        println(fmt!("periodical %d - begin", n));
        loop {
            for _ in range(1, n) {
                println(fmt!("periodical %d - sending...", n));
                chan.send(false);
                println(fmt!("periodical %d - sent", n));
            }
            chan.send(true);
        }
    }
    return port;
}

fn integers() -> Port<int> {
    let (port, chan) = stream();
    do spawn {
        println("integers - begin");
        let mut i = 1;
        loop {
            chan.send(i);
            i = i + 1;
        }
    }
    return port;
}

fn main() {
    let ints = integers();
    let threes = periodical(3);
    let fives = periodical(5);
    for _ in range(1, 100) {
        match (ints.recv(), threes.recv(), fives.recv()) {
            (_, true, true) => println("FizzBuzz"),
            (_, true, false) => println("Fizz"),
            (_, false, true) => println("Buzz"),
            (i, false, false) => println(fmt!("%d", i))
        }
    }
}

Activity

  1. alexcrichton commented on Dec 23, 2013

    @alexcrichton
    Member

    This appears to no longer be a problem. Even if all the prints are removed (which trigger task scheduling), this test completes.

    Flagging as needstest.

  2. added a commit that references this issue on Apr 28, 2014
    35f295d
  3. added a commit that references this issue on Apr 28, 2014
    7a19a82
  4. added a commit that references this issue on May 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions