Skip to content

src: avoid use-after-close of delayed task scheduler async handle#64492

Open
PickBas wants to merge 1 commit into
nodejs:mainfrom
JaneaSystems:issue-64322
Open

src: avoid use-after-close of delayed task scheduler async handle#64492
PickBas wants to merge 1 commit into
nodejs:mainfrom
JaneaSystems:issue-64322

Conversation

@PickBas

@PickBas PickBas commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

src: avoid use-after-close of delayed task scheduler async handle

A worker thread posting a delayed task while the platform is shutting down could call uv_async_send() on the scheduler's async handle after Stop() began closing it, aborting with Assertion failed: !(handle->flags & UV_HANDLE_CLOSING).

This adds a stopped_ flag, guarded by the existing task queue lock, so late PostDelayedTask() calls are dropped instead of racing the handle close. Includes a cctest reproducing the shutdown race.

Fixes: #64322

@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 Jul 14, 2026
Fixes: nodejs#64322
Signed-off-by: StefanStojanovic <stefan.stojanovic@janeasystems.com>
Co-authored-by: Kirill Saied <sayed.kirill@gmail.com>
@codecov

codecov Bot commented Jul 14, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 75.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 90.23%. Comparing base (4140d4c) to head (80d2173).
⚠️ Report is 37 commits behind head on main.

Files with missing lines Patch % Lines
src/node_platform.cc 75.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #64492      +/-   ##
==========================================
- Coverage   90.25%   90.23%   -0.02%     
==========================================
  Files         741      741              
  Lines      241216   241692     +476     
  Branches    45442    45552     +110     
==========================================
+ Hits       217713   218101     +388     
- Misses      15079    15101      +22     
- Partials     8424     8490      +66     
Files with missing lines Coverage Δ
src/node_platform.cc 76.04% <75.00%> (-0.20%) ⬇️

... and 65 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++. needs-ci PRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Assertion failed: !(handle->flags & UV_HANDLE_CLOSING), file src\win\async.c, line 76

3 participants