Repository navigation
Conversation
Like emscripten-core#28186 fixed for `em_proxying_queue`, `em_task_queue` must not call `malloc` or `free` while holding `queue->mutex` because allocator lock contention can run `_emscripten_yield` -> `emscripten_proxy_execute_queue`, re-locking `queue->mutex` on the same thread or blocking another thread executing the queue. Previously both `em_task_queue_send` and `emscripten_thread_mailbox_send` held `queue->mutex` across `em_task_queue_enqueue` -> `em_task_queue_grow`. Move locking into `em_task_queue_enqueue` and drop `queue->mutex` around allocating the larger buffer and freeing the old one, re-checking queue state after re-acquiring the lock. Extend `test_pthread_proxy_deadlock` with growth test cases covering the system queue, user queues, contended workers, and `free`.
This branch has not been deployed
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.
Like #28186 fixed for
em_proxying_queue,em_task_queuemust not callmallocorfreewhile holdingqueue->mutexbecause allocator lock contention can run_emscripten_yield->emscripten_proxy_execute_queue, re-lockingqueue->mutexon the same thread or blocking another thread executing the queue.Previously both
em_task_queue_sendandemscripten_thread_mailbox_sendheldqueue->mutexacrossem_task_queue_enqueue->em_task_queue_grow.Move locking into
em_task_queue_enqueueand dropqueue->mutexaround allocating the larger buffer and freeing the old one, re-checking queue state after re-acquiring the lock.Extend
test_pthread_proxy_deadlockwith growth test cases covering the system queue, user queues, contended workers, andfree.