Skip to content

Update FuzzingBitGen to reduce possible infinite loops.#1991

Open
copybara-service[bot] wants to merge 1 commit intomainfrom
cl/873431571
Open

Update FuzzingBitGen to reduce possible infinite loops.#1991
copybara-service[bot] wants to merge 1 commit intomainfrom
cl/873431571

Conversation

@copybara-service
Copy link
Contributor

@copybara-service copybara-service bot commented Feb 23, 2026

Update FuzzingBitGen to reduce possible infinite loops.

The old FuzzingBitGen algorithm would pull a byte from the head of the data stream to determine whether to return a min or a max, and then it would attempt to pull variate data from the tail of the stream. Once the data stream was expired it would return minimum values from the distributions, which could lead to infinite loops in rejection sampling algorithms.

The updated FuzzingBitGen now takes the following.

  1. Separate control and a data streams (as absl::Span<uint8_t>).
    The control stream indicates whether the distribution functions will return boundary values (min, max, mean) or a value derived from the data stream.
    The data stream provides the actual byte data for generating random values.

  2. A seed for an internal LCG PRNG (as uint64_t).
    When the data stream is exhausted, FuzzingBitGen uses the internal LCG to generate random variates. While the old version had an internal LCG PRNG, those values were not used by the distribution functions.

The basic flow of each variate generation is:

  1. Read a byte from the control stream (in fuzzing_bit_gen).
  2. Depending on the byte, return a min/max/mean/variate, etc.
  3. Once the data stream is expired, use an internal LCG to generate variates.

This update also calls c++ distribution functions in more cases, so that outputs are more aligned with actual distribution behavior.

Adds a test to demonstrate that std::shuffle() is properly manipulated by the fuzzing framework.
Also add additional tests to FuzzingBitGen for the distribution functions.

NOTE: This will change the variates generated by FuzzingBitGen from prior versions.

@copybara-service copybara-service bot force-pushed the cl/873431571 branch 10 times, most recently from 7c98ddf to 1621298 Compare February 23, 2026 23:11
@copybara-service copybara-service bot changed the title No public description Update FuzzingBitGen to take two streams, an instruction stream and a data stream. Feb 23, 2026
@copybara-service copybara-service bot force-pushed the cl/873431571 branch 19 times, most recently from c706205 to a054677 Compare February 27, 2026 01:53
@copybara-service copybara-service bot force-pushed the cl/873431571 branch 27 times, most recently from 79edb5f to 01ea91a Compare March 12, 2026 17:55
@copybara-service copybara-service bot changed the title Update FuzzingBitGen to take two streams, an control stream and a data stream. Update FuzzingBitGen to reduce possible infinite loops. Mar 12, 2026
The old FuzzingBitGen algorithm would pull a byte from the head of the data stream to determine whether to return a min or a max, and then it would attempt to pull variate data from the tail of the stream. Once the data stream was expired it would return minimum values from the distributions, which could lead to infinite loops in rejection sampling algorithms.

The updated FuzzingBitGen now takes the following.
  1. Separate control and a data streams (as absl::Span<uint8_t>).
     The control stream indicates whether the distribution functions will return boundary values (min, max, mean) or a value derived from the data stream.
     The data stream provides the actual byte data for generating random values.

  2. A seed for an internal LCG PRNG (as uint64_t).
     When the data stream is exhausted, FuzzingBitGen uses the internal LCG to generate random variates. While the old version had an internal LCG PRNG, those values were not used by the distribution functions.

The basic flow of each variate generation is:
  1. Read a byte from the control stream (in fuzzing_bit_gen).
  2. Depending on the byte, return a min/max/mean/variate, etc.
  3. Once the data stream is expired, use an internal LCG to generate variates.

This update also calls c++ distribution functions in more cases, so that outputs are more aligned with actual distribution behavior.

Adds a test to demonstrate that std::shuffle() is properly manipulated by the fuzzing framework.
Also add additional tests to FuzzingBitGen for the distribution functions.

NOTE: This will change the variates generated by FuzzingBitGen from prior versions.
PiperOrigin-RevId: 873431571
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant