Bug 241516 - -Wmismatched-new-delete warning spam from CSSStyleValue.h
Summary: -Wmismatched-new-delete warning spam from CSSStyleValue.h
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: CSS (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Michael Catanzaro
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2022-06-10 11:22 PDT by Michael Catanzaro
Modified: 2022-06-21 15:01 PDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Catanzaro 2022-06-10 11:22:42 PDT
Unfortunately since this is a header file, it triggers a massive warning spam that exceeds my terminal scrollback. 
Sadly, I won't notice other compiler warnings until it is fixed:

In destructor ‘virtual WebCore::CSSStyleValue::~CSSStyleValue()’,
    inlined from ‘void std::default_delete<_Tp>::operator()(_Tp*) const [with _Tp = WebCore::CSSStyleValue]’ at /usr/include/c++/12/bits/unique_ptr.h:95:2,
    inlined from ‘void WTF::RefCounted<T, Deleter>::deref() const [with T = WebCore::CSSStyleValue; Deleter = std::default_delete<WebCore::CSSStyleValue>]’ at /home/mcatanzaro/Projects/WebKit/WebKitBuild/GNOME-gtk3/WTF/Headers/wtf/RefCounted.h:190:22,
    inlined from ‘void WTF::RefCounted<T, Deleter>::deref() const [with T = WebCore::CSSStyleValue; Deleter = std::default_delete<WebCore::CSSStyleValue>]’ at /home/mcatanzaro/Projects/WebKit/WebKitBuild/GNOME-gtk3/WTF/Headers/wtf/RefCounted.h:187:10,
    inlined from ‘WTF::Ref<T, <template-parameter-1-2> >::~Ref() [with T = WebCore::CSSUnitValue; Traits = WTF::RawPtrTraits<WebCore::CSSUnitValue>]’ at /home/mcatanzaro/Projects/WebKit/WebKitBuild/GNOME-gtk3/WTF/Headers/wtf/Ref.h:61:23,
    inlined from ‘JSC::EncodedJSValue WebCore::jsDOMCSSNamespaceConstructorFunction_chBody(JSC::JSGlobalObject*, JSC::CallFrame*)’ at /home/mcatanzaro/Projects/WebKit/WebKitBuild/GNOME-gtk3/WebCore/DerivedSources/JSDOMCSSNamespace.cpp:1015:5,
    inlined from ‘static JSC::EncodedJSValue WebCore::IDLOperation<JSClass>::callStatic(JSC::JSGlobalObject&, JSC::CallFrame&, const char*) [with JSC::EncodedJSValue (* operation)(JSC::JSGlobalObject*, JSC::CallFrame*) = WebCore::jsDOMCSSNamespaceConstructorFunction_chBody; WebCore::CastedThisErrorBehavior shouldThrow = WebCore::CastedThisErrorBehavior::Throw; JSClass = WebCore::JSDOMCSSNamespace]’ at /home/mcatanzaro/Projects/WebKit/Source/WebCore/bindings/js/JSDOMOperation.h:70:25,
    inlined from ‘JSC::EncodedJSValue WebCore::jsDOMCSSNamespaceConstructorFunction_ch(JSC::JSGlobalObject*, JSC::CallFrame*)’ at /home/mcatanzaro/Projects/WebKit/WebKitBuild/GNOME-gtk3/WebCore/DerivedSources/JSDOMCSSNamespace.cpp:1020:100:
/home/mcatanzaro/Projects/WebKit/Source/WebCore/css/typedom/CSSStyleValue.h:113:13: warning: ‘static void WebCore::CSSStyleValue::operator delete(void*)’ called on pointer returned from a mismatched allocation function [-Wmismatched-new-delete]
  113 |     virtual ~CSSStyleValue() = default;
      |             ^
In static member function ‘static WTF::Ref<WebCore::CSSUnitValue> WebCore::CSSUnitValue::create(double, WebCore::CSSUnitType)’,
    inlined from ‘static WTF::Ref<WebCore::CSSUnitValue> WebCore::CSSNumericFactory::ch(double)’ at /home/mcatanzaro/Projects/WebKit/Source/WebCore/css/typedom/CSSNumericFactory.h:54:104,
    inlined from ‘JSC::EncodedJSValue WebCore::jsDOMCSSNamespaceConstructorFunction_chBody(JSC::JSGlobalObject*, JSC::CallFrame*)’ at /home/mcatanzaro/Projects/WebKit/WebKitBuild/GNOME-gtk3/WebCore/DerivedSources/JSDOMCSSNamespace.cpp:1015:5,
    inlined from ‘static JSC::EncodedJSValue WebCore::IDLOperation<JSClass>::callStatic(JSC::JSGlobalObject&, JSC::CallFrame&, const char*) [with JSC::EncodedJSValue (* operation)(JSC::JSGlobalObject*, JSC::CallFrame*) = WebCore::jsDOMCSSNamespaceConstructorFunction_chBody; WebCore::CastedThisErrorBehavior shouldThrow = WebCore::CastedThisErrorBehavior::Throw; JSClass = WebCore::JSDOMCSSNamespace]’ at /home/mcatanzaro/Projects/WebKit/Source/WebCore/bindings/js/JSDOMOperation.h:70:25,
    inlined from ‘JSC::EncodedJSValue WebCore::jsDOMCSSNamespaceConstructorFunction_ch(JSC::JSGlobalObject*, JSC::CallFrame*)’ at /home/mcatanzaro/Projects/WebKit/WebKitBuild/GNOME-gtk3/WebCore/DerivedSources/JSDOMCSSNamespace.cpp:1020:100:
/home/mcatanzaro/Projects/WebKit/Source/WebCore/css/typedom/CSSUnitValue.h:43:116: note: returned from ‘static void* WebCore::CSSUnitValue::operator new(size_t)’
   43 |     static Ref<CSSUnitValue> create(double value, CSSUnitType unit) { return adoptRef(*new CSSUnitValue(value, unit)); }
      |                                                                                                                    ^

I'm frustrated that I do not see the problem. I think it must be somehow related to the WTF_MAKE_ISO_ALLOCATED, but I'm bamboozled as to what exactly is wrong. I wouldn't be surprised if GCC is just totally confused.
Comment 1 Michael Catanzaro 2022-06-10 11:39:12 PDT
I found a fix, but it makes no sense:

diff --git a/Source/WebCore/css/typedom/CSSStyleValue.h b/Source/WebCore/css/typedom/CSSStyleValue.h
index da615424d5c4..72f580a5facf 100644
--- a/Source/WebCore/css/typedom/CSSStyleValue.h
+++ b/Source/WebCore/css/typedom/CSSStyleValue.h
@@ -110,7 +110,10 @@ class CSSStyleValue : public RefCounted<CSSStyleValue>, public ScriptWrappable {
 public:
     String toString() const;
     virtual void serialize(StringBuilder&, OptionSet<SerializationArguments> = { }) const;
-    virtual ~CSSStyleValue() = default;
+    virtual ~CSSStyleValue()
+    {
+        m_customPropertyName = { };
+    }
 
     virtual CSSStyleValueType getType() const { return CSSStyleValueType::CSSStyleValue; }
 

If anybody knows a logical reason why this should make any difference....
Comment 2 Michael Catanzaro 2022-06-10 11:42:47 PDT
Pull request: https://github.com/WebKit/WebKit/pull/1448
Comment 3 Radar WebKit Bug Importer 2022-06-17 11:23:23 PDT
<rdar://problem/95401608>
Comment 4 EWS 2022-06-21 15:01:16 PDT
Committed r295692 (251697@main): <https://commits.webkit.org/251697@main>

Reviewed commits have been landed. Closing PR #1448 and removing active labels.