-
Notifications
You must be signed in to change notification settings - Fork 525
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
zhashx_dup() should use previous hashes comparator and key functions? #2144
Comments
Can you send a PR to fix it, please? |
@bluca sure |
chu11
added a commit
to chu11/czmq
that referenced
this issue
Jan 4, 2021
source hash perfectly. It does not duplicate the source hash's hasher function, as the well as the key destructor, duplicator, or comparator. This minimally can lead to unexpected behavior of the duplicate zhashx. At worst it can cause memory corruption, as the default zhashx key destructor is set to zstr_free(). Solution: Copy the source hasher, key destructor, key duplicator, and key comparator over to the newly duplicated zhashx. Fixes zeromq#2144
chu11
added a commit
to chu11/czmq
that referenced
this issue
Jan 4, 2021
source hash perfectly. It does not duplicate the source hash's hasher function, as the well as the key destructor, duplicator, or comparator. This minimally can lead to unexpected behavior of the duplicate zhashx. At worst it can cause memory corruption, as the default zhashx key destructor is set to zstr_free(). Solution: Copy the source hasher, key destructor, key duplicator, and key comparator over to the newly duplicated zhashx. Fixes zeromq#2144
chu11
added a commit
to chu11/czmq
that referenced
this issue
Jan 4, 2021
The zhashx_dup() function does not duplicate the source hash perfectly. It does not duplicate the source hash's hasher function, as the well as the key destructor, duplicator, or comparator. This minimally can lead to unexpected behavior of the duplicate zhashx. At worst it can cause assert/segfault/memory corruption as zhashx defaults access/free unintended memory. Solution: Copy the source hasher, key destructor, key duplicator, and key comparator over to the newly duplicated zhashx. Fixes zeromq#2144
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Recently used
zhashx_dup()
to copy a hash, leading to an assert inzhashx_insert()
while in the middle of the copy iteration inzhashx_dup()
.Eventually, I determined the issue was that we use an alternate setting of the key hasher, comparator, duplicator, and destructor. However in
zhashx_dup()
it does not appear to copy those over. It only copies over the item duplicator/destructor.I think it should be using the same hasher/key functions across the board?
The text was updated successfully, but these errors were encountered: