Skip to content

Fix an over-eager determinizer hack breaking overlay fuzzer - #5282

Merged
graydon merged 2 commits into
stellar:masterfrom
graydon:fix-overlay-fuzzer-randombytes
May 21, 2026
Merged

graydon merged 2 commits into
stellar:masterfrom
graydon:fix-overlay-fuzzer-randombytes

Conversation

@graydon

@graydon graydon commented May 20, 2026

Copy link
Copy Markdown
Contributor

We have a little hack in Random.cpp that routes to the semi-deterministic global PRNG for drawing random bytes when we're in a fuzzer build. This helps reduce pointless nondeterminism, but we've also in the meantime made the global PRNG main-thread-only (sensibly!) and so this actually hits an assert.

The simplest fix -- and I think entirely adequate since this is a fuzzer-only hack anyways -- is to only do the diversion on the main thread, and let non-main threads (of which there are only a small number of callers, mostly those generating random filenames) keep using the normal-build path of accessing true entropy.

Copilot AI review requested due to automatic review settings May 20, 2026 23:30
sisuresh
sisuresh previously approved these changes May 20, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adjusts the fuzzing-only “determinizer” path in randomBytes() to avoid tripping the main-thread-only assertion in getGlobalRandomEngine(), which was breaking the overlay fuzzer.

Changes:

  • In fuzzing builds, route deterministic byte generation through getGlobalRandomEngine() only when running on the main thread.
  • For non-main threads in fuzzing builds, fall back to randombytes_buf() to avoid the main-thread assertion.
  • Add util/GlobalChecks.h to access threadIsMain().

Comment thread src/crypto/Random.cpp Resolved
@graydon
graydon enabled auto-merge May 20, 2026 23:43
@graydon
graydon added this pull request to the merge queue May 21, 2026
Merged via the queue into stellar:master with commit 6f2cf18 May 21, 2026
54 checks passed
@graydon
graydon deleted the fix-overlay-fuzzer-randombytes branch May 21, 2026 01:01
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.

3 participants