Closed Bug 1035394 Opened 10 years ago Closed 10 years ago

Add dangerous public destructor detection to _INHERITED refcounting macros

Categories

(Core :: XPCOM, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla33

People

(Reporter: bjacob, Assigned: bjacob)

References

Details

Attachments

(25 files)

(deleted), patch
khuey
: review+
Details | Diff | Splinter Review
(deleted), patch
surkov
: review+
Details | Diff | Splinter Review
(deleted), patch
khuey
: review+
Details | Diff | Splinter Review
(deleted), patch
smaug
: review+
Details | Diff | Splinter Review
(deleted), patch
karlt
: review+
Details | Diff | Splinter Review
(deleted), patch
cpearce
: review+
Details | Diff | Splinter Review
(deleted), patch
padenot
: review+
Details | Diff | Splinter Review
(deleted), patch
smaug
: review+
Details | Diff | Splinter Review
(deleted), patch
cpearce
: review+
Details | Diff | Splinter Review
(deleted), patch
heycam
: review+
Details | Diff | Splinter Review
(deleted), patch
smaug
: review+
Details | Diff | Splinter Review
(deleted), patch
mrbkap
: review+
Details | Diff | Splinter Review
(deleted), patch
smaug
: review+
Details | Diff | Splinter Review
(deleted), patch
ehsan.akhgari
: review+
Details | Diff | Splinter Review
(deleted), patch
ehsan.akhgari
: review+
Details | Diff | Splinter Review
(deleted), patch
dbaron
: review+
Details | Diff | Splinter Review
(deleted), patch
mcmanus
: review+
Details | Diff | Splinter Review
(deleted), patch
wchen
: review+
Details | Diff | Splinter Review
(deleted), patch
briansmith
: review+
Details | Diff | Splinter Review
(deleted), patch
bent.mozilla
: review+
Details | Diff | Splinter Review
(deleted), patch
ehsan.akhgari
: review+
Details | Diff | Splinter Review
(deleted), patch
BenWa
: review+
Details | Diff | Splinter Review
(deleted), patch
smaug
: review+
Details | Diff | Splinter Review
(deleted), patch
roc
: review+
Details | Diff | Splinter Review
(deleted), patch
khuey
: review+
Details | Diff | Splinter Review
This is a follow-up of bug 1028588, which added such detection to much of nsISupportsImpl.h but left out _INHERITED macros.
Attached patch fix accessible (deleted) — — Splinter Review
Attachment #8451846 - Flags: review?(surkov.alexander)
Attached patch fix content/base (deleted) — — Splinter Review
Attachment #8451848 - Flags: review?(khuey)
Attached patch fix content/html (deleted) — — Splinter Review
Attachment #8451849 - Flags: review?(bzbarsky)
Attached patch fix content/mathml (deleted) — — Splinter Review
Attachment #8451850 - Flags: review?(karlt)
Attached patch fix content/media/eme (deleted) — — Splinter Review
Attachment #8451851 - Flags: review?(cpearce)
Attached patch fix content/media/webaudio (deleted) — — Splinter Review
Attachment #8451853 - Flags: review?(paul)
Attached patch fix content/media/webspeech (deleted) — — Splinter Review
Attachment #8451854 - Flags: review?(bugs)
Attached patch fix the rest of content/media (deleted) — — Splinter Review
Attachment #8451855 - Flags: review?(cpearce)
Comment on attachment 8451846 [details] [diff] [review]
fix accessible

Review of attachment 8451846 [details] [diff] [review]:
-----------------------------------------------------------------

rs=me

::: accessible/xul/XULListboxAccessible.cpp
@@ +742,5 @@
>  }
>  
> +XULListCellAccessible::~XULListCellAccessible()
> +{
> +}

