Closed Bug 808146 Opened 12 years ago Closed 12 years ago

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]

Categories

(Core :: XPCOM, defect)

x86_64
Linux
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla19
Tracking Status
b2g18 --- fixed

People

(Reporter: dholbert, Assigned: dholbert)

References

(Blocks 1 open bug)

Details

Attachments

(1 file)

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.
Attached patch fixSplinter Review
Attachment #677852 - Flags: review?(bobbyholley+bmo)
Assignee: nobody → dholbert
Status: NEW → ASSIGNED
Blocks: buildwarning
Depends on: 771074
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: 12 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.

Attachment

General

Created:
Updated:
Size: