<?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>283450</bug_id>
          
          <creation_ts>2024-11-20 17:12:44 -0800</creation_ts>
          <short_desc>[WebDriver] Debug assertion in willDestroyGlobalObjectInCachedFrame in both selenium and W3C back tests</short_desc>
          <delta_ts>2025-04-08 13:27:24 -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>WebDriver</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="Lauro Moura">lmoura</reporter>
          <assigned_to name="Lauro Moura">lmoura</assigned_to>
          <cc>bburg</cc>
    
    <cc>bugs-noreply</cc>
    
    <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>2076555</commentid>
    <comment_count>0</comment_count>
    <who name="Lauro Moura">lmoura</who>
    <bug_when>2024-11-20 17:12:44 -0800</bug_when>
    <thetext>Running tests that go back and forth in history in a Debug build (after disabling the assertion from bug276266), an assertion is triggered when a CachedPage gets deleted from the BackForwardCache.

This happens both for selenium and W3c tests:

imported/w3c/webdriver/tests/classic/back/back.py
imported/selenium/py/test/selenium/webdriver/common/api_example_tests.py

The minimal set of test cases I managed to get to trigger the issue was running the following in the same run:

imported/w3c/webdriver/tests/classic/back/back.py::test_no_browsing_context
imported/w3c/webdriver/tests/classic/back/back.py::test_no_browsing_history
imported/w3c/webdriver/tests/classic/back/back.py::test_data_urls
imported/w3c/webdriver/tests/classic/back/back.py::test_dismissed_beforeunload

Strangely, these tests pass, so looks like it could be something in the teardown of the WebProcess, after the individual tests returns. This should also explain why the assertion is triggered when another test (test_seen_nodes) from `back.py` fails and triggers the assertion _running alongside these_, but not when running in isolation.

Command line:

./Tools/Scripts/run-webdriver-tests --debug --wpe --display-server=headless --verbose  &quot;imported/w3c/webdriver/tests/classic/back/back.py::test_no_browsing_context&quot; &quot;imported/w3c/webdriver/tests/classic/back/back.py::test_no_browsing_history&quot; &quot;imported/w3c/webdriver/tests/classic/back/back.py::test_data_urls&quot; &quot;imported/w3c/webdriver/tests/classic/back/back.py::test_dismissed_beforeunload&quot;

Trace: 

