Skip to content

ffi: validate 'void' as parameter type in getFunction and getFunctions#63504

Open
Anshikakalpana wants to merge 1 commit into
nodejs:mainfrom
Anshikakalpana:ffi-void-parameter
Open

ffi: validate 'void' as parameter type in getFunction and getFunctions#63504
Anshikakalpana wants to merge 1 commit into
nodejs:mainfrom
Anshikakalpana:ffi-void-parameter

Conversation

@Anshikakalpana
Copy link
Copy Markdown
Contributor

Fixes: #63461

Passing 'void' as a parameter type in getFunction or getFunctions triggers an internal assertion instead of a user-friendly error.

In C, void in a parameter list means a function takes no arguments, expressed in Node.js FFI as an empty array []. There is no valid use case for 'void' as a parameter type.

Fix:
add early validation in getFunction and getFunctions that throws ERR_INVALID_ARG_VALUE when 'void' appears in the parameters array, before wrapWithSharedBuffer is called.

@ShogunPanda
Copy link
Copy Markdown
Contributor

No, this is wrong. Don't validate at JS level but within C++ level please.

@Anshikakalpana Anshikakalpana force-pushed the ffi-void-parameter branch 2 times, most recently from 455f25e to 06410ff Compare May 23, 2026 10:19
@Anshikakalpana
Copy link
Copy Markdown
Contributor Author

No, this is wrong. Don't validate at JS level but within C++ level please.

Moved validation into the native FFI signature parsing layer in src/ffi/types.cc as suggested. Also removed the temporary JS-side validation.

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 added the request-ci Add this label to start a Jenkins CI on a PR. label May 23, 2026
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. label May 23, 2026
@nodejs-github-bot
Copy link
Copy Markdown
Collaborator

Fixes: nodejs#63461
Signed-off-by: Anshikakalpana <anshikajain196872@gmail.com>
@codecov
Copy link
Copy Markdown

codecov Bot commented May 23, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.14%. Comparing base (3c2d2e3) to head (618bed6).
⚠️ Report is 169 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #63504      +/-   ##
==========================================
+ Coverage   90.04%   90.14%   +0.10%     
==========================================
  Files         713      718       +5     
  Lines      224484   227989    +3505     
  Branches    42430    42837     +407     
==========================================
+ Hits       202134   205531    +3397     
- Misses      14156    14237      +81     
- Partials     8194     8221      +27     
Files with missing lines Coverage Δ
src/ffi/types.cc 49.67% <100.00%> (+0.76%) ⬆️

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

needs-ci PRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ffi: 'void' as parameter type triggers internal assertion

3 participants