Skip to content

WIP: Fix deadlock when calling fflush during application shutdown #15190

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

sbc100
Copy link
Collaborator

@sbc100 sbc100 commented Sep 30, 2021

One solution to the deadlock described in #15186 is to allow nested
calls to emscripten_current_thread_process_queued_calls.

This is needed in this case because the main thread is calling fflush
(which requires locking the stdout handle) while another thread is
holding the stdout lock, waiting on the main thread to process the write
action.

There may be reasons we don't want to allow nested calls to
emscripten_current_thread_process_queued_calls but technically its
seems possible.

This change removes all the mitigations that existed in
test_pthread_c11_threads.c and I could no longer reprodude the
deadlock.

Fixes: #15186

@sbc100
Copy link
Collaborator Author

sbc100 commented Sep 30, 2021

This is a test PR to at least see if any tests fail. @juj I seem to remember there could be reasons not to want to do this.. but I can't remember what they are.

One solution to the deadlock described in #15186 is to allow nested
calls to `emscripten_current_thread_process_queued_calls`.

This is needed in this case because the main thread is calling `fflush`
(which requires locking the stdout handle) while another thread is
holding the stdout lock, waiting on the main thread to process the write
action.

There may be reasons we don't want to allow nested calls to
`emscripten_current_thread_process_queued_calls` but technically its
seems possible.

This change removes all the mitigations that existed in
`test_pthread_c11_threads.c` and I could no longer reprodude the
deadlock.

Fixes: #15186
@stale
Copy link

stale bot commented Nov 2, 2022

This issue has been automatically marked as stale because there has been no activity in the past year. It will be closed automatically if no further activity occurs in the next 30 days. Feel free to re-open at any time if this issue is still relevant.

@stale stale bot added the wontfix label Nov 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Deadlock on exit if secondary threads are writing to stdout
1 participant