smol-rs / async-broadcast

Async broadcast channels
Apache License 2.0
163 stars 26 forks source link

InactiveReceiver panics on Drop #13

Closed bltavares closed 3 years ago

bltavares commented 3 years ago

When an InactiveReceiver is cloned, it does not increase the count of inactive receivers, and an error with the recent inactive receiver drop.

thread 'main' panicked at 'attempt to subtract with overflow', C:\Users\bltav\.cargo\registry\src\github.com-1ecc6299db9ec823\async-broadcast-0.3.1\src\lib.rs:1562:13

Reproduced on:

fn main() {
    let (_, active_receiver) = async_broadcast::broadcast::<()>(1);
    let inactive = active_receiver.deactivate();
    let inactive2 = inactive.clone();
    drop(inactive);
    drop(inactive2);
}