-
Notifications
You must be signed in to change notification settings - Fork 5
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
Segfault upon destruction using hashmap of hashmaps #2
Comments
Code LGTM, probably you are seeing a double-free since I did not disable copies. |
If you confirm this is the problem I will either disable copies or add copy constructor since that is a relatively new feature in Dlang |
Yes disabling copies provides me with a long list of compilation errors. |
@charlesgregory can you please provide example code of how you are using nested hashmaps to better understand how we can work around this? I am in favor of disabling copies, but we could potentially instead do refcounting |
This could potentially be solved by having special compile time checks for a value type that is another khash instance. Might be difficult. |
Yeah you are constructing the object in the parameter position and it is copied into the function. |
Changing the ctor function signature value parameter to include |
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):
dklib/source/dklib/khash.d
Lines 145 to 147 in 8b3fa92
The
initval
is an empty hashmap.Example:
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.
The text was updated successfully, but these errors were encountered: