-
Notifications
You must be signed in to change notification settings - Fork 5
Open
Labels
bugSomething isn't workingSomething isn't working
Description
In trying to make a hashmap of hashmaps using khash.d, I run into the issue of a segfault when using the require function.
Segfault happens here as a double free (I think):
Lines 145 to 147 in 8b3fa92
| kfree(cast(void*) this.keys); | |
| kfree(cast(void*) this.flags); | |
| kfree(cast(void*) this.vals); |
The initval is an empty hashmap.
Example:
auto kmers = khash!(string, khash!(string, int))();
// for loop {
// if not present create empty hash
// initval is empty hashmap
kmers.require(kmer1, khash!(string, int)());
// if not present make count zero
kmers[kmer1].require(kmer2, 0);
kmers[kmer1][kmer2]++;
//}
The fix I found was by removing the free statements in the destructor. My theory is that D's automatic destructor frees the pointers as soon as they are out of scope. Or the other theory is that the empty hashmaps are freed before ever having the pointers set to any memory and are therefore the pointers are null or invalid.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working