Skip to content

select await deadlocks when a losing branch is blocked in recv(): the ready branch is never taken #1293

Closed

Description

@ehartford

Found rewriting `examples/nebula` under #1150 ruling 4 (its "race data-ready against shutdown" `select await` demo).

```
use std.channel
async fn never -> i32:
let (tx, rx) = chani32
rx.recv().unwrap() // nobody sends: blocks forever
async fn now -> i32: 1
async fn main:
let a = never()
let b = now()
select await:
_ = a => print("never")
_ = b => print("now")
print("after select")
```

Expected (§14.10): `now` wins, the loser is cancelled at its next suspension point, the program prints `now` / `after select` and exits. Actual: nothing is printed and the process never exits (`timeout 10` kills it, rc 124). When both branches are ready (`sel4`: a value sent on both channels first) the select completes normally, so the defect is the runtime's handling of a fiber parked in `recv()` while another branch of the same select is complete — the scheduler does not return to the selecting fiber.

Installed `with v0.15.2.1-g478b26481`. The nebula demo is written with a sleeping loser instead (`sleep(Duration.millis(300)).await`, which needs #1284 for `Duration`) and documents the constraint.

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