ffi: reject fast calls after library close - #64860
Open
trivikr wants to merge 1 commit into
Open
Conversation
Collaborator
|
Review requested:
|
Optimized Fast API calls bypass InvokeFunction and can jump directly to a symbol after DynamicLibrary::close() unloads its library. Check the function's closed state in the AArch64 and SysV x64 trampolines before entering the target. If the library is closed, schedule ERR_FFI_LIBRARY_CLOSED and return without calling the symbol. Keep the JavaScript guard on platforms without a native trampoline guard and for signatures that already require argument conversion or validation. This keeps raw scalar fast calls close to their original performance on supported platforms. Signed-off-by: Kamat, Trivikram <16024985+trivikr@users.noreply.github.com> Assisted-by: codex:gpt-5.6-sol
trivikr
force-pushed
the
ffi-closed-lib-cal-sigsegv-3
branch
from
July 31, 2026 04:27
8e91308 to
3b1b100
Compare
ShogunPanda
approved these changes
Jul 31, 2026
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #64860 +/- ##
=======================================
Coverage 90.16% 90.16%
=======================================
Files 746 746
Lines 242760 242845 +85
Branches 45765 45774 +9
=======================================
+ Hits 218875 218972 +97
+ Misses 15375 15355 -20
- Partials 8510 8518 +8
🚀 New features to boost your workflow:
|
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: #64854
Optimized FFI Fast API calls bypass
DynamicLibrary::InvokeFunction()and enter the generated trampoline directly. AfterDynamicLibrary::close()unloads the library, optimized code could call the stale symbol address and crash withSIGSEGV.This adds a closed-state check to the AArch64 and SysV x64 fast trampolines. The hot path continues to the native symbol when the library is open. The cold path schedules
ERR_FFI_LIBRARY_CLOSEDand returns without entering the unloaded library.Assisted-by: codex:gpt-5.6-sol