Repository navigation
[JSC] Stop a heap's local Collector threads when the heap shuts down - #77844
Merged
Merged
Conversation
Collaborator
|
EWS run on previous version of this PR (hash aef578b) Details
|
Collaborator
|
EWS run on current version of this PR (hash 49909f2) Details |
dhecht
marked this pull request as ready for review
October 22, 2026 15:04
Achierius
approved these changes
Oct 22, 2026
webkit-commit-queue
force-pushed
the
eng/328418
branch
from
October 22, 2026 18:36
49909f2 to
8b8593e
Compare
https://bugs.webkit.org/show_bug.cgi?id=328418 rdar://190202961 Reviewed by Marcus Plutowski. Heap::shutDown() waits for the Heap's Leave request to be processed by the Collector. However, this can happen before the collector thread has returned from m_stopIfNecessaryTimer->scheduleSoon(): 1. The collector thread is conducting a collection and calls Heap::stopTheMutator(). The mutator holds heap access, so instead of stopping it, the collector thread hands it the conn by setting mutatorHasConnBit. 2. The mutator thread, inside waitForCollector(), sees it has the conn, finishes the collection and processes its own Leave request. 3. The collector thread hasn't yet returned from m_stopIfNecessaryTimer->scheduleSoon(), which uses Heap state. 4. The mutator thread continues through ~VM, which unregisters the VM from JSRunLoopTimer::Manager. ~Heap then destroys m_stopIfNecessaryTimer before m_localCollector, so ~Collector joins the collector thread too late. 5. The collector thread accesses the freed m_stopIfNecessaryTimer, or hits the RELEASE_ASSERT in JSRunLoopTimer::Manager::scheduleTimer() since the VM has unregistered. Before 323479@main, Heap::shutDown() joined the collector thread before tearing anything down. Restore that: Collector::shutDown() stops the collect-continuously thread and the collector thread, and Heap::shutDown() calls it for a local Collector right after leaving. ~Collector now asserts that the threads are already stopped instead of stopping them itself. This will need to be fixed for the --useGlobalGC=true case too, but that depends on how stopping the mutators of several heaps will work, so it will come later. For now, this fixes the default --useGlobalGC=false case. Test: JSTests/stress/many-agents-teardown.js * JSTests/stress/many-agents-teardown.js: Added. (i.setTimeout): * Source/JavaScriptCore/heap/Collector.cpp: (JSC::Collector::~Collector): (JSC::Collector::shutDown): (JSC::Collector::stopCollectingContinuously): * Source/JavaScriptCore/heap/Collector.h: * Source/JavaScriptCore/heap/Heap.cpp: (JSC::Heap::shutDown): Canonical link: https://commits.webkit.org/324477@main
webkit-commit-queue
force-pushed
the
eng/328418
branch
from
October 22, 2026 18:37
8b8593e to
eaf0efa
Compare
Collaborator
|
Committed 324477@main (eaf0efa): https://commits.webkit.org/324477@main Reviewed commits have been landed. Closing PR #77844 and removing active labels. |
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.
🛠 mac-apple
eaf0efa
49909f2