crossbeam-rs / crossbeam

Tools for concurrent programming in Rust
Apache License 2.0
7.48k stars 471 forks source link

skiplist: values are not always dropped #1131

Closed MingweiSamuel closed 3 months ago

MingweiSamuel commented 3 months ago

Seems that sometimes values are never dropped? What exactly are the drop semantics?

use crossbeam_skiplist::SkipMap;

fn main() {
    let map = SkipMap::new();
    for i in 0..200 {
        map.insert(i, LoudDrop(i));
    }
    for i in 0..200 {
        drop(map.remove(&i));
    }
    map.clear();
}

struct LoudDrop(u32);
impl Drop for LoudDrop {
    fn drop(&mut self) {
        println!("DROPPED! {}", self.0);
    }
}

Output:

DROPPED! 0
DROPPED! 1
DROPPED! 2
// ...
DROPPED! 61
DROPPED! 62
DROPPED! 63

And nothing more

MingweiSamuel commented 3 months ago

540 #1126