ffi: prevent premature GC of DynamicLibrary#63024
Open
semimikoh wants to merge 1 commit intonodejs:mainfrom
Open
ffi: prevent premature GC of DynamicLibrary#63024semimikoh wants to merge 1 commit intonodejs:mainfrom
semimikoh wants to merge 1 commit intonodejs:mainfrom
Conversation
Collaborator
|
Review requested:
|
Signed-off-by: semimikoh <ejffjeosms@gmail.com>
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.65% -1.85%
==========================================
Files 358 708 +350
Lines 151574 220376 +68802
Branches 23921 42263 +18342
==========================================
+ Hits 138679 197570 +58891
- Misses 12619 14655 +2036
- Partials 276 8151 +7875
🚀 New features to boost your workflow:
|
ShogunPanda
approved these changes
Apr 29, 2026
Collaborator
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