-
Notifications
You must be signed in to change notification settings - Fork 113
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
Fixed coverity issue in Philox RNG engine #1905
Conversation
…ease_counter_internal fuction in case w!=32 and w!=64
|
||
// set the counter which value is 2-chunk bitsize | ||
unsigned long long increment = ((unsigned long long)testedEngine.max() << Engine::word_size) | testedEngine.max(); | ||
unsigned long long counter_increment = increment / 4; |
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.
unsigned long long counter_increment = increment / 4; | |
unsigned long long counter_increment = increment / Engine::word_count; |
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.
Thanks for catching that! Fixed + all unit tests are also extended for Philox 2x*(except for set_counter_conformance_test
as it expects 1955073260
and 3409172418970261260
numbers to be generated as 10000th)
* Other unit tests were extended to check Philox with word_count=2 as well
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.
Looks good to me, thank you!
What introduces this PR:
w
is not the recommended value (w!=32
andw!=64
)discard_overflow_test
was extended: previously only the first chunk of the counter was overflowing, now introduced the high-level loop, which iterates through the other positions of the counter(2nd and 3rd) and also checks for the overflow.counter_management_test
.set_counter
and more complicatedincrease_counter_internal(unsigned long long __z)
which is called bydiscard
2*w
) - this wayincrease_counter_internal
will take__z
that should be placed properly in the 1st chunk and propagated to the 2nd one. The right calculations are checked byreferenceEngine
which is based on simplerset_counter
function.