(gdb) bt                                                                                                                                                                                                                                                                                                    [0/96660]
#0  0x00007b8168ca1e69 in WTFCrash () at /home/lauro/wkdev-shared/dev/wk-webdriver/WebKit-WebDriver/Source/WTF/wtf/Assertions.cpp:365                                                                                                                                                                                
#1  0x00007b816465d32b in WTFCrashWithInfo () at WTF/Headers/wtf/Assertions.h:913                                                                                                                                                                                                                                    #2  0x00007b8165f5155c in WebKit::WebAutomationDOMWindowObserver::willDestroyGlobalObjectInCachedFrame (this=0x7b814a892e80) at /home/lauro/wkdev-shared/dev/wk-webdriver/WebKit-WebDriver/Source/WebKit/WebProcess/Automation/WebAutomationDOMWindowObserver.cpp:53                                                 #3  0x00007b816d47825a in WebCore::LocalDOMWindow::willDestroyCachedFrame()::$_0::operator()&lt;WebCore::LocalDOMWindowObserver&gt;(WebCore::LocalDOMWindowObserver&amp;) const (this=0x7b814a2424f8, observer=...) at /home/lauro/wkdev-shared/dev/wk-webdriver/WebKit-WebDriver/Source/WebCore/page/LocalDOMWindow.cpp:512   #4  0x00007b816d4781f1 in WTF::Detail::CallableWrapper&lt;WebCore::LocalDOMWindow::willDestroyCachedFrame()::$_0, void, WebCore::LocalDOMWindowObserver&amp;&gt;::call(WebCore::LocalDOMWindowObserver&amp;) (this=0x7b814a2424f0, in=...) at WTF/Headers/wtf/Function.h:53                                                        
#5  0x00007b816d4772cf in WTF::Function&lt;void (WebCore::LocalDOMWindowObserver&amp;)&gt;::operator()(WebCore::LocalDOMWindowObserver&amp;) const (this=0x7ffcdb2db830, in=...) at WTF/Headers/wtf/Function.h:82                                                                                                                  #6  0x00007b816d4508e2 in WTF::WeakHashSet&lt;WebCore::LocalDOMWindowObserver, WTF::DefaultWeakPtrImpl, (WTF::EnableWeakPtrThreadingAssertions)1&gt;::forEach(WTF::Function&lt;void (WebCore::LocalDOMWindowObserver&amp;)&gt; const&amp;) (this=0x7b814a6e8308, callback=...) at WTF/Headers/wtf/WeakHashSet.h:191                      #7  0x00007b816d450404 in WebCore::LocalDOMWindow::willDestroyCachedFrame (this=0x7b814a6e8280) at /home/lauro/wkdev-shared/dev/wk-webdriver/WebKit-WebDriver/Source/WebCore/page/LocalDOMWindow.cpp:511                                                                                                             
#8  0x00007b816cab5340 in WebCore::CachedFrame::destroy (this=0x7b814a66d780) at /home/lauro/wkdev-shared/dev/wk-webdriver/WebKit-WebDriver/Source/WebCore/history/CachedFrame.cpp:289                                                                                                                               
#9  0x00007b816cab5462 in WebCore::CachedFrame::destroy (this=0x7b814a66d600) at /home/lauro/wkdev-shared/dev/wk-webdriver/WebKit-WebDriver/Source/WebCore/history/CachedFrame.cpp:299                                                                                                                               
#10 0x00007b816cab5baf in WebCore::CachedPage::~CachedPage (this=0x7b814a81fa60) at /home/lauro/wkdev-shared/dev/wk-webdriver/WebKit-WebDriver/Source/WebCore/history/CachedPage.cpp:85                                                                                                                              
#11 0x00007b816656567d in WebCore::CachedPage::operator delete (object=0x7b814a81fa60, size=72) at WebCore/PrivateHeaders/WebCore/CachedPage.h:42                                                                                                                                                                    
#12 0x00007b81665654e0 in std::default_delete&lt;WebCore::CachedPage&gt;::operator() (this=0x7b814a444e00, __ptr=0x7b814a81fa60) at /usr/lib/gcc/x86_64-linux-gnu/14/../../../../include/c++/14/bits/unique_ptr.h:93                                                                                                       
#13 0x00007b81665335a3 in std::unique_ptr&lt;WebCore::CachedPage, std::default_delete&lt;WebCore::CachedPage&gt; &gt;::~unique_ptr (this=0x7b814a444e00) at /usr/lib/gcc/x86_64-linux-gnu/14/../../../../include/c++/14/bits/unique_ptr.h:398                                                                                    
#14 0x00007b816cab0a75 in WTF::UniqueRef&lt;WebCore::CachedPage&gt;::~UniqueRef (this=0x7b814a444e00) at WTF/Headers/wtf/UniqueRef.h:65                                                                                                                                                                                    
#15 0x00007b816cabbf25 in std::destroy_at&lt;WTF::UniqueRef&lt;WebCore::CachedPage&gt; &gt; (__location=0x7b814a444e00) at /usr/lib/gcc/x86_64-linux-gnu/14/../../../../include/c++/14/bits/stl_construct.h:88                                                                                                                   
#16 0x00007b816cabbf05 in std::_Destroy&lt;WTF::UniqueRef&lt;WebCore::CachedPage&gt; &gt; (__pointer=0x7b814a444e00) at /usr/lib/gcc/x86_64-linux-gnu/14/../../../../include/c++/14/bits/stl_construct.h:149                                                                                                                     
#17 0x00007b816cabbee9 in std::__detail::__variant::_Variant_storage&lt;false, WebCore::PruningReason, WTF::UniqueRef&lt;WebCore::CachedPage&gt; &gt;::_M_reset()::{lambda(auto:1&amp;&amp;)#1}::operator()&lt;WTF::UniqueRef&lt;WebCore::CachedPage&gt;&amp;&gt;(WTF::UniqueRef&lt;WebCore::CachedPage&gt;&amp;) (this=0x7ffcdb2dbb57, __this_mem=...)            
    at /usr/lib/gcc/x86_64-linux-gnu/14/../../../../include/c++/14/variant:498                                                                                                                                                                                                                                       
