Use deterministic randomness fuzzing the pooling allocator (#5247)

This commit updates the index allocation performed in the pooling
allocator with a few refactorings:

* With `cfg(fuzzing)` a deterministic rng is now used to improve
  reproducibility of fuzz test cases.
* The `Mutex` was pushed inside of `IndexAllocator`, renamed from
  `PoolingAllocationState`.
* Randomness is now always done through a `SmallRng` stored in the
  `IndexAllocator` instead of using `thread_rng`.
* The `is_empty` method has been removed in favor of an `Option`-based
  return on `alloc`.

This refactoring is additionally intended to encapsulate more
implementation details of `IndexAllocator` to more easily allow for
alternate implementations in the future such as lock-free approaches
(possibly).
This commit is contained in:
Alex Crichton
2022-11-10 14:53:04 -06:00
committed by GitHub
parent 42e88c7b24
commit 7ec626b898
3 changed files with 141 additions and 125 deletions

View File

@@ -21,7 +21,7 @@ memoffset = "0.6.0"
indexmap = "1.0.2"
thiserror = "1.0.4"
cfg-if = "1.0"
rand = "0.8.3"
rand = { version = "0.8.3", features = ['small_rng'] }
anyhow = { workspace = true }
memfd = "0.6.1"
paste = "1.0.3"