WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
313389
WorkerMessagingProxy objects leak after calling worker.terminate() from JavaScript
https://bugs.webkit.org/show_bug.cgi?id=313389
Summary
WorkerMessagingProxy objects leak after calling worker.terminate() from JavaS...
David Kilzer (:ddkilzer)
Reported
2026-04-26 22:58:25 PDT
`WorkerMessagingProxy` objects leak after calling `worker.terminate()` from JavaScript. The proxy ref-counting has a two-phase cleanup: `terminateWorkerGlobalScope()` shuts down the worker thread (phase 1), then `workerObjectDestroyed()` releases the initial ref when the `Worker` DOM object is destroyed (phase 2). The bug is that phase 1 clears `m_scriptExecutionContextIdentifier`, which phase 2 needs to post its cleanup task. Specifically, `workerGlobalScopeDestroyedInternal()` runs with `m_mayBeDestroyed == false` (set only by `workerObjectDestroyed()`), so it skips `deref()` and sets `m_scriptExecutionContextIdentifier = std::nullopt`. When `Worker::~Worker()` later calls `workerObjectDestroyed()`, the nullopt identifier causes an early return, and `deref()` is never called. A secondary retain cycle exists when messages are queued in `m_queuedEarlyTasks` before the worker thread is created. The queued task lambdas capture `Ref { *this }`, creating a cycle through the proxy's own member vector that prevents destruction even if `deref()` were called. Observed as ROOT LEAK (957 instances of `WorkerMessagingProxy`) and ROOT CYCLE (88 retain cycles with `WorkerMessagingProxy` and `CallableWrapper`) across 20 of 103 WebContent process memgraphs from a full `run-webkit-tests --leaks --debug` run. Tests that exercise the bug include: - workers/worker-terminate-crash.html - workers/bomb.html - workers/worker-set-delete-terminate-crash.html
Attachments
Add attachment
proposed patch, testcase, etc.
Radar WebKit Bug Importer
Comment 1
2026-04-26 22:58:33 PDT
<
rdar://problem/175652847
>
David Kilzer (:ddkilzer)
Comment 2
2026-04-26 23:34:03 PDT
Pull request:
https://github.com/WebKit/WebKit/pull/63665
EWS
Comment 3
2026-04-28 19:52:14 PDT
Committed
312256@main
(80cc99fb32cb): <
https://commits.webkit.org/312256@main
> Reviewed commits have been landed. Closing PR #63665 and removing active labels.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug