-
Notifications
You must be signed in to change notification settings - Fork 171
FinalizationRegistry resource leak? #648
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
Comments
More minimal example: let finrec = new FinalizationRegistry(v => {})
finrec.register({}, {}) // primitive value works okay
throw "boom" |
No test because I can only get it to trigger with qjs, not run-test262, but the problem is that we need to run FinalizationRegistry finalizers before asserting no objects remain. Fixes: quickjs-ng#648
I still trigger that assert from time to time... reopening. |
Note how this now works: let finrec = new FinalizationRegistry(v => {})
let object = {}
finrec.register(object, {})
throw "boom" But this still asserts: let finrec = new FinalizationRegistry(v => {})
finrec.register({}, {})
throw "boom" As does this: let finrec = new FinalizationRegistry(v => {})
let object = {}
finrec.register(object, {})
object = undefined
throw "boom" js_finrec_finalizer only runs runs in the first case. |
|
If you enable leak dumping, what do you see? (Not at the computer now) |
Right, I didn't mention that but it's the heldValue (second argument) that leaks. |
I tracked it down to a regression beginning with commit 61c8fe6. |
Introduced in commit 61c8fe6 from last month that moved the callback into the job queue: 1. It leaked `fre->held_val` when no job was enqueued 2. It fumbled the reference count when enqueuing; JS_EnqueueJob already takes care of incrementing and decrementing it Reverts commit 0a70623 from earlier today because that didn't turn out to be a complete fix. Fixes: quickjs-ng#648
No test because I can only get it to trigger with qjs, not run-test262, but the problem is that we need to run FinalizationRegistry finalizers before asserting no objects remain. Fixes: quickjs-ng/quickjs#648
Introduced in commit 61c8fe6 from last month that moved the callback into the job queue: 1. It leaked `fre->held_val` when no job was enqueued 2. It fumbled the reference count when enqueuing; JS_EnqueueJob already takes care of incrementing and decrementing it Reverts commit 0a70623 from earlier today because that didn't turn out to be a complete fix. Fixes: quickjs-ng/quickjs#648
Opening so I don't forget.
There seems to be a leak caused by FinalizationRegistry. Apply this diff:
And then:
The assert does not trigger when you throw before the call to test_finalization_registry.
The text was updated successfully, but these errors were encountered: