kanidm / concread

Concurrently Readable Data Structures for Rust
Mozilla Public License 2.0
339 stars 15 forks source link

Double-free in HashTrie #92

Closed dswd closed 1 year ago

dswd commented 1 year ago

Hi there,

I wrote some code using HashTrie and I experienced double free errors in my bench runs when calling remove.

Here is my minimal code example:

#![feature(test)]
extern crate test;

use concread::hashtrie::HashTrie;
use test::Bencher;

#[bench]
fn double_free(b: &mut Bencher) {
    let table = HashTrie::new();
    let mut tx = table.write();
    b.iter(|| {
        tx.insert(13, 34);
        tx.remove(&13);
    });
}

I do not see any double-free errors outside of the bencher.

The version of concread I am using is:

name = "concread"
version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5d3d825450e64aece76bdcf5c6d115c454ebb284c892da3e4cc7ff1e62e72069"

and I tried it with two rust versions:

If you want, I can attach the compiled binary and the core dump.

Firstyear commented 1 year ago

Sorry for the delay. I've reproduced and am investigating.

Firstyear commented 1 year ago

@dswd Resolved in 0.4.2. Thank you! I'm very sorry you hit this issue in the first place. It was very subtle indeed.