any benefits of moving it into cpp file?
Attachment #8451846 - Flags: review?(surkov.alexander) → review+
Attached patch fix content/svg (deleted) — — Splinter Review
Attachment #8451856 - Flags: review?(cam)
Attached patch fix content/xml (deleted) — — Splinter Review
Attachment #8451858 - Flags: review?(bugs)
Attachment #8451851 - Flags: review?(cpearce) → review+
Attached patch fix content/xul (deleted) — — Splinter Review
Attachment #8451865 - Flags: review?(mrbkap)
Attached patch fix dom/events and event codegen (deleted) — — Splinter Review
Attachment #8451867 - Flags: review?(bugs)
Attached patch fix the rest of dom (deleted) — — Splinter Review
Attachment #8451868 - Attachment is patch: true
Attachment #8451868 - Flags: review?(ehsan)
Attached patch fix editor (deleted) — — Splinter Review
Attachment #8451870 - Flags: review?(ehsan)
Attached patch fix layout (deleted) — — Splinter Review
Attachment #8451871 - Flags: review?(dbaron)
Attached patch fix netwerk (deleted) — — Splinter Review
Attachment #8451872 - Flags: review?(mcmanus)
Attached patch fix parser (deleted) — — Splinter Review
Attachment #8451873 - Flags: review?(wchen)
Attachment #8451855 - Flags: review?(cpearce) → review+
Attached patch fix security (deleted) — — Splinter Review
Attachment #8451874 - Flags: review?(brian)
Attached patch fix storage (deleted) — — Splinter Review
Attachment #8451875 - Flags: review?(bent.mozilla)
Attached patch fix toolkit/components (deleted) — — Splinter Review
Attachment #8451876 - Flags: review?(ehsan)
Attached patch fix tools/profiler (deleted) — — Splinter Review
Attachment #8451877 - Flags: review?(bgirard)
Attached patch fix uriloader (deleted) — — Splinter Review
Attachment #8451880 - Flags: review?(bugs)
Attached patch fix widget (deleted) — — Splinter Review
Attachment #8451881 - Flags: review?(roc)
Attached patch fix xpcom (deleted) — — Splinter Review
Attachment #8451882 - Flags: review?(khuey)
Attachment #8451877 - Flags: review?(bgirard) → review+
Comment on attachment 8451849 [details] [diff] [review]
fix content/html

r+ except struct HasDangerousPublicDestructor<dom::HTMLFormElement> 
needs an explanation or a fix.
Attachment #8451849 - Flags: review?(bzbarsky) → review+
Attachment #8451865 - Flags: review?(mrbkap) → review+
Attachment #8451872 - Flags: review?(mcmanus) → review+
Attachment #8451875 - Flags: review?(bent.mozilla) → review+
Attachment #8451858 - Flags: review?(bugs) → review+
Attachment #8451880 - Flags: review?(bugs) → review+
Attachment #8451854 - Flags: review?(bugs) → review+
Attachment #8451867 - Flags: review?(bugs) → review+
Attachment #8451850 - Flags: review?(karlt) → review+
Attachment #8451856 - Flags: review?(cam) → review+
Attachment #8451874 - Flags: review?(brian) → review+
Attachment #8451871 - Flags: review?(dbaron) → review+
Attachment #8451873 - Flags: review?(wchen) → review+
Attachment #8451853 - Flags: review?(paul) → review+
Attachment #8451868 - Flags: review?(ehsan) → review+
Attachment #8451870 - Flags: review?(ehsan) → review+
Attachment #8451876 - Flags: review?(ehsan) → review+
Comment on attachment 8451848 [details] [diff] [review]
fix content/base

Review of attachment 8451848 [details] [diff] [review]:
-----------------------------------------------------------------

::: content/base/src/DOMQuad.cpp
@@ +137,5 @@
>      *aY2 = y2;
>    }
>  
>  protected:
> +  ~QuadBounds() {}

virtual please

::: content/base/src/nsObjectLoadingContent.cpp
@@ +390,5 @@
>    // nsITimerCallback
>    NS_IMETHOD Notify(nsITimer *timer);
>  
> +protected:
> +  ~nsStopPluginRunnable() {}

virtual please

::: content/base/src/nsXMLHttpRequest.h
@@ +172,5 @@
>      return mListenerManager && mListenerManager->HasListeners();
>    }
> +
> +private:
> +  ~nsXMLHttpRequestUpload() {}

