<?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>260642</bug_id>
          
          <creation_ts>2023-08-23 18:46:27 -0700</creation_ts>
          <short_desc>Setting a link@rel=stylesheet to disabled should fully clear the stylesheet (set ownerNode=null)</short_desc>
          <delta_ts>2023-10-25 02:20:25 -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>WebKit Nightly Build</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          <see_also>https://bugs.webkit.org/show_bug.cgi?id=212515</see_also>
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>BrowserCompat, InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          <dependson>263021</dependson>
          
          <everconfirmed>1</everconfirmed>
          <reporter name="sideshowbarker">mike</reporter>
          <assigned_to name="sideshowbarker">mike</assigned_to>
          <cc>ahmad.saleem792</cc>
    
    <cc>annevk</cc>
    
    <cc>cdumez</cc>
    
    <cc>commit-queue</cc>
    
    <cc>karlcow</cc>
    
    <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1973169</commentid>
    <comment_count>0</comment_count>
    <who name="sideshowbarker">mike</who>
    <bug_when>2023-08-23 18:46:27 -0700</bug_when>
    <thetext>&lt;link rel=stylesheet disabled&gt; should cause the corresponding stylesheet’s ownerNode to be set to null.

Note that this is separate (I think) from fully implementing what’s in https://github.com/whatwg/html/pull/4519.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1973170</commentid>
    <comment_count>1</comment_count>
    <who name="sideshowbarker">mike</who>
    <bug_when>2023-08-23 18:52:15 -0700</bug_when>
    <thetext>Pull request: https://github.com/WebKit/WebKit/pull/17001</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1974600</commentid>
    <comment_count>2</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2023-08-30 18:47:19 -0700</bug_when>
    <thetext>&lt;rdar://problem/114736719&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1984121</commentid>
    <comment_count>3</comment_count>
    <who name="EWS">ews-feeder</who>
    <bug_when>2023-10-10 14:12:10 -0700</bug_when>
    <thetext>Committed 269168@main (9ae24bdf27c4): &lt;https://commits.webkit.org/269168@main&gt;

Reviewed commits have been landed. Closing PR #17001 and removing active labels.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1984316</commentid>
    <comment_count>4</comment_count>
    <who name="Chris Dumez">cdumez</who>
    <bug_when>2023-10-11 09:46:21 -0700</bug_when>
    <thetext>I suspect this introduced crashes in debug on various CSS tests:
```
Thread 0 Crashed::  Dispatch queue: com.apple.main-thread
0   JavaScriptCore                	       0x138a02244 WTFCrash + 24 (Assertions.cpp:333)
1   WebCore                       	       0x282d078ac WTFCrashWithInfo(int, char const*, char const*, int) + 36 (Assertions.h:778)
2   WebCore                       	       0x284134440 WebCore::HTMLLinkElement::clearSheet() + 240 (HTMLLinkElement.cpp:374)
3   WebCore                       	       0x2841346c0 WebCore::HTMLLinkElement::removedFromAncestor(WebCore::Node::RemovalType, WebCore::ContainerNode&amp;) + 152 (HTMLLinkElement.cpp:408)
4   WebCore                       	       0x283aed8d4 WebCore::notifyNodeRemovedFromDocument(WebCore::ContainerNode&amp;, WebCore::TreeScopeChange, WebCore::Node&amp;) + 324 (ContainerNodeAlgorithms.cpp:126)
5   WebCore                       	       0x283aed9c8 WebCore::notifyNodeRemovedFromDocument(WebCore::ContainerNode&amp;, WebCore::TreeScopeChange, WebCore::Node&amp;) + 568 (ContainerNodeAlgorithms.cpp:134)
6   WebCore                       	       0x283aed9c8 WebCore::notifyNodeRemovedFromDocument(WebCore::ContainerNode&amp;, WebCore::TreeScopeChange, WebCore::Node&amp;) + 568 (ContainerNodeAlgorithms.cpp:134)
7   WebCore                       	       0x283aed6f4 WebCore::notifyChildNodeRemoved(WebCore::ContainerNode&amp;, WebCore::Node&amp;) + 204 
```</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1984320</commentid>
    <comment_count>5</comment_count>
    <who name="WebKit Commit Bot">commit-queue</who>
    <bug_when>2023-10-11 10:02:51 -0700</bug_when>
    <thetext>Re-opened since this is blocked by bug 263021</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1985305</commentid>
    <comment_count>6</comment_count>
    <who name="sideshowbarker">mike</who>
    <bug_when>2023-10-16 06:07:03 -0700</bug_when>
    <thetext>For the record here: this is a compat/interop issue, because Blink and Gecko both pass these tests:

