penumbra-zone / tower-abci

Tower-based ABCI interface.
MIT License
75 stars 24 forks source link

tokio select pre-conditions not stopping a panic #7

Closed tzemanovic closed 2 years ago

tzemanovic commented 2 years ago

The select! pre-conditions in e.g. https://github.com/penumbra-zone/tower-abci/blob/main/src/buffer4/worker.rs#L156 that check that a receiver is Some don't work as expected.

Excerpt from tokio's docs:

  1. Evaluate all provided expressions. If the precondition returns false, disable the branch for the remainder of the current call to select!. Re-entering select! due to a loop clears the “disabled” state.
  2. Aggregate the s from each branch, including the disabled ones. If the branch is disabled, is still evaluated, but the resulting future is not polled.

So even if the pre-condition is false, the expressions are still evaluated and hence panic on the unwrap, e.g.:

Location: /usr/local/rust/cargo/git/checkouts/tower-abci-0d01b039e0b7a0c9/d63c0d0/src/buffer4/worker.rs:156
Message: called `Option::unwrap()` on a `None` value
The application panicked (crashed).