Skip to content

Audit cases of "tokio::mpsc::channel, size of 1" #9272

@smklein

Description

@smklein

For background, see: #9259

Any case where we create a tokio::mpsc::channel of size 1, we are subsequently vulnerable to deadlock with the following code:

loop {
  tokio::select! {
    // Suppose this is queued first, but is only returning `Poll::pending`
    _ = rx.send(...) => { return }
    // Suppose instead, this select! branch triggers...
    _ = yield_interval.tick() => {
      // ... Then this call to `send` will be stuck forever, queued behind the first rx.send,
      // which is no longer polled.
      let result = rx.send(...).await;
      if result = ... { return }
    }
  }
}

This issue will document cases where we're using mpscs, and risking this behavior.

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