- https://wpt.fyi/results/css/cssom/HTMLLinkElement-disabled-002.html
- https://wpt.fyi/results/css/cssom/HTMLLinkElement-disabled-002.html

…while Safari does not pass those tests.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1986007</commentid>
    <comment_count>7</comment_count>
    <who name="sideshowbarker">mike</who>
    <bug_when>2023-10-18 16:47:55 -0700</bug_when>
    <thetext>I can’t reproduce any crashes in a local debug build with any of the fast/css tests — even running 100+ iterations at a time. Is there something additional I can be doing to try to reproduce the crashes?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1986156</commentid>
    <comment_count>8</comment_count>
    <who name="Chris Dumez">cdumez</who>
    <bug_when>2023-10-19 08:32:56 -0700</bug_when>
    <thetext>(In reply to sideshowbarker from comment #7)
&gt; I can’t reproduce any crashes in a local debug build with any of the
&gt; fast/css tests — even running 100+ iterations at a time. Is there something
&gt; additional I can be doing to try to reproduce the crashes?

Weird. The reason for the crash seems pretty obvious, no?

In HTMLLinkElement::clearSheet() we have this assertion:
```
    ASSERT(m_sheet-&gt;ownerNode() == this);
```

Because we always expect to be the owner of m_sheet.

However, in your patch, you added a call to `m_sheet-&gt;clearOwnerNode();` but didn&apos;t clear m_sheet. As a result, m_sheet&apos;s owner is nullptr.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1986158</commentid>
    <comment_count>9</comment_count>
    <who name="Chris Dumez">cdumez</who>
    <bug_when>2023-10-19 08:45:33 -0700</bug_when>
    <thetext>I just applied your patch then ran the layout tests like so:
```
run-webkit-tests --debug --no-build fast/css
```

fast/css/list-item-pseudo-nocrash.html crashed with:
```
Thread 0 Crashed::  Dispatch queue: com.apple.main-thread
0   JavaScriptCore                	       0x139f15244 WTFCrash + 24
1   WebCore                       	       0x282d1ccac WTFCrashWithInfo(int, char const*, char const*, int) + 36 (Assertions.h:778)
2   WebCore                       	       0x284157b70 WebCore::HTMLLinkElement::clearSheet() + 240 (HTMLLinkElement.cpp:374)
3   WebCore                       	       0x284157df0 WebCore::HTMLLinkElement::removedFromAncestor(WebCore::Node::RemovalType, WebCore::ContainerNode&amp;) + 152 (HTMLLinkElement.cpp:408)
4   WebCore                       	       0x283b05254 WebCore::notifyNodeRemovedFromDocument(WebCore::ContainerNode&amp;, WebCore::TreeScopeChange, WebCore::Node&amp;) + 324 (ContainerNodeAlgorithms.cpp:126)
5   WebCore                       	       0x283b05348 WebCore::notifyNodeRemovedFromDocument(WebCore::ContainerNode&amp;, WebCore::TreeScopeChange, WebCore::Node&amp;) + 568 (ContainerNodeAlgorithms.cpp:134)
6   WebCore                       	       0x283b05348 WebCore::notifyNodeRemovedFromDocument(WebCore::ContainerNode&amp;, WebCore::TreeScopeChange, WebCore::Node&amp;) + 568 (ContainerNodeAlgorithms.cpp:134)
7   WebCore                       	       0x283b05074 WebCore::notifyChildNodeRemoved(WebCore::ContainerNode&amp;, WebCore::Node&amp;) + 204 (ContainerNodeAlgorithms.cpp:178)
8   WebCore                       	       0x283afe20c WebCore::removeDetachedChildrenInContainer(WebCore::ContainerNode&amp;) + 404 (ContainerNodeAlgorithms.cpp:198)
9   WebCore                       	       0x283afe02c WebCore::ContainerNode::removeDetachedChildren() + 172 (ContainerNode.cpp:348)
10  WebCore                       	       0x283b6e3f4 WebCore::Document::removedLastRef() + 580 (Document.cpp:828)
11  WebCore                       	       0x283d58050 WebCore::Node::removedLastRef() + 160 (Node.cpp:2645)
12  WebCore                       	       0x283279a10 WebCore::Node::deref() const + 568 (Node.h:822)
13  WebCore                       	       0x283ae66d4 WTF::Ref&lt;WebCore::ContainerNode, WTF::RawPtrTraits&lt;WebCore::ContainerNode&gt;&gt;::~Ref() + 76 (Ref.h:61)
14  WebCore                       	       0x283ad9700 WTF::Ref&lt;WebCore::ContainerNode, WTF::RawPtrTraits&lt;WebCore::ContainerNode&gt;&gt;::~Ref() + 32 (Ref.h:55)
15  WebCore                       	       0x283adf5d8 WebCore::ChildNodeList::~ChildNodeList() + 96 (ChildNodeList.cpp:49)
```

I didn&apos;t check if more tests crash later on, I interrupted the run once I got one crash.

If you still have trouble reproducing, try passing `--additional-env-var=__XPC_JSC_slowPathAllocsBetweenGCs=10` to run-webkit-tests too to get more aggressive garbage collection.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1986360</commentid>
    <comment_count>10</comment_count>
    <who name="sideshowbarker">mike</who>
    <bug_when>2023-10-19 21:37:56 -0700</bug_when>
    <thetext>Pull request: https://github.com/WebKit/WebKit/pull/19331</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1986363</commentid>
    <comment_count>11</comment_count>
    <who name="sideshowbarker">mike</who>
    <bug_when>2023-10-19 21:51:17 -0700</bug_when>
    <thetext>(In reply to Chris Dumez from comment #8)
&gt; (In reply to sideshowbarker from comment #7)
&gt; &gt; I can’t reproduce any crashes in a local debug build with any of the
&gt; &gt; fast/css tests — even running 100+ iterations at a time. Is there something
&gt; &gt; additional I can be doing to try to reproduce the crashes?
&gt; 
&gt; Weird. The reason for the crash seems pretty obvious, no?

Yeah — what’s less clear to me now is why I ever had it calling m_sheet-&gt;clearOwnerNode() directly to begin with, rather than just calling clearSheet() (which clearly seems like the right and obvious thing to do).

But I still haven’t been able to reproduce the crash with fast/css/list-item-pseudo-nocrash.html locally — even after running “run-webkit-tests --debug --no-build --additional-env-var=__XPC_JSC_slowPathAllocsBetweenGCs=10 fast/css” — so what worries me is that if I couldn’t catch/reproduce the crash in my environment when I introduced the regression (and still can’t seem to reproduce it now…), I also might not be able to catch any other crash/regression another change might introduce.

Anyway, I guess it’s kind of moot as far as this particular issue/PR is concerned — because the right fix for it is clear (and is what https://github.com/WebKit/WebKit/pull/19331 now does).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1987342</commentid>
    <comment_count>12</comment_count>
    <who name="EWS">ews-feeder</who>
    <bug_when>2023-10-25 02:20:23 -0700</bug_when>
    <thetext>Committed 269753@main (123f48fb7964): &lt;https://commits.webkit.org/269753@main&gt;

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

    </bug>

</bugzilla>