Version
main
Platform
Subsystem
ffi
What steps will reproduce the bug?
repro.c
doublemultiply_f64(doublea, doubleb) {
returna*b;
}Compile it with
$ cc -shared -fPIC -o repro.so repro.c # macOS: -o repro.dylib
repro.js
import{dlopen,suffix}from'node:ffi';const{ lib, functions }=dlopen(`./repro.${suffix}`,{multiply_f64: {arguments: ['f64','f64'],return: 'f64'},});functionhot(a,b){returnfunctions.multiply_f64(a,b);}%PrepareFunctionForOptimization(hot);hot(2,3);%OptimizeFunctionOnNextCall(hot);console.log('pre-close:',hot(2,3));// 6, now through the trampolinelib.close();console.log('after close:',hot(2,3));// SIGSEGVRun it with
$ node --no-warnings --experimental-ffi --allow-natives-syntax repro.js
How often does it reproduce? Is there a required condition?
Always
What is the expected behavior? Why is that the expected behavior?
The call after close() throws ERR_FFI_LIBRARY_CLOSED
What do you see instead?
pre-close: 6zsh: segmentation fault (core dumped)
The call after close() throws segmentation fault
Additional information
No response
Version
main
Platform
Subsystem
ffi
What steps will reproduce the bug?
repro.cCompile it with
$ cc -shared -fPIC -o repro.so repro.c # macOS: -o repro.dylibrepro.jsRun it with
How often does it reproduce? Is there a required condition?
Always
What is the expected behavior? Why is that the expected behavior?
The call after
close()throwsERR_FFI_LIBRARY_CLOSEDWhat do you see instead?
The call after
close()throwssegmentation faultAdditional information
No response