-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tools: make code cache and snapshot deterministic
Use a fixed random seed to ensure that the generated sources are identical across runs. The final node binary still reseeds itself on start-up so there should be no security implications caused by predictable random numbers (e.g., `Math.random()`, ASLR, the hash seed, etc.) Fixes: #29108 PR-URL: #29142 Reviewed-By: Gus Caplan <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Anna Henningsen <[email protected]>
- Loading branch information
1 parent
119c4cc
commit 5116a6a
Showing
3 changed files
with
24 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
'use strict'; | ||
|
||
require('../common'); | ||
const assert = require('assert'); | ||
const { spawnSync } = require('child_process'); | ||
|
||
const results = new Set(); | ||
for (let i = 0; i < 10; i++) { | ||
const result = spawnSync(process.execPath, ['-p', 'Math.random()']); | ||
assert.strictEqual(result.status, 0); | ||
results.add(result.stdout.toString()); | ||
} | ||
// It's theoretically possible if _very_ unlikely to see some duplicates. | ||
// Therefore, don't expect that the size of the set is exactly 10 but do | ||
// assume it's > 1 because if you get 10 duplicates in a row you should | ||
// go out real quick and buy some lottery tickets, you lucky devil you! | ||
assert(results.size > 1); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters