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: unlink reference during its destructor #35933

Closed
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 2 additions & 1 deletion src/js_native_api_v8.cc
Expand Up @@ -220,6 +220,8 @@ class RefBase : protected Finalizer, RefTracker {
finalize_hint);
}

virtual ~RefBase() { Unlink(); }

inline void* Data() {
return _finalize_data;
}
Expand All @@ -240,7 +242,6 @@ class RefBase : protected Finalizer, RefTracker {
// the finalizer and _delete_self is set. In this case we
// know we need to do the deletion so just do it.
static inline void Delete(RefBase* reference) {
reference->Unlink();
if ((reference->RefCount() != 0) ||
(reference->_delete_self) ||
(reference->_finalize_ran)) {
Expand Down
2 changes: 0 additions & 2 deletions test/node-api/test_worker_terminate_finalization/test.js
@@ -1,11 +1,9 @@
'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
// Refs: https://github.com/nodejs/node/pull/35777
// Refs: https://github.com/nodejs/node/issues/35778
common.skip('Reference management in N-API leaks memory');

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

Expand Down