Fixed the race condition in NamedThread#984
Merged
veloman-yunkan merged 2 commits intomainfrom May 4, 2025
Merged
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #984 +/- ##
==========================================
- Coverage 57.65% 57.65% -0.01%
==========================================
Files 103 103
Lines 4922 4926 +4
Branches 2066 2068 +2
==========================================
+ Hits 2838 2840 +2
Misses 706 706
- Partials 1378 1380 +2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
e3c8111 to
eb66991
Compare
Before this fix, `NamedThread::getCurrentThreadName()` might be called from the new thread (that already started executing) before the assignment to `thread_` in the `NamedThread` constructor had taken place. Then the query to the thread id (`nt->thread_.get_id()`) on such a thread did not return the correct id, and the end result was that a new (numbered) thread name was synthesized for that thread. From that point onward, concurrency orchestration via `log_debug()` (which relies on correct thread names) broke, typically resulting in a deadlock. This fix slightly reduces the generality of the `NamedThread` constructor (support for arguments to the callable has been dropped) since it is not currently needed (and even if it was needed, it could be circumvented with an extra lambda expression).
eb66991 to
3ef0774
Compare
Contributor
|
@veloman-yunkan This PR seems to introduce a compilation regression (Windows only!), see https://github.com/openzim/libzim/actions/runs/14819235224/job/41603865419?pr=984 |
11311ba to
bce9a15
Compare
bce9a15 to
c86c695
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #983