-
Notifications
You must be signed in to change notification settings - Fork 71
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
test-hash-seed fails #231
Comments
So, it seems that the hash seed cannot be guessed anymore? I don't know who to ping about that @nodejs/v8 |
I don't think we have any guarantee on what hashing function / seeds we use internally in V8. |
The test verifies that two Node.js processes do not use the same hash seed. |
I didn't look too deeply into this but that test learns the hash seed by observing insertion time into a Set. It leans heavily on the observation that I was going to suggest starting node with |
I'm able to make the test pass again with the following changes: diff --git a/test/fixtures/guess-hash-seed.js b/test/fixtures/guess-hash-seed.js
index 8d69cf9249..c6166450b4 100644
--- a/test/fixtures/guess-hash-seed.js
+++ b/test/fixtures/guess-hash-seed.js
@@ -67,9 +67,6 @@ function hash_to_bucket(hash, numBuckets) {
function time_set_lookup(set, value) {
const t1 = process.hrtime();
for (let i = 0; i < 100; i++) {
- // annoyingly, SetHas() is JS code and therefore potentially optimizable.
- // However, SetHas() looks up the table using native code, and it seems like
- // that's sufficient to prevent the optimizer from doing anything?
set.has(value);
}
const t = process.hrtime(t1);
@@ -78,6 +75,9 @@ function time_set_lookup(set, value) {
return secs * 1e9 + nanos;
}
+// Prevent optimization of SetHas().
+%NeverOptimizeFunction(time_set_lookup);
+
// Set with 256 buckets; bucket 0 full, others empty
const tester_set_buckets = 256;
const tester_set = new Set();
diff --git a/test/pummel/test-hash-seed.js b/test/pummel/test-hash-seed.js
index 274183d8ce..95ad87d4d8 100644
--- a/test/pummel/test-hash-seed.js
+++ b/test/pummel/test-hash-seed.js
@@ -24,7 +24,14 @@ const requiredCallback = common.mustCall((results) => {
assert.strictEqual(seeds.length, kRepetitions);
});
-const generateSeed = () => execFilePromise(process.execPath, [targetScript]);
+function generateSeed() {
+ return execFilePromise(process.execPath, [
+ // Needed for %NeverOptimizeFunction.
+ '--allow-natives-syntax',
+ targetScript
+ ]);
+}
+
const subprocesses = [...new Array(kRepetitions)].map(generateSeed);
Promise.all(subprocesses) Is that acceptable? |
I guess that will work. |
Done, thank you. |
https://github.com/nodejs/node-v8/runs/7037723725?check_suite_focus=true
The text was updated successfully, but these errors were encountered: