Skip to content

ffi: refresh cached string buffers on every call - #65051

Open
trivikr wants to merge 1 commit into
nodejs:mainfrom
trivikr:ffi-temp-string-buffer-reuse
Open

ffi: refresh cached string buffers on every call#65051
trivikr wants to merge 1 commit into
nodejs:mainfrom
trivikr:ffi-temp-string-buffer-reuse

Conversation

@trivikr

@trivikr trivikr commented Aug 5, 2026

Copy link
Copy Markdown
Member

Fixes: #65050

Native code can mutate temporary string storage during an FFI call. Rewrite cached buffers on every conversion so a later call with the same JavaScript string receives a fresh copy of its UTF-8 bytes.


Assisted-by: codex:gpt-5.6-sol

Native code can mutate temporary string storage during an FFI call.
Rewrite cached buffers on every conversion so a later call with the
same JavaScript string receives a fresh copy of its UTF-8 bytes.

Signed-off-by: Kamat, Trivikram <16024985+trivikr@users.noreply.github.com>
Assisted-by: codex:gpt-5.6-sol
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/ffi

@nodejs-github-bot nodejs-github-bot added ffi Issues and PRs related to experimental Foreign Function Interface support. needs-ci PRs that need a full CI run. labels Aug 5, 2026
@codecov

codecov Bot commented Aug 5, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.29%. Comparing base (f7804f7) to head (a88fe4c).
⚠️ Report is 5 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #65051      +/-   ##
==========================================
- Coverage   90.31%   90.29%   -0.02%     
==========================================
  Files         759      759              
  Lines      247618   247623       +5     
  Branches    46694    46693       -1     
==========================================
- Hits       223632   223588      -44     
- Misses      15454    15503      +49     
  Partials     8532     8532              
Files with missing lines Coverage Δ
lib/internal/ffi/fast-api.js 95.54% <ø> (+1.58%) ⬆️

... and 35 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ffi Issues and PRs related to experimental Foreign Function Interface support. needs-ci PRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ffi reuses mutated temporary string buffer without restoring its contents

2 participants