tokio select pre-conditions not stopping a panic
tzemanovic opened this issue · 0 comments
tzemanovic commented
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:
- 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.
- 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).