virtual please
Attachment #8451848 - Flags: review?(khuey) → review+
(In reply to Olli Pettay [:smaug] from comment #27)
> Comment on attachment 8451849 [details] [diff] [review]
> fix content/html
> 
> r+ except struct HasDangerousPublicDestructor<dom::HTMLFormElement> 
> needs an explanation or a fix.

So if I make that destructor protected, I get:

 0:09.45 /home/bjacob/hack/mozilla-central/content/html/content/src/HTMLFormElement.cpp:75:12: error: calling a protected destructor of class 'mozilla::dom::HTMLFormElement'
 0:09.46     delete it;
 0:09.46            ^
 
The code in question is

http://dxr.mozilla.org/mozilla-central/source/content/html/content/src/HTMLFormElement.cpp#75

It looks very easy to fix. I'll file the followup bug as I land.
(In reply to alexander :surkov from comment #10)
> Comment on attachment 8451846 [details] [diff] [review]
> fix accessible
> 
> Review of attachment 8451846 [details] [diff] [review]:
> -----------------------------------------------------------------
> 
> rs=me
> 
> ::: accessible/xul/XULListboxAccessible.cpp
> @@ +742,5 @@
> >  }
> >  
> > +XULListCellAccessible::~XULListCellAccessible()
> > +{
> > +}
> 
> any benefits of moving it into cpp file?

None. That was just my default action to be able to process all the failures quickly. Indeed, that's the safe choice as it doesn't rely on all the definitions to be #included in the header file. But I tried, and in the present case, it works, even in non-unified build. So I'll do that.
(In reply to Kyle Huey [:khuey] (khuey@mozilla.com) from comment #28)
> virtual please

Done (x3).
Follow-up bugs to fix whitelisted dangerous destructors have been file; there were only 3. The tracking bug is bug 1028132.
https://hg.mozilla.org/mozilla-central/rev/959a72081da6
https://hg.mozilla.org/mozilla-central/rev/d44b04df56ae
https://hg.mozilla.org/mozilla-central/rev/f25ec3d47ca0
https://hg.mozilla.org/mozilla-central/rev/67b022015900
https://hg.mozilla.org/mozilla-central/rev/6af74fb23859
https://hg.mozilla.org/mozilla-central/rev/fcc1ebdf82c0
https://hg.mozilla.org/mozilla-central/rev/3f0f389821f7
https://hg.mozilla.org/mozilla-central/rev/821dd7192068
https://hg.mozilla.org/mozilla-central/rev/18dd3958f2f6
https://hg.mozilla.org/mozilla-central/rev/15ea98d307c5
https://hg.mozilla.org/mozilla-central/rev/e5f8bd650ef1
https://hg.mozilla.org/mozilla-central/rev/ad2e6df50240
https://hg.mozilla.org/mozilla-central/rev/cddfa382a2ba
https://hg.mozilla.org/mozilla-central/rev/f6fd4bafabdf
https://hg.mozilla.org/mozilla-central/rev/53bc1bd562ac
https://hg.mozilla.org/mozilla-central/rev/6e71cf4db1ad
https://hg.mozilla.org/mozilla-central/rev/dcd4f09949ce
https://hg.mozilla.org/mozilla-central/rev/74685fc519f4
https://hg.mozilla.org/mozilla-central/rev/bb3aaa6cdaa7
https://hg.mozilla.org/mozilla-central/rev/d070ae6e63cb
https://hg.mozilla.org/mozilla-central/rev/5821b55a574c
https://hg.mozilla.org/mozilla-central/rev/2f5b2fbae4fb
https://hg.mozilla.org/mozilla-central/rev/cd28b3d3a4bd
https://hg.mozilla.org/mozilla-central/rev/683e40882500
https://hg.mozilla.org/mozilla-central/rev/558231b7c91c
Assignee: nobody → bjacob
Status: NEW → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla33
Depends on: 1036619
Accidentally used this bug number in https://hg.mozilla.org/integration/b2g-inbound/rev/86702af059f4 . The intended bug number was bug 1036394.
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: