nsProxyRelease.h:156:356: warning: deleting object of polymorphic class type ‘nsMainThreadPtrHolder<nsIUrlClassifierLookupCallback>’ which has non-virtual destructor might cause undefined behaviour [-Wdelete-non-virtual-dtor]

RESOLVED FIXED in mozilla19

Status

()

defect
RESOLVED FIXED
7 years ago
7 years ago

People

(Reporter: dholbert, Assigned: dholbert)

Tracking

(Blocks 1 bug)

Trunk
mozilla19
x86_64
Linux
Points:
---
Dependency tree / graph
Bug Flags:
in-testsuite -

Firefox Tracking Flags

(b2g18 fixed)

Details

Attachments

(1 attachment)

Assignee

Description

7 years ago
Just noticed this mess of warning-spam, when building in url-classifier:
{
nsUrlClassifierDBService.cpp
In file included from /scratch/work/builds/mozilla-central/mozilla-central.10-12-09.12-05/mozilla/toolkit/components/url-classifier/nsUrlClassifierProxies.h:10:0,
                 from /scratch/work/builds/mozilla-central/mozilla-central.10-12-09.12-05/mozilla/toolkit/components/url-classifier/nsUrlClassifierDBService.cpp:23:
../../../dist/include/nsProxyRelease.h: In instantiation of ‘nsrefcnt nsMainThreadPtrHolder<T>::Release() [with T = nsIUrlClassifierLookupCallback; nsrefcnt = unsigned int]’:
../../../dist/include/nsAutoPtr.h:874:13:   required from ‘nsRefPtr<T>::~nsRefPtr() [with T = nsMainThreadPtrHolder<nsIUrlClassifierLookupCallback>]’
../../../dist/include/nsProxyRelease.h:159:7:   required from here
../../../dist/include/nsProxyRelease.h:156:356: warning: deleting object of polymorphic class type ‘nsMainThreadPtrHolder<nsIUrlClassifierLookupCallback>’ which has non-virtual destructor might cause undefined behaviour [-Wdelete-non-virtual-dtor]
../../../dist/include/nsProxyRelease.h: In instantiation of ‘nsrefcnt nsMainThreadPtrHolder<T>::Release() [with T = nsIUrlClassifierCallback; nsrefcnt = unsigned int]’:
../../../dist/include/nsAutoPtr.h:874:13:   required from ‘nsRefPtr<T>::~nsRefPtr() [with T = nsMainThreadPtrHolder<nsIUrlClassifierCallback>]’
../../../dist/include/nsProxyRelease.h:159:7:   required from here
../../../dist/include/nsProxyRelease.h:156:356: warning: deleting object of polymorphic class type ‘nsMainThreadPtrHolder<nsIUrlClassifierCallback>’ which has non-virtual destructor might cause undefined behaviour [-Wdelete-non-virtual-dtor]
../../../dist/include/nsProxyRelease.h: In instantiation of ‘nsrefcnt nsMainThreadPtrHolder<T>::Release() [with T = nsIUrlClassifierUpdateObserver; nsrefcnt = unsigned int]’:
../../../dist/include/nsAutoPtr.h:874:13:   required from ‘nsRefPtr<T>::~nsRefPtr() [with T = nsMainThreadPtrHolder<nsIUrlClassifierUpdateObserver>]’
../../../dist/include/nsProxyRelease.h:159:7:   required from here
../../../dist/include/nsProxyRelease.h:156:356: warning: deleting object of polymorphic class type ‘nsMainThreadPtrHolder<nsIUrlClassifierUpdateObserver>’ which has non-virtual destructor might cause undefined behaviour [-Wdelete-non-virtual-dtor]
nsUrlClassifierProxies.cpp
In file included from /scratch/work/builds/mozilla-central/mozilla-central.10-12-09.12-05/mozilla/toolkit/components/url-classifier/nsUrlClassifierProxies.h:10:0,
                 from /scratch/work/builds/mozilla-central/mozilla-central.10-12-09.12-05/mozilla/toolkit/components/url-classifier/nsUrlClassifierProxies.cpp:6:
../../../dist/include/nsProxyRelease.h: In instantiation of ‘nsrefcnt nsMainThreadPtrHolder<T>::Release() [with T = nsIUrlClassifierLookupCallback; nsrefcnt = unsigned int]’:
../../../dist/include/nsAutoPtr.h:874:13:   required from ‘nsRefPtr<T>::~nsRefPtr() [with T = nsMainThreadPtrHolder<nsIUrlClassifierLookupCallback>]’
../../../dist/include/nsProxyRelease.h:159:7:   required from here
../../../dist/include/nsProxyRelease.h:156:356: warning: deleting object of polymorphic class type ‘nsMainThreadPtrHolder<nsIUrlClassifierLookupCallback>’ which has non-virtual destructor might cause undefined behaviour [-Wdelete-non-virtual-dtor]
../../../dist/include/nsProxyRelease.h: In instantiation of ‘nsrefcnt nsMainThreadPtrHolder<T>::Release() [with T = nsIUrlClassifierCallback; nsrefcnt = unsigned int]’:
../../../dist/include/nsAutoPtr.h:874:13:   required from ‘nsRefPtr<T>::~nsRefPtr() [with T = nsMainThreadPtrHolder<nsIUrlClassifierCallback>]’
../../../dist/include/nsProxyRelease.h:159:7:   required from here
../../../dist/include/nsProxyRelease.h:156:356: warning: deleting object of polymorphic class type ‘nsMainThreadPtrHolder<nsIUrlClassifierCallback>’ which has non-virtual destructor might cause undefined behaviour [-Wdelete-non-virtual-dtor]
../../../dist/include/nsProxyRelease.h: In instantiation of ‘nsrefcnt nsMainThreadPtrHolder<T>::Release() [with T = nsIUrlClassifierUpdateObserver; nsrefcnt = unsigned int]’:
../../../dist/include/nsAutoPtr.h:874:13:   required from ‘nsRefPtr<T>::~nsRefPtr() [with T = nsMainThreadPtrHolder<nsIUrlClassifierUpdateObserver>]’
../../../dist/include/nsProxyRelease.h:159:7:   required from here
../../../dist/include/nsProxyRelease.h:156:356: warning: deleting object of polymorphic class type ‘nsMainThreadPtrHolder<nsIUrlClassifierUpdateObserver>’ which has non-virtual destructor might cause undefined behaviour [-Wdelete-non-virtual-dtor]
}

