-
-
Notifications
You must be signed in to change notification settings - Fork 142
Open
Description
I just discovered that std::shuffle's implementation is not defined by the standard so its behavior might differ per libc implementation.
Note that the implementation is not dictated by the standard, so even if you use exactly the same RandomFunc or URBG (Uniform Random Number Generator) you may get different results with different standard library implementations.
I am definitely observing different behaviors w/ the same seeds on Windows / Ubuntu. MutationDispatcher::Mutate_ShuffleBytes from libfuzzer uses it which leads to the generation of different testcases even w/ the same seeds, ugh:
size_t MutationDispatcher::Mutate_ShuffleBytes(uint8_t* Data, size_t Size,
size_t MaxSize) {
if (Size > MaxSize || Size == 0) return 0;
size_t ShuffleAmount =
Rand(std::min(Size, (size_t)8)) + 1; // [1,8] and <= Size.
size_t ShuffleStart = Rand(Size - ShuffleAmount);
assert(ShuffleStart + ShuffleAmount <= Size);
std::shuffle(Data + ShuffleStart, Data + ShuffleStart + ShuffleAmount, Rand);
return Size;
}
Metadata
Metadata
Assignees
Labels
No labels