Fix bug that affects reproducibility (#9176)

I made a mistake when I implemented this workaround:


6e299b2e23/projects/ruby/fuzz_ruby_gems.c (L288-L291)

To ensure that the workaround code won't get dead-code-eliminated by a
clever compiler optimization, I decided to feed bytes from the test data
in as an argument:


6e299b2e23/projects/ruby/fuzz_ruby_gems.c (L404-L406)

But that code only gets run on the first iteration (it's protected by a
static variable). That means that the code behaves differently when
you're trying to reproduce a testcase. This PR fixes the bug by
rewinding the bytestream back to the beginning after it's been used for
the workaround code.
This commit is contained in:
Kevin Backhouse 2022-12-09 21:44:05 +00:00 committed by GitHub
parent ebe05f04ce
commit 182e63729a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 0 deletions

View File

@ -404,6 +404,9 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
uint32_t x = 0;
BytesStream_get_uint32_t(&bs, &x);
workaround_UBSAN_CALLS_THRESHOLD_FOR_UBSAN_BUILD(x);
// Reset the byte stream
ByteStream_init(&bs, data, size);
}
// Choose a function from `target_functions`.