-
Notifications
You must be signed in to change notification settings - Fork 219
extrakeys: fix pubkey_sort_cmp test #302
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
Conversation
Instead of providing CTX directly, pass a cmp_data object containing CTX. Otherwise, memory sanitizer fails with "use-of-uninitialized-value".
real-or-random
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
utACK 83d0fa2
| secp256k1_pubkey_sort(CTX, pk_ptr, 5); | ||
| for (j = 1; j < 5; j++) { | ||
| CHECK(secp256k1_pubkey_sort_cmp(&pk_ptr[j - 1], &pk_ptr[j], CTX) <= 0); | ||
| secp256k1_pubkey_sort_cmp_data cmp_data; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I confirmed that declaring the cmp_data variable at the beginning of the function does not cause any issues. This means we do not need to create a new instance for each iteration.
I reviewed the secp256k1_pubkey_sort_cmp function, and it appears that the ctx variable is not utilized within the secp256k1_pubkey_load function. My understanding of this usage is limited, so please correct me if I am mistaken.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's correct that ctx is never used (which is why the old, incorrect code could pass the tests).
As for scoping, IMO we should keep cmp_data as tightly scoped as we can, because it makes the code easier to read.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it, thanks!
apoelstra
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK 83d0fa2; successfully ran local tests
|
I'm gonna go ahead and merge this -- I can't imagine the CI failures are the fault of this PR. |
Instead of providing CTX directly, pass a cmp_data object containing CTX. Otherwise, memory sanitizer fails with "use-of-uninitialized-value".