Title: ffi: Detached ArrayBuffers and views are silently converted to null FFI pointers · Issue #65082 · nodejs/node · GitHub
Open Graph Title: ffi: Detached ArrayBuffers and views are silently converted to null FFI pointers · Issue #65082 · nodejs/node
X Title: ffi: Detached ArrayBuffers and views are silently converted to null FFI pointers · Issue #65082 · nodejs/node
Description: Version main Platform macOS 26.6.0 Subsystem ffi What steps will reproduce the bug? repro.c #include
Open Graph Description: Version main Platform macOS 26.6.0 Subsystem ffi What steps will reproduce the bug? repro.c #include
X Description: Version main Platform macOS 26.6.0 Subsystem ffi What steps will reproduce the bug? repro.c #include <stdint.h> uint64_t pointer_to_usize(void* ptr) { return (uint64_t)(uintptr_t)ptr; } repro...
Opengraph URL: https://github.com/nodejs/node/issues/65082
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"ffi: Detached ArrayBuffers and views are silently converted to null FFI pointers","articleBody":"### Version\n\nmain\n\n### Platform\n\n```text\nmacOS 26.6.0\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\nuint64_t pointer_to_usize(void* ptr) {\n return (uint64_t)(uintptr_t)ptr;\n}\n```\n\n`repro.js`\n```js\nimport { resolve } from 'node:path';\nimport { dlopen, suffix, getRawPointer } from 'node:ffi';\n\nconst { lib, functions } = dlopen(\n resolve(`repro.${suffix}`),\n {\n pointer_to_usize: {\n arguments: ['pointer'],\n return: 'u64',\n },\n },\n);\n\nconst arrayBuffer = new ArrayBuffer(8);\nconst typedArray = new Uint8Array(arrayBuffer);\nconst dataView = new DataView(arrayBuffer);\n\nstructuredClone(arrayBuffer, { transfer: [arrayBuffer] });\n\nfunction show(label, operation) {\n try {\n console.log(label, operation());\n } catch (error) {\n console.log(label, error.code);\n }\n}\n\ntry {\n for (const [name, value] of [\n ['ArrayBuffer', arrayBuffer],\n ['Uint8Array', typedArray],\n ['DataView', dataView],\n ]) {\n show(`getRawPointer(${name})`, () => getRawPointer(value));\n show(`pointer_to_usize(${name})`, () =>\n functions.pointer_to_usize(value));\n }\n} finally {\n lib.close();\n}\n```\n\nCommands to run\n```sh\n$ cc -dynamiclib -o repro.dylib repro.c\n$ node --no-warnings --experimental-ffi 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\nEach operation should throw `ERR_INVALID_ARG_VALUE`, consistent with `ExportBytes()` rejecting detached buffers and views.\n\n### What do you see instead?\n\n```console\ngetRawPointer(ArrayBuffer) 0n\npointer_to_usize(ArrayBuffer) 0n\ngetRawPointer(Uint8Array) 0n\npointer_to_usize(Uint8Array) 0n\ngetRawPointer(DataView) 0n\npointer_to_usize(DataView) 0n\n```\n\nAll six operations return `0n`, silently treating detached memory as a null pointer.\n\n### Additional information\n\n_No response_","author":{"url":"https://github.com/trivikr","@type":"Person","name":"trivikr"},"datePublished":"2026-08-06T14:43:01Z","url":"https://github.com/nodejs/node/issues/65082"}
| 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:1fa25db0-8378-34c9-bbef-6fd92786a920 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | CE6C:39A2F9:63CB2A:8515EF:6AED1F4E |
| html-safe-nonce | e3d6f080b47d3cea230f87f1bd72777b915747537b2790c01ddb3d1281d11416 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDRTZDOjM5QTJGOTo2M0NCMkE6ODUxNUVGOjZBRUQxRjRFIiwidmlzaXRvcl9pZCI6IjY4NTQ3Mzc5MzA0MTc0MTM5NjYiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 956214fc28f984363f0b2ba7a06326b29a52a0549e9a02caec4375e95f35b3aa |
| hovercard-subject-tag | issue:5082346738 |
| 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/65082/issue_layout |
| twitter:image | https://opengraph.githubassets.com/0ed203f252101bdc9b9979c46e59d7da27ad408916dbd8062bac984a3b22b554/nodejs/node/issues/65082 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/0ed203f252101bdc9b9979c46e59d7da27ad408916dbd8062bac984a3b22b554/nodejs/node/issues/65082 |
| og:image:alt | Version main Platform macOS 26.6.0 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 | e3e0f7f63e50c6fe879198a93a0a023a648ecc0a5e9bc3b5e033ac57172237e6 |
| 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 | 707a24b346ac8a82878b9c084efaa38a997660cb |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width