-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Fix flake in test_pthread_proxying_refcount #25097
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
Conversation
It apparently takes more than one turn of the worker thread's event loop to ensure that the notifications on the zombie task queues have been cleared so the zombies can be culled. Update the test to wait two turns of the event loop instead of one. Also add new synchronization forcing the main thread to wait until the worker thread has entered Wasm before proxying work to it. This prevents the proxied work notifications from somehow being cleared before the worker thread destroys the proxy queues, which would prevent the task queues from ever being placed on the zombie list in the first place. Finally, generally improve comments and make the test assertions more specific.
Very nice, thanks for the attention. Ran this several times on Windows, Linux and macOS, and it does look watertight now. |
@@ -29,22 +34,28 @@ void __attribute__((noinline)) free(void* ptr) { | |||
|
|||
#endif // SANITIZER | |||
|
|||
_Atomic int worker_started = 0; | |||
_Atomic int should_execute = 0; |
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.
Can you use bool
for these two atomics to make the purpose more clear?
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.
Done.
|
||
void* execute_and_free_queue(void* arg) { | ||
// Signal the main thread to proxy work to us. | ||
worker_started = 1; |
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 assumed you could use true/false in the all the assignment too).
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.
Done.
It apparently takes more than one turn of the worker thread's event loop
to ensure that the notifications on the zombie task queues have been
cleared so the zombies can be culled. Update the test to wait two turns
of the event loop instead of one.
Also add new synchronization forcing the main thread to wait until the
worker thread has entered Wasm before proxying work to it. This prevents
the proxied work notifications from somehow being cleared before the
worker thread destroys the proxy queues, which would prevent the task
queues from ever being placed on the zombie list in the first place.
Finally, generally improve comments and make the test assertions more
specific.
Fixes #19795.