#18 0x00007b816cabbebd in std::__invoke_impl&lt;void, std::__detail::__variant::_Variant_storage&lt;false, WebCore::PruningReason, WTF::UniqueRef&lt;WebCore::CachedPage&gt; &gt;::_M_reset()::{lambda(auto:1&amp;&amp;)#1}, WTF::UniqueRef&lt;WebCore::CachedPage&gt;&amp;&gt;(std::__invoke_other, std::__detail::__variant::_Variant_storage&lt;false, We
bCore::PruningReason, WTF::UniqueRef&lt;WebCore::CachedPage&gt; &gt;::_M_reset()::{lambda(auto:1&amp;&amp;)#1}&amp;&amp;, WTF::UniqueRef&lt;WebCore::CachedPage&gt;&amp;) (__f=..., __args=...) at /usr/lib/gcc/x86_64-linux-gnu/14/../../../../include/c++/14/bits/invoke.h:61                                                                         
#19 0x00007b816cabbe8d in std::__invoke_r&lt;void, std::__detail::__variant::_Variant_storage&lt;false, WebCore::PruningReason, WTF::UniqueRef&lt;WebCore::CachedPage&gt; &gt;::_M_reset()::{lambda(auto:1&amp;&amp;)#1}, WTF::UniqueRef&lt;WebCore::CachedPage&gt;&amp;&gt;(std::__detail::__variant::_Variant_storage&lt;false, WebCore::PruningReason, WT
F::UniqueRef&lt;WebCore::CachedPage&gt; &gt;::_M_reset()::{lambda(auto:1&amp;&amp;)#1}&amp;&amp;, WTF::UniqueRef&lt;WebCore::CachedPage&gt;&amp;) (__fn=..., __args=...) at /usr/lib/gcc/x86_64-linux-gnu/14/../../../../include/c++/14/bits/invoke.h:111                                                                                               
#20 0x00007b816cabbdad in std::__detail::__variant::__gen_vtable_impl&lt;std::__detail::__variant::_Multi_array&lt;void (*)(std::__detail::__variant::_Variant_storage&lt;false, WebCore::PruningReason, WTF::UniqueRef&lt;WebCore::CachedPage&gt; &gt;::_M_reset()::{lambda(auto:1&amp;&amp;)#1}&amp;&amp;, std::variant&lt;WebCore::PruningReason, WTF::UniqueRef&lt;WebCore::CachedPage&gt; &gt;&amp;)&gt;, std::integer_sequence&lt;unsigned long, 1ul&gt; &gt;::__visit_invoke(std::__detail::__variant::_Variant_storage&lt;false, WebCore::PruningReason, WTF::UniqueRef&lt;WebCore::CachedPage&gt; &gt;::_M_reset()::{lambda(auto:1&amp;&amp;)#1}&amp;&amp;, std::variant&lt;WebCore::PruningReason, WTF::UniqueRef&lt;WebCore::Ca
chedPage&gt; &gt;&amp;) (__visitor=..., __vars=std::variant [index 1] = {...}) at /usr/lib/gcc/x86_64-linux-gnu/14/../../../../include/c++/14/variant:1064                                                                                                                                                                     
#21 0x00007b816cabbcf6 in std::__do_visit&lt;void, std::__detail::__variant::_Variant_storage&lt;false, WebCore::PruningReason, WTF::UniqueRef&lt;WebCore::CachedPage&gt; &gt;::_M_reset()::{lambda(auto:1&amp;&amp;)#1}, std::variant&lt;WebCore::PruningReason, WTF::UniqueRef&lt;WebCore::CachedPage&gt; &gt;&amp;&gt;(std::__detail::__variant::_Variant_storage&lt;false, WebCore::PruningReason, WTF::UniqueRef&lt;WebCore::CachedPage&gt; &gt;::_M_reset()::{lambda(auto:1&amp;&amp;)#1}&amp;&amp;, std::variant&lt;WebCore::PruningReason, WTF::UniqueRef&lt;WebCore::CachedPage&gt; &gt;&amp;) (__visitor=..., __variants=std::variant [index 1] = {...})                                                                  at /usr/lib/gcc/x86_64-linux-gnu/14/../../../../include/c++/14/variant:1820                                                                                                                                                                                                                                      
#22 0x00007b816cabbc6b in std::__detail::__variant::_Variant_storage&lt;false, WebCore::PruningReason, WTF::UniqueRef&lt;WebCore::CachedPage&gt; &gt;::_M_reset (this=0x7b814a444e00) at /usr/lib/gcc/x86_64-linux-gnu/14/../../../../include/c++/14/variant:496                                                                 
#23 0x00007b816cac61b9 in std::__detail::__variant::__emplace&lt;0ul, false, WebCore::PruningReason, WTF::UniqueRef&lt;WebCore::CachedPage&gt;, WebCore::PruningReason&amp;&gt; (__v=..., __args=@0x7ffcdb2dbd54: WebCore::PruningReason::ReachedMaxSize) at /usr/lib/gcc/x86_64-linux-gnu/14/../../../../include/c++/14/variant:565 #24 0x00007b816cac6191 in std::variant&lt;WebCore::PruningReason, WTF::UniqueRef&lt;WebCore::CachedPage&gt; &gt;::emplace&lt;0ul, WebCore::PruningReason&amp;&gt; (this=0x7b814a444e00, __args=@0x7ffcdb2dbd54: WebCore::PruningReason::ReachedMaxSize) at /usr/lib/gcc/x86_64-linux-gnu/14/../../../../include/c++/14/variant:1552        #25 0x00007b816cac5bd8 in std::variant&lt;WebCore::PruningReason, WTF::UniqueRef&lt;WebCore::CachedPage&gt; &gt;::operator=&lt;WebCore::PruningReason&amp;&gt; (this=0x7b814a444e00, __rhs=@0x7ffcdb2dbd54: WebCore::PruningReason::ReachedMaxSize) at /usr/lib/gcc/x86_64-linux-gnu/14/../../../../include/c++/14/variant:1510            
#26 0x00007b816cac5ae7 in WTF::HashMap&lt;WebCore::ProcessQualified&lt;WTF::ObjectIdentifierGeneric&lt;WebCore::BackForwardItemIdentifierType, WTF::ObjectIdentifierMainThreadAccessTraits&lt;unsigned long&gt;, unsigned long&gt; &gt;, std::variant&lt;WebCore::PruningReason, WTF::UniqueRef&lt;WebCore::CachedPage&gt; &gt;, WTF::DefaultHash&lt;WebC
ore::ProcessQualified&lt;WTF::ObjectIdentifierGeneric&lt;WebCore::BackForwardItemIdentifierType, WTF::ObjectIdentifierMainThreadAccessTraits&lt;unsigned long&gt;, unsigned long&gt; &gt; &gt;, WTF::HashTraits&lt;WebCore::ProcessQualified&lt;WTF::ObjectIdentifierGeneric&lt;WebCore::BackForwardItemIdentifierType, WTF::ObjectIdentifierMainThreadAccessTraits&lt;unsigned long&gt;, unsigned long&gt; &gt; &gt;, WTF::HashTraits&lt;std::variant&lt;WebCore::PruningReason, WTF::UniqueRef&lt;WebCore::CachedPage&gt; &gt; &gt;, WTF::HashTableTraits, (WTF::ShouldValidateKey)1&gt;::inlineSet&lt;WebCore::ProcessQualified&lt;WTF::ObjectIdentifierGeneric&lt;WebCore::BackForwardItemIdentifierType, WTF::ObjectIdentifierMainThreadAccessTraits&lt;unsigned long&gt;, unsigned long&gt; &gt; const&amp;, WebCore::PruningReason&amp;&gt; (this=0x7b8170598110 &lt;WebCore::BackForwardCache::singleton()::globalBackForwardCache&gt;, key=..., value=@0x7ffcdb2dbd54: WebCore::PruningReason::ReachedMaxSize) at WTF/Headers/wtf/HashMap.h:420               #27 0x00007b816cab1dd0 in WTF::HashMap&lt;WebCore::ProcessQualified&lt;WTF::ObjectIdentifierGeneric&lt;WebCore::BackForwardItemIdentifierType, WTF::ObjectIdentifierMainThreadAccessTraits&lt;unsigned long&gt;, unsigned long&gt; &gt;, std::variant&lt;WebCore::PruningReason, WTF::UniqueRef&lt;WebCore::CachedPage&gt; &gt;, WTF::DefaultHash&lt;WebC
ore::ProcessQualified&lt;WTF::ObjectIdentifierGeneric&lt;WebCore::BackForwardItemIdentifierType, WTF::ObjectIdentifierMainThreadAccessTraits&lt;unsigned long&gt;, unsigned long&gt; &gt; &gt;, WTF::HashTraits&lt;WebCore::ProcessQualified&lt;WTF::ObjectIdentifierGeneric&lt;WebCore::BackForwardItemIdentifierType, WTF::ObjectIdentifierMainTh
--Type &lt;RET&gt; for more, q to quit, c to continue without paging--bt                                                                                                                                                                                                                                                   
readAccessTraits&lt;unsigned long&gt;, unsigned long&gt; &gt; &gt;, WTF::HashTraits&lt;std::variant&lt;WebCore::PruningReason, WTF::UniqueRef&lt;WebCore::CachedPage&gt; &gt; &gt;, WTF::HashTableTraits, (WTF::ShouldValidateKey)1&gt;::set&lt;WebCore::PruningReason&amp;&gt;                                                                                    
    (this=0x7b8170598110 &lt;WebCore::BackForwardCache::singleton()::globalBackForwardCache&gt;, key=..., mapped=@0x7ffcdb2dbd54: WebCore::PruningReason::ReachedMaxSize) at WTF/Headers/wtf/HashMap.h:443                                                                                                                 
#28 0x00007b816caaf522 in WebCore::BackForwardCache::prune (this=0x7b8170598110 &lt;WebCore::BackForwardCache::singleton()::globalBackForwardCache&gt;, pruningReason=WebCore::PruningReason::ReachedMaxSize)                                                                                                              
    at /home/lauro/wkdev-shared/dev/wk-webdriver/WebKit-WebDriver/Source/WebCore/history/BackForwardCache.cpp:641                                                                                                                                                                                                    
#29 0x00007b816cab081f in WebCore::BackForwardCache::addIfCacheable (this=0x7b8170598110 &lt;WebCore::BackForwardCache::singleton()::globalBackForwardCache&gt;, item=..., page=0x7b814a0bc100) at /home/lauro/wkdev-shared/dev/wk-webdriver/WebKit-WebDriver/Source/WebCore/history/BackForwardCache.cpp:536              
#30 0x00007b816d2194e0 in WebCore::FrameLoader::commitProvisionalLoad (this=0x7b814a065000) at /home/lauro/wkdev-shared/dev/wk-webdriver/WebKit-WebDriver/Source/WebCore/loader/FrameLoader.cpp:2326                                                                                                                 
#31 0x00007b816d1b1ecf in WebCore::DocumentLoader::commitIfReady (this=0x7b80fa1bc000) at /home/lauro/wkdev-shared/dev/wk-webdriver/WebKit-WebDriver/Source/WebCore/loader/DocumentLoader.cpp:424                                                                                                                    
#32 0x00007b816d1bb6e3 in WebCore::DocumentLoader::commitLoad (this=0x7b80fa1bc000, data=...) at /home/lauro/wkdev-shared/dev/wk-webdriver/WebKit-WebDriver/Source/WebCore/loader/DocumentLoader.cpp:1219                                                                                                            
#33 0x00007b816d1bd4cd in WebCore::DocumentLoader::dataReceived (this=0x7b80fa1bc000, buffer=...) at /home/lauro/wkdev-shared/dev/wk-webdriver/WebKit-WebDriver/Source/WebCore/loader/DocumentLoader.cpp:1399                                                                                                        
#34 0x00007b816d1bd232 in WebCore::DocumentLoader::dataReceived (this=0x7b80fa1bc000, resource=..., buffer=...) at /home/lauro/wkdev-shared/dev/wk-webdriver/WebKit-WebDriver/Source/WebCore/loader/DocumentLoader.cpp:1374                                                                                          
#35 0x00007b816d320b57 in WebCore::CachedRawResource::notifyClientsDataWasReceived (this=0x7b814a3ac8e0, buffer=...) at /home/lauro/wkdev-shared/dev/wk-webdriver/WebKit-WebDriver/Source/WebCore/loader/cache/CachedRawResource.cpp:144                                                                             
#36 0x00007b816d320926 in WebCore::CachedRawResource::updateBuffer (this=0x7b814a3ac8e0, data=...) at /home/lauro/wkdev-shared/dev/wk-webdriver/WebKit-WebDriver/Source/WebCore/loader/cache/CachedRawResource.cpp:80                                                                                                
#37 0x00007b816d2a9ffa in WebCore::SubresourceLoader::didReceiveBuffer (this=0x7b814a497360, buffer=..., encodedDataLength=512, dataPayloadType=WebCore::DataPayloadBytes) at /home/lauro/wkdev-shared/dev/wk-webdriver/WebKit-WebDriver/Source/WebCore/loader/SubresourceLoader.cpp:577                             
#38 0x00007b816d2900cf in WebCore::ResourceLoader::didReceiveData (this=0x7b814a497360, buffer=..., encodedDataLength=512, dataPayloadType=WebCore::DataPayloadBytes) at /home/lauro/wkdev-shared/dev/wk-webdriver/WebKit-WebDriver/Source/WebCore/loader/ResourceLoader.cpp:614                                     
#39 0x00007b8166319dc6 in WebKit::WebResourceLoader::didReceiveData (this=0x7b814a51e000, data=..., encodedDataLength=512) at /home/lauro/wkdev-shared/dev/wk-webdriver/WebKit-WebDriver/Source/WebKit/WebProcess/Network/WebResourceLoader.cpp:235
&lt;snip&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2109499</commentid>
    <comment_count>1</comment_count>
    <who name="Lauro Moura">lmoura</who>
    <bug_when>2025-04-07 12:38:41 -0700</bug_when>
    <thetext>Pull request: https://github.com/WebKit/WebKit/pull/43758</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2109779</commentid>
    <comment_count>2</comment_count>
    <who name="EWS">ews-feeder</who>
    <bug_when>2025-04-08 13:26:58 -0700</bug_when>
    <thetext>Committed 293431@main (aa0b90378a55): &lt;https://commits.webkit.org/293431@main&gt;

Reviewed commits have been landed. Closing PR #43758 and removing active labels.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2109780</commentid>
    <comment_count>3</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2025-04-08 13:27:24 -0700</bug_when>
    <thetext>&lt;rdar://problem/148853084&gt;</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>