Skip to content

src: improve thread safety of TaskQueue #57910

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 22, 2025

Conversation

codebytere
Copy link
Member

@codebytere codebytere commented Apr 17, 2025

Closes #56236.

Improve thread safety of TaskQueue by making locking of TaskQueue explicit and thus hopefully preventing a crash due to uv_async_send being called with nullptr.

@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 Apr 17, 2025
Copy link

codecov bot commented Apr 17, 2025

Codecov Report

Attention: Patch coverage is 97.56098% with 2 lines in your changes missing coverage. Please review.

Project coverage is 90.26%. Comparing base (5077ea4) to head (d71a542).
Report is 425 commits behind head on main.

Files with missing lines Patch % Lines
src/node_platform.cc 97.53% 0 Missing and 2 partials ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##             main   #57910    +/-   ##
========================================
  Coverage   90.25%   90.26%            
========================================
  Files         630      630            
  Lines      185691   186170   +479     
  Branches    36407    36480    +73     
========================================
+ Hits       167589   168039   +450     
+ Misses      10994    10975    -19     
- Partials     7108     7156    +48     
Files with missing lines Coverage Δ
src/node_platform.h 80.00% <100.00%> (+5.00%) ⬆️
src/node_platform.cc 88.70% <97.53%> (+0.83%) ⬆️

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

@codebytere codebytere force-pushed the mutex-flush-tasks branch 2 times, most recently from 0ffd2a4 to f1b6765 Compare April 17, 2025 17:47
@mcollina
Copy link
Member

@codebytere I wonder if this could also help with #54918.

@codebytere codebytere requested a review from bnoordhuis April 18, 2025 08:53
@codebytere codebytere added the request-ci Add this label to start a Jenkins CI on a PR. label Apr 18, 2025
@github-actions github-actions bot added request-ci-failed An error occurred while starting CI via request-ci label, and manual interventon is needed. and removed request-ci Add this label to start a Jenkins CI on a PR. labels Apr 18, 2025
@nodejs nodejs deleted a comment from github-actions bot Apr 18, 2025
@codebytere codebytere removed the request-ci-failed An error occurred while starting CI via request-ci label, and manual interventon is needed. label Apr 18, 2025
Copy link
Member

@bnoordhuis bnoordhuis left a comment

Choose a reason for hiding this comment

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

LGTM with some suggestions.

@codebytere codebytere force-pushed the mutex-flush-tasks branch 2 times, most recently from 0192c4f to 78a514e Compare April 19, 2025 10:42
Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

RSLGTM

@mcollina mcollina added the request-ci Add this label to start a Jenkins CI on a PR. label Apr 19, 2025
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Apr 19, 2025
@nodejs-github-bot
Copy link
Collaborator

@lpinca
Copy link
Member

lpinca commented Apr 19, 2025

@codebytere I wonder if this could also help with #54918

I applied this patch and unfortunately it does not.

@mcollina
Copy link
Member

Thanks for checking!

@nodejs-github-bot
Copy link
Collaborator

Copy link
Member

@joyeecheung joyeecheung left a comment

Choose a reason for hiding this comment

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

