Title: ffi: Fast FFI buffer/arraybuffer signatures reject bigint after optimization · Issue #64638 · nodejs/node · GitHub
Open Graph Title: ffi: Fast FFI buffer/arraybuffer signatures reject bigint after optimization · Issue #64638 · nodejs/node
X Title: ffi: Fast FFI buffer/arraybuffer signatures reject bigint after optimization · Issue #64638 · nodejs/node
Description: Version main Platform macOS 26.5.2 Subsystem ffi What steps will reproduce the bug? repro.c #include
Open Graph Description: Version main Platform macOS 26.5.2 Subsystem ffi What steps will reproduce the bug? repro.c #include
X Description: Version main Platform macOS 26.5.2 Subsystem ffi What steps will reproduce the bug? repro.c #include <stdint.h> __attribute__((visibility("default"))) uintptr_t pointer_to_usize(voi...
Opengraph URL: https://github.com/nodejs/node/issues/64638
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"ffi: Fast FFI buffer/arraybuffer signatures reject bigint after optimization","articleBody":"### Version\n\nmain\n\n### Platform\n\n```text\nmacOS 26.5.2\n```\n\n### Subsystem\n\nffi\n\n### What steps will reproduce the bug?\n\n`repro.c`\n```c\n#include \u003cstdint.h>\n\n__attribute__((visibility(\"default\")))\nuintptr_t pointer_to_usize(void* pointer) {\n return (uintptr_t)pointer;\n}\n```\n\nBuild it by running\n```sh\n$ cc -dynamiclib repro.c -o librepro.dylib\n```\n\n`repro.js`\n```js\nimport { dlopen } from \"node:ffi\";\n\nconst { lib, functions } = dlopen(\"./librepro.dylib\", {\n pointer_to_usize: {\n arguments: [\"buffer\"], // Also reproduces with 'arraybuffer'.\n return: \"u64\",\n },\n});\n\nfunction call(value) {\n return functions.pointer_to_usize(value);\n}\n\nconsole.log(\"before:\", call(0n));\n\ntry {\n for (let i = 0; i \u003c 1_000_000; i++)\n call(0n);\n console.log('after:', call(0n));\n} catch (error) {\n console.log('after:', error.code, error.message);\n}\n\nlib.close();\n```\n\nRun it using\n```sh\n$ node --no-warnings --experimental-ffi --allow-natives-syntax repro.js\n```\n\n### How often does it reproduce? Is there a required condition?\n\nAlways\n\n### What is the expected behavior? Why is that the expected behavior?\n\n```console\nbefore: 0n\nafter: 0n\n```\n\nOptimization should not change accepted inputs; `buffer` and `arraybuffer` signatures should continue accepting documented pointer-like values such as `bigint`.\n\n### What do you see instead?\n\n```console\nbefore: 0n\nafter: ERR_INVALID_ARG_VALUE Argument 0 must be a buffer or an ArrayBuffer\n```\n\nThe initial generic call accepts `0n`, but after optimization the same call throws `ERR_INVALID_ARG_VALUE`\n\n### Additional information\n\n_No response_","author":{"url":"https://github.com/trivikr","@type":"Person","name":"trivikr"},"datePublished":"2026-07-21T03:41:41Z","url":"https://github.com/nodejs/node/issues/64638"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:401e39ba-1d21-5e17-09c3-33dbb74b2a1d |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A7EC:37E706:842FF8:AC0980:6AED3623 |
| html-safe-nonce | d629baa5e94c8173a1247ad35f302ee179cf9bd65ff34984927a5fd834eac705 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBN0VDOjM3RTcwNjo4NDJGRjg6QUMwOTgwOjZBRUQzNjIzIiwidmlzaXRvcl9pZCI6IjM0NjY4ODgwNzY4ODc2NjgyNTkiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 57f7bbad4d9bdcef08487442881bdcbcbd3c6118ef030d7390c1dac964a4c6fc |
| hovercard-subject-tag | issue:4935165366 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/nodejs/node/64638/issue_layout |
| twitter:image | https://opengraph.githubassets.com/396c8e07906c5ceb64aa4acdf54dc1cc362f6186720e2b4eb7c62190342b1c0f/nodejs/node/issues/64638 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/396c8e07906c5ceb64aa4acdf54dc1cc362f6186720e2b4eb7c62190342b1c0f/nodejs/node/issues/64638 |
| og:image:alt | Version main Platform macOS 26.5.2 Subsystem ffi What steps will reproduce the bug? repro.c #include |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | trivikr |
| hostname | github.com |
| expected-hostname | github.com |
| None | 26c92a9388ddfad3fa88d132b5d5f0b4747030233dcc4e5efb05f1cbae152184 |
| turbo-cache-control | no-preview |
| go-import | github.com/nodejs/node git https://github.com/nodejs/node.git |
| octolytics-dimension-user_id | 9950313 |
| octolytics-dimension-user_login | nodejs |
| octolytics-dimension-repository_id | 27193779 |
| octolytics-dimension-repository_nwo | nodejs/node |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 27193779 |
| octolytics-dimension-repository_network_root_nwo | nodejs/node |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | c629ad99c254d306375fc8354d04321c2c362236 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width