<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>313353</bug_id>
          
          <creation_ts>2026-04-26 10:31:21 -0700</creation_ts>
          <short_desc>IDBTransaction/IDBRequest/IDBObjectStore retain cycle when IDBTransaction::stop() is called on a finishing transaction</short_desc>
          <delta_ts>2026-04-30 11:22:39 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>Website Storage</component>
          <version>WebKit Nightly Build</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="David Kilzer (:ddkilzer)">ddkilzer</reporter>
          <assigned_to name="David Kilzer (:ddkilzer)">ddkilzer</assigned_to>
          <cc>sihui_liu</cc>
    
    <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>2204626</commentid>
    <comment_count>0</comment_count>
    <who name="David Kilzer (:ddkilzer)">ddkilzer</who>
    <bug_when>2026-04-26 10:31:21 -0700</bug_when>
    <thetext>When `IDBTransaction::stop()` is called on a transaction that is already finishing (Committing or Aborting state), multiple retain cycles prevent `IDBTransaction`, `IDBRequest`, `IDBObjectStore`, and `TransactionOperationImpl` objects from being destroyed.

The retain cycles are:
1. `IDBTransaction::m_transactionOperationMap` holds `Ref&lt;TransactionOperationImpl&gt;`, and each `TransactionOperationImpl` holds `Ref&lt;IDBTransaction&gt;` via its `m_transaction` member and through captured lambdas in `m_performFunction` and `m_completeFunction`.
2. `IDBTransaction::m_openRequests` holds `Ref&lt;IDBRequest&gt;`, and each `IDBRequest` holds `RefPtr&lt;IDBTransaction&gt;` via its `m_transaction` member.
3. `IDBDatabase::m_activeTransactions` (and `m_committingTransactions`, `m_abortingTransactions`) hold `Ref&lt;IDBTransaction&gt;` that are never cleared in `IDBDatabase::stop()`.

Steps to reproduce:
1. Build WebKit Debug from main branch.
2. Run layout tests with --leaks: `Tools/Scripts/run-webkit-tests --leaks --debug imported/w3c/web-platform-tests/IndexedDB/`
3. Examine the WebContent memgraph with `leaks --groupByType`.

Expected results:
No `IDBTransaction`, `IDBRequest`, `IDBObjectStore`, or `TransactionOperationImpl` objects appear as ROOT CYCLE in the leaks output.

Actual results:
The `leaks` tool reports ROOT CYCLE entries for `IDBTransaction`, `IDBRequest`, `IDBObjectStore`, and `TransactionOperationImpl` objects. Example from `leaks --groupByType`:

```
508 (71.4K) ROOT CYCLE: CallableWrapper&lt;TransactionOperationImpl...&gt;
    492 (69.6K) ROOT CYCLE: CallableWrapper&lt;IDBTransaction::requestGetRecord...&gt;
        420 (61.9K) ROOT CYCLE: WebCore::IDBTransaction
            344 (53.9K) ROOT CYCLE: non-object
                170 (26.6K) ROOT CYCLE: WebCore::IDBClient::TransactionOperationImpl
                    68 (18.1K) ROOT CYCLE: WebCore::IDBRequest
```</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2204627</commentid>
    <comment_count>1</comment_count>
    <who name="David Kilzer (:ddkilzer)">ddkilzer</who>
    <bug_when>2026-04-26 10:31:23 -0700</bug_when>
    <thetext>&lt;rdar://problem/175627928&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2204649</commentid>
    <comment_count>2</comment_count>
    <who name="David Kilzer (:ddkilzer)">ddkilzer</who>
    <bug_when>2026-04-26 12:15:02 -0700</bug_when>
    <thetext>Pull request: https://github.com/WebKit/WebKit/pull/63634</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2206325</commentid>
    <comment_count>3</comment_count>
    <who name="EWS">ews-feeder</who>
    <bug_when>2026-04-30 11:22:37 -0700</bug_when>
    <thetext>Committed 312379@main (a460a664aa29): &lt;https://commits.webkit.org/312379@main&gt;

Reviewed commits have been landed. Closing PR #63634 and removing active labels.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>