You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Deadlock on exit if secondary threads are writing to stdout #15186
When using PROXY_TO_PTHREAD and main() returns (or if a secondary pthread calls exit()),
the exitOnMainThread function is used to proxy the application exit back top the main thread and
bring down the entire application.
This means that the exit() call ends up happens during emscripten_current_thread_process_queued_calls.
However, if there are threads that are printing to stdout it will then be blocked because writing
to stdout also requires a proxied operation which requires the main thread to process queued calls
but emscripten_current_thread_process_queued_calls does not recursion.
This means that when the main thread calls fflush(0), and it tried to __lockfile(2) there is
a deadlock because the thread trying to write to stdout is already holding this lock.
This issue is responsible for the flakiness in test_pthread_c11_threads: #14579
@juj, I seem to remember you mentioning that there any reasons not to allow emscripten_current_thread_process_queued_calls be nested ? Removing the thread_is_processing_queued_calls check would fix this deadlock.
Activity
Second attempt at fixing test_pthread_c11_threads
Second attempt at fixing test_pthread_c11_threads
Second attempt at fixing test_pthread_c11_threads (#15187)
sbc100 commentedon Sep 30, 2021
@juj, I seem to remember you mentioning that there any reasons not to allow
emscripten_current_thread_process_queued_callsbe nested ? Removing thethread_is_processing_queued_callscheck would fix this deadlock.Fix deadlock when calling fflush during application shutdown
Fix deadlock when calling fflush during application shutdown
Add variadic versions of emscripten_console functions
Add variadic versions of emscripten_console functions
Add variadic versions of emscripten_console functions
Add variadic versions of emscripten_console functions
Add variadic versions of emscripten_console functions
Add variadic versions of emscripten_console functions
Add variadic versions of emscripten_console functions (#15199)