Easy to fix -- we just need to declare nsMainThreadPtrHolder as MOZ_FINAL, so the compiler doesn't worry about potential subclasses trying & failing to override its destructor.
Assignee

Comment 1

7 years ago
Posted patch fixSplinter Review
Attachment #677852 - Flags: review?(bobbyholley+bmo)
Assignee

Updated

7 years ago
Assignee: nobody → dholbert
Status: NEW → ASSIGNED
Assignee

Updated

7 years ago
Blocks: buildwarning
Assignee

Updated

7 years ago
Depends on: 771074
Assignee

Comment 2

7 years ago
FWIW, this warning started with the landing of bug 795281, which added the first instantiation of nsMainThreadPtrHolder<> into the tree.
Depends on: 795281
Attachment #677852 - Flags: review?(bobbyholley+bmo) → review+
Yeah, that was one of the patches from a big patch stack I had, but gcp landed it earlier to fix some other stuff. I'm pretty sure this fix is also somewhere in my stack, but please go ahead and land this. Sorry for the trouble. :-)
https://hg.mozilla.org/mozilla-central/rev/7b2ba9e2d17f
Status: ASSIGNED → RESOLVED
Closed: 7 years ago
Flags: in-testsuite-
Resolution: --- → FIXED
Target Milestone: --- → mozilla19
You need to log in before you can comment on or make changes to this bug.