Repository navigation
Conversation
test_pthread_dylink_tls_free, added in emscripten-core#28051, is flaky on the emscripten-releases bot (test_core.cores). The test compares mallinfo() before and after 100 pthread_create / pthread_join cycles and allows 200 KiB of growth. Under PROXY_TO_PTHREAD, main() runs on a pthread, and there pthread_join() doesn't free the joined thread's own block (64 KiB stack + guard + TLS + pthread struct, about 73 KiB): _emscripten_thread_cleanup() posts CMD_CLEANUP_THREAD to the main thread, which frees it later. The next pthread_create() reaches the main thread through its mailbox rather than through that message queue, so the main thread can fall several joins behind. Three not-yet-freed blocks are enough to exceed the allowance. Drop PROXY_TO_PTHREAD for this test. On the main runtime thread, _emscripten_thread_cleanup() calls cleanupThread() directly, so the joined thread's block is freed before pthread_join() returns and the measurement no longer depends on timing. The side-module TLS leak fixed in emscripten-core#28051 is still caught. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EuYUd1U1jgeJHaduQBgcKA
There was a problem hiding this comment.
Code Review
This pull request updates the test_pthread_dylink_tls_free test by removing the PROXY_TO_PTHREAD setting in test/test_core.py and updating the corresponding comments in test_pthread_dylink_tls_free.c. This change ensures the test runs on the main runtime thread so that pthread_join() synchronously frees the joined thread's resources, preventing timing-dependent measurement discrepancies. There are no review comments, and I have no feedback to provide.
sbc100
approved these changes
Oct 31, 2026
sbc100
enabled auto-merge (squash)
October 31, 2026 18:01
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.
test_pthread_dylink_tls_free, added in #28051, is flaky on the emscripten-releases bot (test_core.cores), as reported in #28051 (comment):The test compares
mallinfo()before and after 100pthread_create/pthread_joincycles and allows 200 KiB of growth. UnderPROXY_TO_PTHREAD,main()runs on a pthread, and therepthread_join()doesn't free the joined thread's own block (64 KiB stack + guard + TLS + pthread struct, about 73 KiB):_emscripten_thread_cleanup()postsCMD_CLEANUP_THREADto the main thread, which frees it later. The nextpthread_create()reaches the main thread through its mailbox rather than through that message queue, so the main thread can fall several joins behind. Three not-yet-freed blocks are enough to exceed the allowance.This drops
PROXY_TO_PTHREADfor this test. On the main runtime thread,_emscripten_thread_cleanup()callscleanupThread()directly, so the joined thread's block is freed beforepthread_join()returns and the measurement no longer depends on timing. The side-module TLS leak fixed in #28051 (about 400 KiB over 100 threads) is still caught.test_pthread_dlopenalready usesdlopenpluspthread_create/pthread_joinon the main thread under node in the same way.🤖 Generated with Claude Code
https://claude.ai/code/session_01EuYUd1U1jgeJHaduQBgcKA