You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ffi: getFunctions() can return a wrapper with the wrong signature if a signature getter requests an earlier symbol #67192
import{DynamicLibrary}from'node:ffi';import{strictEqual}from'node:assert';constlib=newDynamicLibrary(null);// Symbols already loaded in the process.letconflicting;const{ abs }=lib.getFunctions({abs: {arguments: ['i32'],return: 'i32'},getlabs(){conflicting=lib.getFunction('abs',{arguments: ['f64'],return: 'f64'});return{arguments: ['i64'],return: 'i64'};},});console.log('same wrapper:',abs===conflicting);console.log('abs(-5):',abs(-5));strictEqual(abs(-5),5);
How often does it reproduce? Is there a required condition?
Always
What is the expected behavior? Why is that the expected behavior?
getFunctions() should throw ERR_INVALID_ARG_VALUE ("Function abs was already requested with a different signature"), so neither console.log nor the assert should run. The assert is only reached because of the bug.
What do you see instead?
same wrapper: trueabs(-5): -5AssertionError [ERR_ASSERTION]: Expected values to be strictly equal:-5 !== 5
Activity