`absl::Uniform(tag, rng, a, b)` has some restrictions on the values it can produce in that it will always be in the range specified by `a` and `b`, but these restrictions can be violated by `absl::MockingBitGen`. This makes it easier than necessary to introduce a bug in tests using a mock RNG. We can fix this by making `MockingBitGen` emit a runtime error if the value produced is out of bounds. Immediately fixing all the internal buggy uses of `MockingBitGen` is currently infeasible, so the plan is this: 1. Add turned-off validation to `MockingBitGen` to avoid the costs of maintaining unsubmitted code. 2. Temporarily migrate the internal buggy use cases to keep the current behavior, to be fixed later. 3. Turn on validation for `MockingBitGen`. 4. Fix the internal buggy use cases over time. --- A few of the different categories of errors I found: - `Call(tag, rng, a, b) -> a or b`, for open/half-open intervals (i.e. incorrect boundary condition). This case happens quite a lot, e.g. by specifying `absl::Uniform<double>(rng, 0, 1)` to return `1.0`. - `Call(tag, rng, 0, 1) -> 42` (i.e. return an arbitrary value). These may be straightforward to fix by just returning an in-range value, or sometimes they are difficult to fix because other data structures depend on those values. PiperOrigin-RevId: 635503223 Change-Id: I9293ab78e79450e2b7b682dcb05149f238ecc550
| Name |
Last commit
|
Last Update |
|---|---|---|
| .. | ||
| BUILD.bazel | Loading commit data... | |
| chi_square.cc | Loading commit data... | |
| chi_square.h | Loading commit data... | |
| chi_square_test.cc | Loading commit data... | |
| distribution_caller.h | Loading commit data... | |
| distribution_test_util.cc | Loading commit data... | |
| distribution_test_util.h | Loading commit data... | |
| distribution_test_util_test.cc | Loading commit data... | |
| explicit_seed_seq.h | Loading commit data... | |
| explicit_seed_seq_test.cc | Loading commit data... | |
| fast_uniform_bits.h | Loading commit data... | |
| fast_uniform_bits_test.cc | Loading commit data... | |
| fastmath.h | Loading commit data... | |
| fastmath_test.cc | Loading commit data... | |
| gaussian_distribution_gentables.cc | Loading commit data... | |
| generate_real.h | Loading commit data... | |
| generate_real_test.cc | Loading commit data... | |
| iostream_state_saver.h | Loading commit data... | |
| iostream_state_saver_test.cc | Loading commit data... | |
| mock_helpers.h | Loading commit data... | |
| mock_overload_set.h | Loading commit data... | |
| mock_validators.h | Loading commit data... | |
| nanobenchmark.cc | Loading commit data... | |
| nanobenchmark.h | Loading commit data... | |
| nanobenchmark_test.cc | Loading commit data... | |
| nonsecure_base.h | Loading commit data... | |
| nonsecure_base_test.cc | Loading commit data... | |
| pcg_engine.h | Loading commit data... | |
| pcg_engine_test.cc | Loading commit data... | |
| platform.h | Loading commit data... | |
| pool_urbg.cc | Loading commit data... | |
| pool_urbg.h | Loading commit data... | |
| pool_urbg_test.cc | Loading commit data... | |
| randen.cc | Loading commit data... | |
| randen.h | Loading commit data... | |
| randen_benchmarks.cc | Loading commit data... | |
| randen_detect.cc | Loading commit data... | |
| randen_detect.h | Loading commit data... | |
| randen_engine.h | Loading commit data... | |
| randen_engine_test.cc | Loading commit data... | |
| randen_hwaes.cc | Loading commit data... | |
| randen_hwaes.h | Loading commit data... | |
| randen_hwaes_test.cc | Loading commit data... | |
| randen_round_keys.cc | Loading commit data... | |
| randen_slow.cc | Loading commit data... | |
| randen_slow.h | Loading commit data... | |
| randen_slow_test.cc | Loading commit data... | |
| randen_test.cc | Loading commit data... | |
| randen_traits.h | Loading commit data... | |
| salted_seed_seq.h | Loading commit data... | |
| salted_seed_seq_test.cc | Loading commit data... | |
| seed_material.cc | Loading commit data... | |
| seed_material.h | Loading commit data... | |
| seed_material_test.cc | Loading commit data... | |
| sequence_urbg.h | Loading commit data... | |
| traits.h | Loading commit data... | |
| traits_test.cc | Loading commit data... | |
| uniform_helper.h | Loading commit data... | |
| uniform_helper_test.cc | Loading commit data... | |
| wide_multiply.h | Loading commit data... | |
| wide_multiply_test.cc | Loading commit data... |