ffi: prevent premature GC of DynamicLibrary#63024
Merged
nodejs-github-bot merged 1 commit intonodejs:mainfrom May 1, 2026
Merged
ffi: prevent premature GC of DynamicLibrary#63024nodejs-github-bot merged 1 commit intonodejs:mainfrom
nodejs-github-bot merged 1 commit intonodejs:mainfrom
Conversation
Collaborator
|
Review requested:
|
875711b to
5d3ffc4
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #63024 +/- ##
==========================================
- Coverage 91.49% 89.64% -1.85%
==========================================
Files 358 708 +350
Lines 151574 220415 +68841
Branches 23921 42272 +18351
==========================================
+ Hits 138679 197596 +58917
- Misses 12619 14675 +2056
- Partials 276 8144 +7868
🚀 New features to boost your workflow:
|
ShogunPanda
approved these changes
Apr 29, 2026
Collaborator
addaleax
approved these changes
Apr 29, 2026
bengl
approved these changes
Apr 29, 2026
Contributor
Author
|
Ready from my side, thanks! |
Signed-off-by: semimikoh <[email protected]>
5d3ffc4 to
0d47435
Compare
Collaborator
Commit Queue failed- Loading data for nodejs/node/pull/63024 ✔ Done loading data for nodejs/node/pull/63024 ----------------------------------- PR info ------------------------------------ Title ffi: prevent premature GC of DynamicLibrary (#63024) ⚠ Could not retrieve the email or name of the PR author's from user's GitHub profile! Branch semimikoh:fix/ffi-premature-library-gc -> nodejs:main Labels c++, author ready, needs-ci, ffi Commits 1 - ffi: prevent premature GC of DynamicLibrary Committers 1 - semimikoh <[email protected]> PR-URL: https://github.com/nodejs/node/pull/63024 Fixes: https://github.com/nodejs/node/issues/63010 Reviewed-By: Paolo Insogna <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Bryan English <[email protected]> ------------------------------ Generated metadata ------------------------------ PR-URL: https://github.com/nodejs/node/pull/63024 Fixes: https://github.com/nodejs/node/issues/63010 Reviewed-By: Paolo Insogna <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Bryan English <[email protected]> -------------------------------------------------------------------------------- ℹ This PR was created on Wed, 29 Apr 2026 05:51:17 GMT ✔ Approvals: 4 ✔ - Paolo Insogna (@ShogunPanda) (TSC): https://github.com/nodejs/node/pull/63024#pullrequestreview-4194878077 ✔ - Anna Henningsen (@addaleax): https://github.com/nodejs/node/pull/63024#pullrequestreview-4197628494 ✔ - Matteo Collina (@mcollina) (TSC): https://github.com/nodejs/node/pull/63024#pullrequestreview-4197975170 ✔ - Bryan English (@bengl): https://github.com/nodejs/node/pull/63024#pullrequestreview-4199352943 ✔ Last GitHub CI successful ℹ Last Full PR CI on 2026-04-29T07:30:26Z: https://ci.nodejs.org/job/node-test-pull-request/73010/ ⚠ Commits were pushed after the last Full PR CI run: ⚠ - ffi: prevent premature GC of DynamicLibrary - Querying data for job/node-test-pull-request/73010/ ✔ Build data downloaded ✔ Last Jenkins CI successful -------------------------------------------------------------------------------- ✔ Aborted `git node land` session in /home/runner/work/node/node/.ncuhttps://github.com/nodejs/node/actions/runs/25205417009 |
Collaborator
Collaborator
Collaborator
|
Landed in 9c01018 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes: #63010
Functions created by
getFunction()do not hold a strong referenceto the owning
DynamicLibrary. V8 may garbage-collect the librarywhile derived functions are still in use, causing spurious
ERR_FFI_LIBRARY_CLOSEDerrors in tight loops.Store a
Global<Object>reference to the library inFFIFunctionInfoso the library remains alive as long as anyderived function exists. The reference is released when the
function is garbage-collected via
CleanupFunctionInfo.Verification