<?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>246294</bug_id>
          
          <creation_ts>2022-10-10 13:13:13 -0700</creation_ts>
          <short_desc>-Wuse-after-free from CSSValue.h</short_desc>
          <delta_ts>2022-10-11 14:07:31 -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>CSS</component>
          <version>WebKit Nightly Build</version>
          <rep_platform>PC</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>DUPLICATE</resolution>
          <dup_id>246292</dup_id>
          <see_also>https://bugs.webkit.org/show_bug.cgi?id=246292</see_also>
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Michael Catanzaro">mcatanzaro</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>bugs-noreply</cc>
    
    <cc>darin</cc>
    
    <cc>mcatanzaro</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1904583</commentid>
    <comment_count>0</comment_count>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2022-10-10 13:13:13 -0700</bug_when>
    <thetext>254846@main introduced a new GCC warning:

[3817/7121] Building CXX object Source/WebCore/CMakeFiles...edSources/unified-sources/UnifiedSource-2f84417a-18.cpp.o
In file included from /home/mcatanzaro/Projects/WebKit/Source/WebCore/css/CSSPrimitiveValue.h:26,
                 from /home/mcatanzaro/Projects/WebKit/Source/WebCore/css/parser/CSSParserToken.h:32,
                 from /home/mcatanzaro/Projects/WebKit/Source/WebCore/css/parser/CSSParserToken.cpp:31,
                 from /home/mcatanzaro/Projects/WebKit/WebKitBuild/gtk3/WebCore/DerivedSources/unified-sources/UnifiedSource-2f84417a-18.cpp:2:
In member function ‘void WebCore::CSSValue::deref() const’,
    inlined from ‘static void WTF::DefaultRefDerefTraits&lt; &lt;template-parameter-1-1&gt; &gt;::derefIfNotNull(T*) [with T = WebCore::CSSValue]’ at /home/mcatanzaro/Projects/WebKit/WebKitBuild/gtk3/WTF/Headers/wtf/RefPtr.h:42:23,
    inlined from ‘WTF::RefPtr&lt;T, &lt;template-parameter-1-2&gt;, &lt;template-parameter-1-3&gt; &gt;::~RefPtr() [with T = WebCore::CSSValue; _PtrTraits = WTF::RawPtrTraits&lt;WebCore::CSSValue&gt;; _RefDerefTraits = WTF::DefaultRefDerefTraits&lt;WebCore::CSSValue&gt;]’ at /home/mcatanzaro/Projects/WebKit/WebKitBuild/gtk3/WTF/Headers/wtf/RefPtr.h:74:61,
    inlined from ‘WTF::RefPtr&lt;WebCore::CSSValue&gt; WebCore::consumeContentDistributionOverflowPosition(CSSParserTokenRange&amp;, IsPositionKeyword)’ at /home/mcatanzaro/Projects/WebKit/Source/WebCore/css/parser/CSSPropertyParser.cpp:3049:5:
/home/mcatanzaro/Projects/WebKit/Source/WebCore/css/CSSValue.h:256:29: warning: pointer used after ‘static void WebCore::CSSValue::operator delete(WebCore::CSSValue*, std::destroying_delete_t)’ [-Wuse-after-free]
  256 |     unsigned tempRefCount = m_refCount - refCountIncrement;
      |                             ^~~~~~~~~~
In member function ‘void WebCore::CSSValue::deref() const’,
    inlined from ‘static void WTF::DefaultRefDerefTraits&lt; &lt;template-parameter-1-1&gt; &gt;::derefIfNotNull(T*) [with T = WebCore::CSSValue]’ at /home/mcatanzaro/Projects/WebKit/WebKitBuild/gtk3/WTF/Headers/wtf/RefPtr.h:42:23,
    inlined from ‘WTF::RefPtr&lt;T, &lt;template-parameter-1-2&gt;, &lt;template-parameter-1-3&gt; &gt;::~RefPtr() [with T = WebCore::CSSValue; _PtrTraits = WTF::RawPtrTraits&lt;WebCore::CSSValue&gt;; _RefDerefTraits = WTF::DefaultRefDerefTraits&lt;WebCore::CSSValue&gt;]’ at /home/mcatanzaro/Projects/WebKit/WebKitBuild/gtk3/WTF/Headers/wtf/RefPtr.h:74:61,
    inlined from ‘WTF::RefPtr&lt;WebCore::CSSValue&gt; WebCore::consumeContentDistributionOverflowPosition(CSSParserTokenRange&amp;, IsPositionKeyword)’ at /home/mcatanzaro/Projects/WebKit/Source/WebCore/css/parser/CSSPropertyParser.cpp:3048:51:
/home/mcatanzaro/Projects/WebKit/Source/WebCore/css/CSSValue.h:258:16: note: call to ‘static void WebCore::CSSValue::operator delete(WebCore::CSSValue*, std::destroying_delete_t)’ here
  258 |         delete this;
      |                ^~~~


Although &quot;use after free&quot; sounds scary, these warnings are always false positives. I don&apos;t think I&apos;ve ever seen this warning find a real bug. In this case, it&apos;s complaining that a value is used on line 256 after it&apos;s freed on line 258, which we humans know should be impossible, assuming no mismatched ref/derefs. That&apos;s admittedly a big assumption, but if it&apos;s violated anywhere I doubt we&apos;ll find it based on this warning....</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1904609</commentid>
    <comment_count>1</comment_count>
    <who name="Darin Adler">darin</who>
    <bug_when>2022-10-10 14:00:49 -0700</bug_when>
    <thetext>I agree with your analysis.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1904888</commentid>
    <comment_count>2</comment_count>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2022-10-11 14:07:31 -0700</bug_when>
    <thetext>

*** This bug has been marked as a duplicate of bug 246292 ***</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>