<?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>271849</bug_id>
          
          <creation_ts>2024-03-28 14:52:22 -0700</creation_ts>
          <short_desc>nullptr crash in moveOutOfAllShadowRoots</short_desc>
          <delta_ts>2024-03-28 17:17:53 -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>DOM</component>
          <version>Other</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="Ryosuke Niwa">rniwa</reporter>
          <assigned_to name="Ryosuke Niwa">rniwa</assigned_to>
          <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>2024558</commentid>
    <comment_count>0</comment_count>
    <who name="Ryosuke Niwa">rniwa</who>
    <bug_when>2024-03-28 14:52:22 -0700</bug_when>
    <thetext>e.g.
Thread[0] EXC_BAD_ACCESS (SIGSEGV) (0x0000000000000001, 0x000000000000001d)
[  0] 0x00000001a8a8dba0 WebCore`WebCore::EventPath::setRelatedTarget(WebCore::Node&amp;, WebCore::Node&amp;) [inlined] WebCore::moveOutOfAllShadowRoots(WebCore::Node&amp;) + 36 at EventPath.cpp:294:5

       290 	
       291 	static Node* moveOutOfAllShadowRoots(Node&amp; startingNode)
       292 	{
       293 	    Node* node = &amp;startingNode;
    -&gt; 294 	    while (node-&gt;isInShadowTree())
       295 	        node = downcast&lt;ShadowRoot&gt;(node-&gt;treeScope().rootNode()).host();
       296 	    return node;
       297 	}
       298 	
    

     0x00000001a8a8db90:      cbz x8, 0x16d9b9c        ; &lt;+1992&gt; [inlined] WebCore::moveOutOfAllShadowRoots(WebCore::Node&amp;) + 32 at WeakPtr.h
     0x00000001a8a8db94:      ldr x9, [x8, #0x8]
     0x00000001a8a8db98:        b 0x16d9ba0            ; &lt;+1996&gt; [inlined] WebCore::moveOutOfAllShadowRoots(WebCore::Node&amp;) + 36 at EventPath.cpp:294:5
     0x00000001a8a8db9c:      mov x9, #0x0
 -&gt;  0x00000001a8a8dba0:     ldrb w8, [x9, #0x1d]
     0x00000001a8a8dba4:     tbnz w8, #0x3, 0x16d9b84  ; &lt;+1968&gt; [inlined] WebCore::Node::treeScope() const at Node.h:388:17
     0x00000001a8a8dba8:      ldr w8, [x9, #0x18]
     0x00000001a8a8dbac:      add w8, w8, #0x2
     0x00000001a8a8dbb0:      str w8, [x9, #0x18]

[  0] 0x00000001a8a8db7c WebCore`WebCore::EventPath::setRelatedTarget(WebCore::Node&amp;, WebCore::Node&amp;) [inlined] WebCore::RelatedNodeRetargeter::RelatedNodeRetargeter(WebCore::Node&amp;, WebCore::Node&amp;) + 36 at EventPath.cpp:316:35
       312 	        return;
       313 	    }
       314 	    if (relatedNode.isConnected() != target.isConnected()) {
       315 	        m_hasDifferentTreeRoot = true;
    -&gt; 316 	        m_retargetedRelatedNode = moveOutOfAllShadowRoots(relatedNode);
       317 	        return;
       318 	    }
       319 	
       320 	    collectTreeScopes();
    
