You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Oct 22, 2026. It is now read-only.
Repository navigation
This repository was archived by the owner on Oct 22, 2026. It is now read-only.
Mild race condition in secp256k1_context_preallocated_create #351
In this scenario C needlessly waited for A even though the context was initialized. I suggest to use compare exchange to avoid erroneous swapping in the first place.
There's also break missing so B always makes one more iteration of the loop and may even ironically become thread C.
Right, this just seems like "it could be more performant", not a specific bug, if I'm reading your description correctly, which isn't super relevant given its only used in fuzzing and presumably after initial startup things are "warm" and just stay DONE.
Ah, missed that it's only in fuzzing. Not looking immediately suspicious could have some benefit for reviewers too but if nobody wants to bother feel free to close.
We could add a comment, I guess? But, really, std should expose Once even if we don't have the ability to park a thread - the code here is basically the same as the std Once, with the only difference being that we don't park threads and instead busy-loop to avoid using std.
Once in std is actually quite involved. It uses an intrusive linked list to track waiting threads. I think it'd be pretty complicated to make usable without std.
Philosophically I agree with Matt that "it doesn't matter" and also that it's somehow std's fault ;) but there's a straightforward solution so let's just take it.
Activity
elichai commentedon Jan 4, 2022
Just want to note that this is only for the fuzzing configuration
TheBlueMatt commentedon Jan 4, 2022
Right, this just seems like "it could be more performant", not a specific bug, if I'm reading your description correctly, which isn't super relevant given its only used in fuzzing and presumably after initial startup things are "warm" and just stay DONE.
Kixunil commentedon Jan 4, 2022
Ah, missed that it's only in fuzzing. Not looking immediately suspicious could have some benefit for reviewers too but if nobody wants to bother feel free to close.
TheBlueMatt commentedon Jan 4, 2022
We could add a comment, I guess? But, really, std should expose Once even if we don't have the ability to park a thread - the code here is basically the same as the std Once, with the only difference being that we don't park threads and instead busy-loop to avoid using std.
Kixunil commentedon Jan 4, 2022
Onceinstdis actually quite involved. It uses an intrusive linked list to track waiting threads. I think it'd be pretty complicated to make usable withoutstd.TheBlueMatt commentedon Jan 5, 2022
Yes, that's my point, it does the same thing plus parks threads (with relevant tracking to wake them up again).
Kixunil commentedon Jan 5, 2022
The code difference is so large that I'm not sure it'd be reasonable to abstract. And I generally love abstractions.
Anyway I think just changing
swaptocompare_exchangeis better than a comment. :)apoelstra commentedon Jan 5, 2022
I agree with changing
swaptocompare_exchange.Philosophically I agree with Matt that "it doesn't matter" and also that it's somehow
std's fault ;) but there's a straightforward solution so let's just take it.