Skip to content

ffi: reject detached ArrayBufferViews - #65086

Open
trivikr wants to merge 1 commit into
nodejs:mainfrom
trivikr:ffi-export-arraybufferview-detached-handling
Open

ffi: reject detached ArrayBufferViews#65086
trivikr wants to merge 1 commit into
nodejs:mainfrom
trivikr:ffi-export-arraybufferview-detached-handling

Conversation

@trivikr

@trivikr trivikr commented Aug 6, 2026

Copy link
Copy Markdown
Member

Fixes: #65085

Detached ArrayBuffers were rejected with ERR_INVALID_ARG_VALUE, but detached views were not: typed arrays exported zero bytes and DataViews threw a bare TypeError from byteLength.

Track detachment in ArrayBufferViewContents::Read() and skip the JS length check for detached buffers, so every detached input is rejected.


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 c++ Issues and PRs that require attention from people who are familiar with C++. ffi Issues and PRs related to experimental Foreign Function Interface support. needs-ci PRs that need a full CI run. labels Aug 6, 2026
@trivikr
trivikr force-pushed the ffi-export-arraybufferview-detached-handling branch from 989c399 to 6a14197 Compare August 6, 2026 18:25
Detached ArrayBuffers were rejected with ERR_INVALID_ARG_VALUE, but
detached views were not: typed arrays exported zero bytes and DataViews
threw a bare TypeError from byteLength.

Track detachment in ArrayBufferViewContents::Read() and skip the JS
length check for detached buffers, so every detached input is rejected.

Signed-off-by: Kamat, Trivikram <16024985+trivikr@users.noreply.github.com>
Assisted-by: codex:gpt-5.6-sol
@trivikr
trivikr force-pushed the ffi-export-arraybufferview-detached-handling branch from 6a14197 to ebb66f2 Compare August 7, 2026 02:59
@trivikr trivikr added the request-ci Add this label to start a Jenkins CI on a PR. label Aug 7, 2026
@codecov

codecov Bot commented Aug 7, 2026

Copy link
Copy Markdown

Codecov Report

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

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #65086      +/-   ##
==========================================
- Coverage   90.29%   90.29%   -0.01%     
==========================================
  Files         759      759              
  Lines      248295   248307      +12     
  Branches    46861    46855       -6     
==========================================
+ Hits       224205   224207       +2     
  Misses      15517    15517              
- Partials     8573     8583      +10     
Files with missing lines Coverage Δ
lib/ffi.js 95.38% <100.00%> (+0.14%) ⬆️
src/util-inl.h 83.58% <100.00%> (-0.85%) ⬇️

... and 30 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

c++ Issues and PRs that require attention from people who are familiar with C++. ffi Issues and PRs related to experimental Foreign Function Interface support. needs-ci PRs that need a full CI run. request-ci Add this label to start a Jenkins CI on a PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ffi: exportArrayBufferView() inconsistently handles detached views

2 participants