Skip to content
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

Iterating a range of skiplist may cause memory leaks #671

Closed
sticnarf opened this issue Mar 4, 2021 · 0 comments · Fixed by #673
Closed

Iterating a range of skiplist may cause memory leaks #671

sticnarf opened this issue Mar 4, 2021 · 0 comments · Fixed by #673

Comments

@sticnarf
Copy link
Contributor

sticnarf commented Mar 4, 2021

Code:

use crossbeam_skiplist::SkipSet;

fn main() {
    let set: SkipSet<_> = [1, 3, 5].iter().cloned().collect();
    assert_eq!(set.range(2..4).count(), 1);
    set.insert(3);
}

Run with address sanitizer:

$ RUSTFLAGS='-Z sanitizer=address' cargo run
=================================================================
==1934867==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 24 byte(s) in 1 object(s) allocated from:
    #0 0x55725024bf8d in malloc /rustc/llvm/src/llvm-project/compiler-rt/lib/asan/asan_malloc_linux.cpp:145:3
    #1 0x55725027936e in alloc::alloc::alloc::hcf88d30e57cf3e2a /home/yilin/.rustup/toolchains/nightly-2021-01-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/alloc.rs:86:14
    #2 0x557250284f25 in crossbeam_skiplist::base::Node$LT$K$C$V$GT$::alloc::he004a3fff4341a94 /home/yilin/Code/crossbeam/crossbeam-skiplist/src/base.rs:102:19
    #3 0x557250288fa5 in crossbeam_skiplist::base::SkipList$LT$K$C$V$GT$::insert_internal::h829667128f83af99 /home/yilin/Code/crossbeam/crossbeam-skiplist/src/base.rs:885:25
    #4 0x557250287fa4 in crossbeam_skiplist::base::SkipList$LT$K$C$V$GT$::get_or_insert::h5c252f8a1f57cf55 /home/yilin/Code/crossbeam/crossbeam-skiplist/src/base.rs:474:9
    #5 0x55725026dab1 in crossbeam_skiplist::set::SkipSet$LT$T$GT$::get_or_insert::h4032e246962d79f5 /home/yilin/Code/crossbeam/crossbeam-skiplist/src/set.rs:224:20
    #6 0x55725027b633 in core::iter::traits::iterator::Iterator::collect::hc2b1afd048fa866a /home/yilin/.rustup/toolchains/nightly-2021-01-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/iter/traits/iterator.rs:1765:9
    #7 0x55725027d811 in skiplist_demo::main::ha4dda8363f53ed87 /home/yilin/Scratch/skiplist-demo/src/main.rs:3:27
    #8 0x5572502719da in core::ops::function::FnOnce::call_once::ha570b3b78ebd326e /home/yilin/.rustup/toolchains/nightly-2021-01-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/function.rs:227:5
    #9 0x557250270ca6 in std::rt::lang_start::_$u7b$$u7b$closure$u7d$$u7d$::h079447501dfdfceb /home/yilin/.rustup/toolchains/nightly-2021-01-25-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/rt.rs:66:18

SUMMARY: AddressSanitizer: 24 byte(s) leaked in 1 allocation(s).
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.

2 participants