Skip to content

ffi: reject detached ArrayBuffers as pointers - #65083

Open
trivikr wants to merge 5 commits into
nodejs:mainfrom
trivikr:ffi-detached-arraybuffers-null
Open

ffi: reject detached ArrayBuffers as pointers#65083
trivikr wants to merge 5 commits into
nodejs:mainfrom
trivikr:ffi-detached-arraybuffers-null

Conversation

@trivikr

@trivikr trivikr commented Aug 6, 2026

Copy link
Copy Markdown
Member

Fixes: #65082

Reject detached ArrayBuffers and ArrayBuffer views in getRawPointer() and all FFI pointer argument conversion paths, including optimized fast calls. This prevents detached backing stores from being silently passed to native functions as null pointers.


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++. needs-ci PRs that need a full CI run. labels Aug 6, 2026
@trivikr trivikr added ffi Issues and PRs related to experimental Foreign Function Interface support. request-ci Add this label to start a Jenkins CI on a PR. labels Aug 6, 2026
@trivikr
trivikr force-pushed the ffi-detached-arraybuffers-null branch 2 times, most recently from 3713f90 to 6aa48c5 Compare August 7, 2026 02:58
@codecov

codecov Bot commented Aug 7, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 61.97183% with 27 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.30%. Comparing base (a576f1c) to head (99ac691).
⚠️ Report is 7 commits behind head on main.

Files with missing lines Patch % Lines
src/ffi/fast.cc 0.00% 20 Missing ⚠️
lib/internal/ffi/fast-api.js 75.86% 7 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #65083      +/-   ##
==========================================
- Coverage   90.30%   90.30%   -0.01%     
==========================================
  Files         760      760              
  Lines      248526   248595      +69     
  Branches    46886    46911      +25     
==========================================
+ Hits       224439   224496      +57     
- Misses      15515    15528      +13     
+ Partials     8572     8571       -1     
Files with missing lines Coverage Δ
src/ffi/data.cc 75.16% <100.00%> (+1.17%) ⬆️
src/ffi/types.cc 54.20% <100.00%> (+0.82%) ⬆️
lib/internal/ffi/fast-api.js 93.60% <75.86%> (-1.18%) ⬇️
src/ffi/fast.cc 64.12% <0.00%> (-5.64%) ⬇️

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

MILLERMARRU

This comment was marked as low quality.

@trivikr trivikr removed the request-ci Add this label to start a Jenkins CI on a PR. label Aug 10, 2026
@nodejs-github-bot

This comment was marked as outdated.

@nodejs-github-bot

This comment was marked as outdated.

@trivikr
trivikr marked this pull request as draft August 11, 2026 05:17
@trivikr

This comment was marked as outdated.

Reject detached ArrayBuffers and ArrayBuffer views in getRawPointer()
and FFI pointer argument conversion. This prevents detached backing
stores from being silently passed to native functions as null pointers.

Signed-off-by: Kamat, Trivikram <16024985+trivikr@users.noreply.github.com>
Assisted-by: codex:gpt-5.6-sol
Report that the ArrayBuffer is detached instead of describing its
backing store as invalid.

Signed-off-by: Kamat, Trivikram <16024985+trivikr@users.noreply.github.com>
ffi: reject detached ArrayBuffers as pointers

Reject detached ArrayBuffers and ArrayBuffer views in getRawPointer()
and all FFI pointer argument conversion paths, including optimized
fast calls. This prevents detached backing stores from being silently
passed to native functions as null pointers.

Signed-off-by: Kamat, Trivikram <16024985+trivikr@users.noreply.github.com>
Assisted-by: codex:gpt-5.6-sol
@trivikr
trivikr force-pushed the ffi-detached-arraybuffers-null branch from 6aa48c5 to 99ac691 Compare August 11, 2026 05:32
@trivikr
trivikr marked this pull request as ready for review August 11, 2026 05:33
@nodejs-github-bot

This comment was marked as outdated.

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@trivikr
trivikr requested a review from ShogunPanda August 11, 2026 15:26
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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ffi: Detached ArrayBuffers and views are silently converted to null FFI pointers

4 participants