LGTM (as in, my tiny head can't find potential issues out of the new locks), though I think it can use a bit more comments (I am fairly certain that the race can only happen at shutdown, the platform is initialized too early for any tasks to be posted during that process)

RafaelGSS pushed a commit that referenced this pull request May 2, 2025
PR-URL: #57910
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Joyee Cheung <[email protected]>
aduh95 pushed a commit that referenced this pull request May 6, 2025
PR-URL: #57910
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Joyee Cheung <[email protected]>
RafaelGSS pushed a commit that referenced this pull request May 14, 2025
PR-URL: #57910
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Joyee Cheung <[email protected]>
aduh95 pushed a commit that referenced this pull request May 16, 2025
PR-URL: #57910
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Joyee Cheung <[email protected]>
aduh95 pushed a commit that referenced this pull request May 17, 2025
PR-URL: #57910
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Joyee Cheung <[email protected]>
aduh95 pushed a commit that referenced this pull request May 17, 2025
PR-URL: #57910
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Joyee Cheung <[email protected]>
aduh95 pushed a commit that referenced this pull request May 17, 2025
PR-URL: #57910
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Joyee Cheung <[email protected]>
aduh95 pushed a commit that referenced this pull request May 18, 2025
PR-URL: #57910
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Joyee Cheung <[email protected]>
aduh95 pushed a commit that referenced this pull request May 19, 2025
PR-URL: #57910
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Joyee Cheung <[email protected]>
codebytere added a commit to electron/electron that referenced this pull request May 23, 2025
codebytere added a commit to electron/electron that referenced this pull request May 26, 2025
codebytere added a commit to electron/electron that referenced this pull request May 29, 2025
codebytere added a commit to electron/electron that referenced this pull request Jun 2, 2025
jkleinsc pushed a commit to electron/electron that referenced this pull request Jun 2, 2025
* chore: bump node in DEPS to v22.16.0

* crypto: remove BoringSSL dh-primes addition

nodejs/node#57023

* tools: enable linter in test/fixtures/test\-runner/output

nodejs/node#57698

* src: improve thread safety of TaskQueue

nodejs/node#57910

* buffer: define global v8::CFunction objects as const

nodejs/node#57676

* src: disable abseil deadlock detection

nodejs/node#57582

* zlib: fix pointer alignment

nodejs/node#57727

* chore: fixup patch indices

* src: set default config as node.config.json

nodejs/node#57171

* src: update std::vector<v8::Local<T>> to use v8::LocalVector<T>

nodejs/node#57578

* test: disable chmod tests failing in Docker

nodejs/node#58326

---------

Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com>
Co-authored-by: Shelley Vohr <[email protected]>
codebytere added a commit to electron/electron that referenced this pull request Jun 3, 2025
codebytere added a commit to electron/electron that referenced this pull request Jun 3, 2025
codebytere added a commit to electron/electron that referenced this pull request Jun 3, 2025
codebytere added a commit to electron/electron that referenced this pull request Jun 3, 2025
codebytere added a commit to electron/electron that referenced this pull request Jun 3, 2025
codebytere added a commit to electron/electron that referenced this pull request Jun 3, 2025
codebytere added a commit to electron/electron that referenced this pull request Jun 4, 2025
* chore: bump node in DEPS to v22.16.0

* crypto: remove BoringSSL dh-primes addition

nodejs/node#57023

* tools: enable linter in test/fixtures/test\-runner/output

nodejs/node#57698

* src: improve thread safety of TaskQueue

nodejs/node#57910

* buffer: define global v8::CFunction objects as const

nodejs/node#57676

* src: disable abseil deadlock detection

nodejs/node#57582

* zlib: fix pointer alignment

nodejs/node#57727

* chore: fixup patch indices

* src: set default config as node.config.json

nodejs/node#57171

* src: update std::vector<v8::Local<T>> to use v8::LocalVector<T>

nodejs/node#57578

* test: disable chmod tests failing in Docker

nodejs/node#58326

---------

Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com>
Co-authored-by: Shelley Vohr <[email protected]>
@marco-ippolito marco-ippolito added backport-requested-v20.x PRs awaiting manual backport to the v20.x-staging branch. and removed lts-watch-v20.x PRs that may need to be released in v20.x labels Jun 5, 2025
@marco-ippolito
Copy link
Member

This commit requires a manual backport to land on v20.x

codebytere added a commit to electron/electron that referenced this pull request Jun 6, 2025
codebytere added a commit to electron/electron that referenced this pull request Jun 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-requested-v20.x PRs awaiting manual backport to the v20.x-staging branch. c++ Issues and PRs that require attention from people who are familiar with C++.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Node.js 20 Upgrade: Segmentation Fault Core Dump During Pipeline Lage Build Step
9 participants