Title: ffi: Fast API string buffer is corrupted by reentrant callbacks · Issue #64550 · nodejs/node · GitHub
Open Graph Title: ffi: Fast API string buffer is corrupted by reentrant callbacks · Issue #64550 · nodejs/node
X Title: ffi: Fast API string buffer is corrupted by reentrant callbacks · Issue #64550 · 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> #include <string.h> int32_t inner(const char *text) { return (int32_t)str...
Opengraph URL: https://github.com/nodejs/node/issues/64550
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"ffi: Fast API string buffer is corrupted by reentrant callbacks","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#include \u003cstring.h>\n\nint32_t inner(const char *text) {\n return (int32_t)strlen(text);\n}\n\nint32_t outer(const char *text, void (*callback)(void)) {\n callback();\n return strcmp(text, \"OUTER\") == 0;\n}\n```\n\nCompile\n```sh\n$ clang -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 inner: {\n arguments: ['string'],\n return: 'i32',\n },\n // `pointer` keeps this function eligible for the Fast API path.\n outer: {\n arguments: ['string', 'pointer'],\n return: 'i32',\n },\n});\n\nlet nestedLength;\nconst callback = lib.registerCallback(() => {\n nestedLength = functions.inner('INNER');\n});\n\nconsole.log(\n 'outer string unchanged:',\n functions.outer('OUTER', callback),\n);\nconsole.log('nested length:', nestedLength);\n\nlib.unregisterCallback(callback);\nlib.close();\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\nouter string unchanged: 1\nnested length: 5\n```\n\nThe outer string remains valid and unchanged for the entire native call.\n\n### What do you see instead?\n\n```console\nouter string unchanged: 0\nnested length: 5\n```\n\nThe nested call overwrites the outer call’s argument-0 string buffer, so native code sees `\"INNER\"` instead of `\"OUTER\"`\n\n### Additional information\n\n_No response_","author":{"url":"https://github.com/trivikr","@type":"Person","name":"trivikr"},"datePublished":"2026-07-17T03:24:01Z","url":"https://github.com/nodejs/node/issues/64550"}
| 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:cc8cae91-de93-c49b-c8ea-ffcfba6862b2 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | AA26:2884DE:1456EA:1B7E9C:6AED3722 |
| html-safe-nonce | 38fd594eab508510dfbc9685ad116b5e9194e251e17ea9db7a42dae785e8ec2d |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBQTI2OjI4ODRERToxNDU2RUE6MUI3RTlDOjZBRUQzNzIyIiwidmlzaXRvcl9pZCI6IjU1NjE5ODI2NjcyOTM4MDAyMjYiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 71143eab1e21a9f235bcfff924edf32a288de0f622aebe329278b7ba28a67135 |
| hovercard-subject-tag | issue:4907775586 |
| 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/64550/issue_layout |
| twitter:image | https://opengraph.githubassets.com/3ff1497740ab102c7b5c28d2dab3c0c15a7fa88f5b8b9318bf7cc595e11ccefe/nodejs/node/issues/64550 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/3ff1497740ab102c7b5c28d2dab3c0c15a7fa88f5b8b9318bf7cc595e11ccefe/nodejs/node/issues/64550 |
| 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