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

test-finalization-group-error failed on v8 8.4 #156

Closed
gengjiawen opened this issue Apr 15, 2020 · 6 comments
Closed

test-finalization-group-error failed on v8 8.4 #156

gengjiawen opened this issue Apr 15, 2020 · 6 comments

Comments

@gengjiawen
Copy link
Member

This one still failed:
cc @mmarchini

=== release test-finalization-group-error ===
Path: parallel/test-finalization-group-error
--- stdout ---
Mismatched noop function calls. Expected exactly 1, actual 2.
    at Proxy.mustCall (/home/runner/work/node-v8/node-v8/test/common/index.js:328:10)
    at Object.<anonymous> (/home/runner/work/node-v8/node-v8/test/parallel/test-finalization-group-error.js:27:40)
    at Module._compile (internal/modules/cjs/loader.js:1178:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1198:10)
    at Module.load (internal/modules/cjs/loader.js:1027:32)
    at Function.Module._load (internal/modules/cjs/loader.js:923:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
    at internal/main/run_main_module.js:17:47
Command: out/Release/node --expose-gc --harmony-weak-refs /home/runner/work/node-v8/node-v8/test/parallel/test-finalization-group-error.js

Originally posted by @gengjiawen in #155 (comment)

@gengjiawen
Copy link
Member Author

I debugged this, throw is triggered, but uncaughtException not noticed.

const g = new globalThis.FinalizationRegistry(common.mustCallAtLeast(() => {
throw new Error('test');
}, 1));

cc @devsnek @syg

@syg
Copy link

syg commented Apr 21, 2020

Pretty sure this is because you need to change the flag to --harmony-weak-refs-with-cleanup-some. At the last TC39, Apple objected to cleanupSome, so the method was made optional. V8 split out cleanupSome to a different flag so the rest of the API may ship. That test uses cleanupSome, which is no longer exposed by default.

@gengjiawen
Copy link
Member Author

I am aware of that, when I debug, I add --harmony-weak-refs-with-cleanup-some, but the test still failed.

@devsnek
Copy link
Member

devsnek commented Apr 22, 2020

@syg could recent changes (maybe the torque rewrite?) have broken the uncaught exception reporting? there's been a similar issue with microtasks for a while.

@syg
Copy link

syg commented Apr 22, 2020

I debugged this locally. I noticed three issues with node's WeakRef integration. I'm not exactly sure how this test worked before.

  1. The top-level line g.register({}, 42) doesn't actually cause the unreachable {} to be GC-able when calling gc(), so the async task wasn't being scheduled and wasn't running at all. I didn't dig into why exactly, but other V8 tests tend to do the registration in an IIFE, like (function () { g.register({}, 42); })();, which is a more foolproof for causing the object to be collected.

  2. There's a single object registered, and FinalizationRegistry's API has changed to a per-item API. cleanupSome will drain all finalized objects, so if cleanupSome is called, no async task will be scheduled even if the scheduling was working.

  3. As per the the deprecation message for Isolate::SetHostCleanupFinalizationGroupCallback, the scheduling of FinalizationRegistry cleanup tasks is automatic if no host cleanup callback is set. I see that this version of node is still using the hook. Things should "just work" if no hook is set.

Testing weak refs and finalizers is hard, good luck!

@targos
Copy link
Member

targos commented May 13, 2020

This is made obsolete by nodejs/node#33373 which I cherry-picked to canary-base.

@targos targos closed this as completed May 13, 2020
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

No branches or pull requests

4 participants