[  0] 0x00000001a8a8db58 WebCore`WebCore::EventPath::setRelatedTarget(WebCore::Node&amp;, WebCore::Node&amp;) [inlined] WebCore::RelatedNodeRetargeter::RelatedNodeRetargeter(WebCore::Node&amp;, WebCore::Node&amp;) at EventPath.cpp:302:1
       298 	
       299 	RelatedNodeRetargeter::RelatedNodeRetargeter(Node&amp; relatedNode, Node&amp; target)
       300 	    : m_relatedNode(relatedNode)
       301 	    , m_retargetedRelatedNode(&amp;relatedNode)
    -&gt; 302 	{
       303 	    auto&amp; targetTreeScope = target.treeScope();
       304 	    TreeScope* currentTreeScope = &amp;m_relatedNode-&gt;treeScope();
       305 	    if (LIKELY(currentTreeScope == &amp;targetTreeScope &amp;&amp; target.isConnected() &amp;&amp; m_relatedNode-&gt;isConnected()))
       306 	        return;
    
[  0] 0x00000001a8a8db58 WebCore`WebCore::EventPath::setRelatedTarget(WebCore::Node&amp;, WebCore::Node&amp;) + 1924 at EventPath.cpp:148:27
       144 	}
       145 	
       146 	void EventPath::setRelatedTarget(Node&amp; origin, Node&amp; relatedNode)
       147 	{
    -&gt; 148 	    RelatedNodeRetargeter retargeter(relatedNode, *m_path[0].node());
       149 	
       150 	    bool originIsRelatedTarget = &amp;origin == &amp;relatedNode;
       151 	    Node&amp; rootNodeInOriginTreeScope = origin.treeScope().rootNode();
       152 	    TreeScope* previousTreeScope = nullptr;
    
[  1] 0x00000001a8a8db9f WebCore`WebCore::EventPath::setRelatedTarget(WebCore::Node&amp;, WebCore::Node&amp;) [inlined] WebCore::moveOutOfAllShadowRoots(WebCore::Node&amp;) + 35 at WeakPtr.h:0:56
[  1] 0x00000001a8a8db7c WebCore`WebCore::EventPath::setRelatedTarget(WebCore::Node&amp;, WebCore::Node&amp;) [inlined] WebCore::RelatedNodeRetargeter::RelatedNodeRetargeter(WebCore::Node&amp;, WebCore::Node&amp;) + 36 at EventPath.cpp:316:35
[  1] 0x00000001a8a8db58 WebCore`WebCore::EventPath::setRelatedTarget(WebCore::Node&amp;, WebCore::Node&amp;) [inlined] WebCore::RelatedNodeRetargeter::RelatedNodeRetargeter(WebCore::Node&amp;, WebCore::Node&amp;) at EventPath.cpp:302:1
[  1] 0x00000001a8a8db58 WebCore`WebCore::EventPath::setRelatedTarget(WebCore::Node&amp;, WebCore::Node&amp;) + 1924 at EventPath.cpp:148:27
[  2] 0x00000001a8a8db9f WebCore`WebCore::EventPath::setRelatedTarget(WebCore::Node&amp;, WebCore::Node&amp;) [inlined] WebCore::moveOutOfAllShadowRoots(WebCore::Node&amp;) + 35 at WeakPtr.h:0:56
[  2] 0x00000001a8a8db7c WebCore`WebCore::EventPath::setRelatedTarget(WebCore::Node&amp;, WebCore::Node&amp;) [inlined] WebCore::RelatedNodeRetargeter::RelatedNodeRetargeter(WebCore::Node&amp;, WebCore::Node&amp;) + 36 at EventPath.cpp:316:35
[  2] 0x00000001a8a8db58 WebCore`WebCore::EventPath::setRelatedTarget(WebCore::Node&amp;, WebCore::Node&amp;) [inlined] WebCore::RelatedNodeRetargeter::RelatedNodeRetargeter(WebCore::Node&amp;, WebCore::Node&amp;) at EventPath.cpp:302:1
[  2] 0x00000001a8a8db58 WebCore`WebCore::EventPath::setRelatedTarget(WebCore::Node&amp;, WebCore::Node&amp;) + 1924 at EventPath.cpp:148:27
[  3] 0x00000001a8a8db9f WebCore`WebCore::EventPath::setRelatedTarget(WebCore::Node&amp;, WebCore::Node&amp;) [inlined] WebCore::moveOutOfAllShadowRoots(WebCore::Node&amp;) + 35 at WeakPtr.h:0:56
[  3] 0x00000001a8a8db7c WebCore`WebCore::EventPath::setRelatedTarget(WebCore::Node&amp;, WebCore::Node&amp;) [inlined] WebCore::RelatedNodeRetargeter::RelatedNodeRetargeter(WebCore::Node&amp;, WebCore::Node&amp;) + 36 at EventPath.cpp:316:35
[  3] 0x00000001a8a8db58 WebCore`WebCore::EventPath::setRelatedTarget(WebCore::Node&amp;, WebCore::Node&amp;) [inlined] WebCore::RelatedNodeRetargeter::RelatedNodeRetargeter(WebCore::Node&amp;, WebCore::Node&amp;) at EventPath.cpp:302:1
[  3] 0x00000001a8a8db58 WebCore`WebCore::EventPath::setRelatedTarget(WebCore::Node&amp;, WebCore::Node&amp;) + 1924 at EventPath.cpp:148:27</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2024560</commentid>
    <comment_count>1</comment_count>
    <who name="Ryosuke Niwa">rniwa</who>
    <bug_when>2024-03-28 14:59:26 -0700</bug_when>
    <thetext>Pull request: https://github.com/WebKit/WebKit/pull/26576</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2024561</commentid>
    <comment_count>2</comment_count>
    <who name="Ryosuke Niwa">rniwa</who>
    <bug_when>2024-03-28 14:59:54 -0700</bug_when>
    <thetext>&lt;rdar://121268633&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2024626</commentid>
    <comment_count>3</comment_count>
    <who name="EWS">ews-feeder</who>
    <bug_when>2024-03-28 17:17:51 -0700</bug_when>
    <thetext>Committed 276815@main (26bc2e2bb52f): &lt;https://commits.webkit.org/276815@main&gt;

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

    </bug>

</bugzilla>