-
-
Notifications
You must be signed in to change notification settings - Fork 21.7k
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
Robustify multi-threading primitives #72249
Conversation
@@ -113,7 +113,9 @@ Thread::Thread() { | |||
Thread::~Thread() { | |||
if (id != _thread_id_hash(std::thread::id())) { | |||
#ifdef DEBUG_ENABLED | |||
WARN_PRINT("A Thread object has been destroyed without wait_to_finish() having been called on it. Please do so to ensure correct cleanup of the thread."); | |||
WARN_PRINT( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've just reworded this one to be consistent with the warning newly added to Semaphore
.
Given 3.x is also affected (and has a fix ready), this should be safe to merge for 4.0.x when reduz has time to review it. |
03a9ab8
to
fb46f44
Compare
Pushed just fixing a couple of mistakes in the docs. |
fb46f44
to
a6f883d
Compare
Rebased on top of 4.1. |
a6f883d
to
6b5c38e
Compare
Thanks! |
This PR does the following:
Thread
objects were leaked to the OS if not joined (i.e., in those cases there would be no possibility for the warning about callingwait_to_finish()
to be printed; therefore, pretty much hiding the issue to the user).Semaphore
(long explanation in the code comments; TL;DR is Don't exit with semaphores being awaited) and avoids the undefined behavior. I have tried to add similar protection toMutex
, but there are no reasonable ways to detect misuse. In any case, now we can finally get the warning for non-joined threads, most (all?) cases of misuse would cause some kind of admonishment.Fixes #71216.
UPDATE: Back-ported to 3.x in #72251.