Skip to content

doc,test: mem protection must be observed in ffi#62818

Open
bengl wants to merge 2 commits intonodejs:mainfrom
bengl:bengl/ffi-mem-prot-doc-test
Open

doc,test: mem protection must be observed in ffi#62818
bengl wants to merge 2 commits intonodejs:mainfrom
bengl:bengl/ffi-mem-prot-doc-test

Conversation

@bengl
Copy link
Copy Markdown
Member

@bengl bengl commented Apr 19, 2026

When using ffi.toBuffer, memory protection on any memory pages exposed must be observed by the caller, otherwise crashes will occur.

Now documented, and tested.

@nodejs-github-bot nodejs-github-bot added the needs-ci PRs that need a full CI run. label Apr 19, 2026
@bengl bengl requested a review from ShogunPanda April 19, 2026 14:05
@bengl bengl marked this pull request as ready for review April 19, 2026 14:06
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 19, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.62%. Comparing base (3f52482) to head (48ebb7a).
⚠️ Report is 39 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #62818      +/-   ##
==========================================
- Coverage   91.55%   89.62%   -1.93%     
==========================================
  Files         356      706     +350     
  Lines      149601   219136   +69535     
  Branches    23395    41982   +18587     
==========================================
+ Hits       136967   196407   +59440     
- Misses      12371    14612    +2241     
- Partials      263     8117    +7854     

see 483 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.

@ShogunPanda
Copy link
Copy Markdown
Contributor

ShogunPanda commented Apr 19, 2026

Codewise it LGTM!
Can you expand the documentation just a little bit?
Once CI succeeds I'll be more than happy to approve it!

Comment thread test/ffi/test-ffi-readonly-write.js Outdated
'-p',
`
const ffi = require('node:ffi');
const { functions } = ffi.dlopen('${libraryPath}', ${symbols})
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const { functions } = ffi.dlopen('${libraryPath}', ${symbols})
const { functions } = ffi.dlopen(${JSON.stringify(libraryPath)}, ${symbols})

#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <sys/mman.h>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The #ifdef _WIN32 below this line makes me assume that this file is also compiled on Windows, which means that this include here (and the actual function that was added) should probably be in #ifndef _WIN32 guards?

When using ffi.toBuffer, memory protection on any memory pages exposed
must be observed by the caller, otherwise crashes will occur.

Now documented, and tested.
@bengl bengl force-pushed the bengl/ffi-mem-prot-doc-test branch from 43f68d7 to b448d7f Compare April 20, 2026 02:07
@bengl bengl force-pushed the bengl/ffi-mem-prot-doc-test branch from f3d4109 to 48ebb7a Compare April 20, 2026 03:05
@bengl bengl added the request-ci Add this label to start a Jenkins CI on a PR. label Apr 20, 2026
Copy link
Copy Markdown
Contributor

@ShogunPanda ShogunPanda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@ShogunPanda ShogunPanda removed the request-ci Add this label to start a Jenkins CI on a PR. label Apr 20, 2026
@nodejs-github-bot
Copy link
Copy Markdown
Collaborator

@ShogunPanda
Copy link
Copy Markdown
Contributor

@bengl https://ci.nodejs.org/job/node-test-binary-windows-js-suites/40143/ - This is the only relevant failure.

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

Labels

needs-ci PRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants