-
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
base: main
Are you sure you want to change the base?
Conversation
…ease_counter_internal fuction in case w!=32 and w!=64
// 0 1 2 3 overflow position | ||
// 1 2 3 0 set-up counter position in engine | ||
// 2 1 0 3 raw_counter_position | ||
int raw_counter_position = (Engine::word_count - overflown_position - 2) % 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.
please, check this line if Engine::word_count - overflown_position - 2
would overflow or is it expected?
also is -2 here only for Engine::word_count = 4?
|
||
// 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; |
What introduces this PR:
w
is not the recommended value (w!=32
andw!=64
)discard_overflow_test
was extended: previously only the second chunk of the counter was overflowing, now introduced the high-level loop, which iterates through the other positions of the counter(3rd and 4th) 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.