Skip to content

crossbeam-skiplist bug #1023

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
vnt-dev opened this issue Aug 27, 2023 · 4 comments · Fixed by #1101
Closed

crossbeam-skiplist bug #1023

vnt-dev opened this issue Aug 27, 2023 · 4 comments · Fixed by #1101

Comments

@vnt-dev
Copy link

vnt-dev commented Aug 27, 2023

[dependencies]
crossbeam-skiplist = "0.1.1"

fn main() {
    let map: Arc<SkipMap<u32, u32>> = Arc::new(SkipMap::new());
    map.insert(1, 2);
    let map1 = map.clone();
    std::thread::spawn(move||{
        let key = 1;
        for _ in 0..10_0000 {
            let len = map1.len();
            if let Some(entry) = map1.get(&key) {

            }else{
                panic!("len={},key={}",len,key);
            }
            std::thread::sleep(Duration::from_millis(1));
        }
    });
    for _ in 0..10_0000 {
        map.insert(1, 2);
        std::thread::sleep(Duration::from_millis(100));
    }
}

output:

thread '<unnamed>' panicked at 'len=1,key=1', src\main.rs:21:17
stack backtrace:
@taiki-e
Copy link
Member

taiki-e commented Sep 12, 2023

Thanks for the report!

IIUC, insert reduces the refcount of the old value and then sets the new value, so if insert makes the refcount zero, a get that occurs between the time the refcount is reduced and the new value is set will return None because it sees a deleted value with a refcount of zero.

@vnt-dev
Copy link
Author

vnt-dev commented Sep 15, 2023

Do you have any plans to fix it

@taiki-e
Copy link
Member

taiki-e commented Sep 15, 2023

I consider it a bug that needs to be fixed, but I'm not sure if I will be able to work on a fix anytime soon.
It would be great if you or someone else could work on a fix.

Tianion added a commit to Tianion/crossbeam that referenced this issue Apr 12, 2024
@Tianion
Copy link
Contributor

Tianion commented Apr 12, 2024

I consider it a bug that needs to be fixed, but I'm not sure if I will be able to work on a fix anytime soon. It would be great if you or someone else could work on a fix.

I am trying to fix it. #1101

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging a pull request may close this issue.

3 participants