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

n-api: revert change to finalisation #35777

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 2 additions & 4 deletions src/js_native_api_v8.cc
Expand Up @@ -228,10 +228,9 @@ class RefBase : protected Finalizer, RefTracker {
// from one of Unwrap or napi_delete_reference.
//
// When it is called from Unwrap or napi_delete_reference we only
// want to do the delete if there is no finalizer or the finalizer has already
// run or cannot have been queued to run (i.e. the reference count is > 0),
// want to do the delete if the finalizer has already run or
// cannot have been queued to run (ie the reference count is > 0),
// otherwise we may crash when the finalizer does run.
//
// If the finalizer may have been queued and has not already run
// delay the delete until the finalizer runs by not doing the delete
// and setting _delete_self to true so that the finalizer will
Expand All @@ -243,7 +242,6 @@ class RefBase : protected Finalizer, RefTracker {
static inline void Delete(RefBase* reference) {
reference->Unlink();
if ((reference->RefCount() != 0) ||
(reference->_finalize_callback == nullptr) ||
(reference->_delete_self) ||
(reference->_finalize_ran)) {
delete reference;
Expand Down
4 changes: 4 additions & 0 deletions test/node-api/test_worker_terminate_finalization/test.js
@@ -1,6 +1,10 @@
'use strict';
const common = require('../../common');

// TODO(addaleax): Run this test once it stops failing under ASAN/valgrind.
// Refs: https://github.com/nodejs/node/issues/34731
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optional non-blocking suggestion: Should the comment mention #35778 as well? And maybe #35777 (this pull request) too?

mhdawson marked this conversation as resolved.
Show resolved Hide resolved
common.skip('Reference management in N-API leaks memory');

const { Worker, isMainThread } = require('worker_threads');

if (isMainThread) {
Expand Down