Closed Bug 403199 Opened 17 years ago Closed 2 years ago

Leak logging confused with classes derived from classes supporting aggregation. (like nsSimpleNestedURI)

Categories

(Core :: XPCOM, defect)

defect

Tracking

()

RESOLVED FIXED
mozilla1.9.2a1

People

(Reporter: peterv, Assigned: bzbarsky)

References

Details

(Keywords: fixed1.9.1, helpwanted, Whiteboard: [ToDo: comment 17] [fixed1.9.1b4])

Attachments

(1 file)

I ran into this while trying to reproduce bug 399758: Serial Numbers of Leaked Objects: 12 @0x19754380 (0 references; 0 from COMPtrs) I was logging nsSimpleNestedURI. I think I know what is happening. nsSimpleNestedURI is derived from nsSimpleURI which supports aggregation. Because of aggregation the canonical nsISupports pointer for nsSimpleURI is not the nsSimpleURI itself. Calling AddRef/Release on the canonical nsISupports pointer will not call AddRef/Release on the nsSimpleURI itself. Calling AddRef/Release on the nsSimpleURI will call AddRef/Release on the canonical nsISupports pointer. In the case of a derived class this means that the AddRef/Release of the derived class will only be called when calling AddRef/Release on the nsSimpleURI itself. In this case the AddRef/Release calls were balanced (both through the derived class and through the canonical nsISupports pointer), but the Release for refcount 1 -> 0 didn't go through the derived class. The object was deleted properly, but the logging code in the implementation of AddRef/Release for the derived class was never called for refcount 0, and so we didn't register destruction for the derived class (see http://bonsai.mozilla.org/cvsblame.cgi?file=/mozilla/xpcom/base/nsTraceRefcntImpl.cpp&rev=1.110&mark=253-254#250).
Blocks: 418132
Blocks: 426821
Blocks: 427570
Blocks: 427904
[Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.9.1b1pre) Gecko/20080912014358 Minefield/3.1b1pre] (home, optim default) (W2Ksp4) Fwiw, I can reproduce leaking 1 nsSimpleNestedURI, by running (--browser-chrome) <objdir-Firefox_\_tests\testing\mochitest\browser\docshell\test\browser with "only" [ browser_bug134911.js browser_bug388121-1.js browser_bug388121-2.js browser_bug441169.js test-form_sjis.html ] If I remove any (more) of these files, the leak (report) stops :-|
Summary: Leak logging confused with classes derived from classes supporting aggregation → Leak logging confused with classes derived from classes supporting aggregation. (like nsSimpleNestedURI)
(In reply to comment #3) [Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.9.1b2pre) Gecko/20081120 Minefield/3.1b2pre] (home, optim default) (W2Ksp4) (http://hg.mozilla.org/mozilla-central/rev/20245c2d97d0) (After removing the (leaking) tests from bug 462545 and bug 465952,) I can't reproduce this leak anymore. I don't know if the previously leaking tests were modified, or if this bug was fixed...
Reftest leak error report was enabled today, and here is an intermittent leak: { http://tinderbox.mozilla.org/showlog.cgi?log=Firefox/1238936836.1238944390.2219.gz Linux mozilla-central unit test on 2009/04/05 06:07:16 TEST-UNEXPECTED-FAIL | runtests-leaks | leaked 64 bytes during test execution TEST-UNEXPECTED-FAIL | runtests-leaks | leaked 1 instance of nsSimpleNestedURI with size 64 bytes TinderboxPrint: reftest<br/>2875/0/138&nbsp;<em class="testfail">LEAK</em> }
Blocks: 438871
Flags: wanted1.9.2?
Whiteboard: [orange]
(In reply to comment #5) > Reftest leak error report was enabled today, Actually, in this very build ;->
Why do you think those failures are related to this bug? Why would any symptoms of this bug be intermittent?
Er, I suppose they'd be intermittent if it varies who does the last release on an object, so never mind... maybe.
If Serge is correct that this is the intermittent leak on tbox, then this is by far the most common source of unit test orange... Would just never calling AddRef/Release on the nsSimpleURI (and instead always calling it on its canonical nsISuports) fix the issue? Or even more simply, would switching nsSimpleNestedURI to not log its addref/release calls work? Note that I do thing Serge is correct, because while nsSimpleNestedURI shows as leaking, nsSimpleURI does NOT. Nor do any other objects.
Yeah, I think this is fallout from making the *_INHERITED macros log, which things really weren't designed for. I think the easy solution here would be just making nsSimpleNestedURI's AddRef and Release not log; it may well be good to have a set of INHERITED_ADDREF and INHERITED_RELEASE macros that don't log for the general case.
Comment on attachment 371877 [details] [diff] [review] How does this look? [Checkin: See comment 16 & 21] I guess you can get rid of the |nsrefcnt r| intermediate variable.
Comment on attachment 371877 [details] [diff] [review] How does this look? [Checkin: See comment 16 & 21] r+sr=dbaron with the elimination of the |r| variable in both
Attachment #371877 - Flags: superreview+
Attachment #371877 - Flags: review?(dbaron)
Attachment #371877 - Flags: review+
Status: NEW → RESOLVED
Closed: 16 years ago
Resolution: --- → FIXED
Shouldn't we search the tree for other classes derived from classes supporting aggregation before marking this fixed?
Ah, probably a good idea, yes.
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Attachment #371877 - Flags: approval1.9.1?
(In reply to comment #17) > Shouldn't we search the tree for other classes derived from classes supporting > aggregation How does one do this ?
Blocks: 458844
Status: REOPENED → NEW
Flags: wanted1.9.2?
Whiteboard: [orange] → [ToDo: comment 17] [orange]
Target Milestone: --- → mozilla1.9.2a1
Attachment #371877 - Flags: approval1.9.1? → approval1.9.1+
Comment on attachment 371877 [details] [diff] [review] How does this look? [Checkin: See comment 16 & 21] a191=beltzner
Attachment #371877 - Attachment description: How does this look? → How does this look? [Checkin: See comment 16 & 21]
Whiteboard: [ToDo: comment 17] [orange] → [ToDo: comment 17] [fixed1.9.1b4] [orange]
Blocks: 391976
No longer blocks: 458844
(In reply to comment #19) > > Shouldn't we search the tree for other classes derived from classes supporting > > aggregation > > How does one do this ? Are the followings part of the answer? http://mxr.mozilla.org/mozilla-central/ident?i=NS_DECL_AGGREGATED Referenced (in 5 files total) http://mxr.mozilla.org/mozilla1.9.1/ident?i=NS_DECL_AGGREGATED Referenced (in 8 files total) http://mxr.mozilla.org/mozilla-central/ident?i=NS_DECL_CYCLE_COLLECTING_AGGREGATED http://mxr.mozilla.org/mozilla1.9.1/ident?i=NS_DECL_CYCLE_COLLECTING_AGGREGATED Referenced in: * rdf/base/src/nsInMemoryDataSource.cpp
No longer blocks: 438871
Whiteboard: [ToDo: comment 17] [fixed1.9.1b4] [orange] → [ToDo: comment 17] [fixed1.9.1b4]
Severity: normal → S3

Code for this landed a long time ago. I think the aggregated stuff might even be gone now, though NS_IMPL_NONLOGGING_ADDREF_INHERITED is still around.

Status: NEW → RESOLVED
Closed: 16 years ago2 years ago
Resolution: --- → FIXED
Assignee: nobody → bzbarsky
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: