Skip to content

os: fix abort on negative zero pid or priority - #67651

Open
zelalem61 wants to merge 1 commit into
nodejs:mainfrom
zelalem61:os-negative-zero
Open

zelalem61 wants to merge 1 commit into
nodejs:mainfrom
zelalem61:os-negative-zero

Conversation

@zelalem61

Copy link
Copy Markdown

Description

os.getPriority(-0) and os.setPriority(-0) abort the process because validateInt32() accepts negative zero, but V8's Value::IsInt32() returns false for it, causing the native CHECK in src/node_os.cc to fail.

This PR normalizes the PID and priority arguments using | 0 in lib/os.js before passing them to the native binding, following the approach used in #65888 for the fs module.

A new test/parallel/test-os-negative-zero.js regression test covers os.getPriority(-0), os.setPriority(-0), and os.setPriority(0, -0).

Verification: Reproduced the crashes on Windows 11 using Node.js v24.8.0 and v28.0.0-nightly20261119cdd06876da. I haven't built Node.js locally, so the fix will rely on CI for build and test verification.

Fixes: #67648

AI disclosure: I used AI (Claude Code) to help identify the bug and draft the fix. I reviewed the changes, investigated the root cause, and independently reproduced and verified the issue.

Fixes: nodejs#67648
Assisted-by: Claude Code
Signed-off-by: Zelalem Habtamu <zelalemhab19@gmail.com>
@nodejs-github-bot nodejs-github-bot added needs-ci PRs that need a full CI run. os Issues and PRs related to the os subsystem. labels Nov 20, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Welcome to Node.js, and thank you for your first contribution!

Before review, please take a moment to read:

Please make sure every commit is signed off. For a first pull request, GitHub Actions require collaborator approval and Jenkins CI must be started by a collaborator or triager, so an initial wait is normal.

@codecov

codecov Bot commented Nov 20, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.72%. Comparing base (f0eb690) to head (18f27ad).
⚠️ Report is 9 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #67651   +/-   ##
=======================================
  Coverage   90.72%   90.72%           
=======================================
  Files         801      801           
  Lines      280944   280910   -34     
  Branches    54264    54246   -18     
=======================================
- Hits       254876   254854   -22     
+ Misses      16255    16250    -5     
+ Partials     9813     9806    -7     
Files with missing lines Coverage Δ
lib/os.js 98.62% <100.00%> (+0.01%) ⬆️

... and 43 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. os Issues and PRs related to the os subsystem.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

os: getPriority() and setPriority() abort the process when passed -0

2 participants