Version
main
Platform
Subsystem
ffi
What steps will reproduce the bug?
import { DynamicLibrary, suffix } from 'node:ffi';
const lib = new DynamicLibrary(
`test/ffi/fixture_library/build/Release/ffi_test_library.${suffix}`);
const fn = lib.getFunction('pointer_to_usize', {
arguments: ['pointer', 'pointer'],
return: 'u64',
});
function call(p) { return fn(p, 0n); }
const run = (label) => {
for (const v of [-1n, 2n ** 64n + 5n]) {
try { console.log(label, v, call(v)); } catch (e) { console.log(label, v, e.code); }
}
};
run('cold');
%PrepareFunctionForOptimization(call);
call(1n);
%OptimizeFunctionOnNextCall(call);
call(1n);
run('optimized');
Run with
node --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?
Both calls throw ERR_INVALID_ARG_VALUE in both the cold and optimized runs.
What do you see instead?
cold -1n ERR_INVALID_ARG_VALUE
cold 18446744073709551621n ERR_INVALID_ARG_VALUE
optimized -1n 18446744073709551615n
optimized 18446744073709551621n 5n
Additional information
No response
Version
main
Platform
Subsystem
ffi
What steps will reproduce the bug?
Run with
node --allow-natives-syntax repro.jsHow often does it reproduce? Is there a required condition?
Always
What is the expected behavior? Why is that the expected behavior?
Both calls throw
ERR_INVALID_ARG_VALUEin both the cold and optimized runs.What do you see instead?
Additional information
No response