Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

runtime: deterministic fallback hashes across process boundary #66885

Closed
prattmic opened this issue Apr 18, 2024 · 4 comments
Closed

runtime: deterministic fallback hashes across process boundary #66885

prattmic opened this issue Apr 18, 2024 · 4 comments
Assignees
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. NeedsFix The path to resolution is known, but the work has not been done. release-blocker
Milestone

Comments

@prattmic
Copy link
Member

Map hashes use pre-process unique seeds to ensure that hashes differ across processes: aeskeysched for AES hash, and hashkey for fallback hash. Both are initialized in alginit.

https://go.dev/cl/516860 refactored the rand implementation in the runtime. Initialization of aeskeysched was changed to use bootstrapRand (available early), while hashkey was initialized with rand. rand's seed is not initialized until after alginit, so hashkey ends up with a deterministic value in every single process! Because hashkey is deterministic, so to are all (fallback) hashes.

cc @randall77 @rsc

@prattmic prattmic added NeedsFix The path to resolution is known, but the work has not been done. release-blocker labels Apr 18, 2024
@prattmic prattmic added this to the Go1.23 milestone Apr 18, 2024
@prattmic prattmic self-assigned this Apr 18, 2024
@gopherbot gopherbot added the compiler/runtime Issues related to the Go compiler and/or runtime. label Apr 18, 2024
@prattmic
Copy link
Member Author

@gopherbot Please backport to 1.22. This regression makes map hashes deterministic across processes.

@gopherbot
Copy link
Contributor

Backport issue(s) opened: #66886 (for 1.22).

Remember to create the cherry-pick CL(s) as soon as the patch is submitted to master, according to https://go.dev/wiki/MinorReleases.

@gopherbot
Copy link
Contributor

Change https://go.dev/cl/580136 mentions this issue: runtime: use bootstrapRand to initialize hashkey

@gopherbot
Copy link
Contributor

Change https://go.dev/cl/580018 mentions this issue: [release-branch.go1.22] runtime: use bootstrapRand to initialize hashkey

gopherbot pushed a commit that referenced this issue Apr 26, 2024
The seed for rand is not initialized until after alginit. Before
initialization, rand returns a deterministic sequence, making hashkey
deterministic across processes.

Switch to bootstrapRand, like other early rand calls, such as
initialization of aeskeysched.

For #66885.
Fixes #66886.

Change-Id: I5023a9161232b49fda2ebd1d5f9338bbdd17b1fe
Reviewed-on: https://go-review.googlesource.com/c/go/+/580136
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
(cherry picked from commit 1a3682b)
Reviewed-on: https://go-review.googlesource.com/c/go/+/580018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. NeedsFix The path to resolution is known, but the work has not been done. release-blocker
Projects
None yet
Development

No branches or pull requests

2 participants