Closed Bug 289970 Opened 19 years ago Closed 19 years ago

The sanitizing serializer leaks parsers

Categories

(Core :: DOM: Serializers, defect)

x86
Windows XP
defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: mrbkap, Assigned: mrbkap)

Details

(Keywords: memory-leak)

Attachments

(1 file)

When I made the patch for bug 254989, I didn't fully realize that there was a
cycle between the parser and the content sinks. Therefore, my patch introduced a
leak of the parser and the content sink (and the various classes used by both of
them). I have a patch that fixes the leak, which I will attach shortly.
Attached patch fix the cycleSplinter Review
This fixes the cycle by having the content sink let go of the parser when the
parser is done with it (it calls DidBuildModel() when it's done).
Attachment #180420 - Flags: review?(ben.bucksch)
Status: NEW → ASSIGNED
Attachment #180420 - Flags: superreview?(bzbarsky)
Attachment #180420 - Flags: superreview?(bzbarsky) → superreview+
nsCOMPtr<nsIParser> temp(mParser); mParser = nsnull;

This looks iffy to me. Why is mParser = nsnull; insufficient? Doesn't that let
go of the reference? Alternatively a raw pointer and ADDREF/RELEASE?
I guess best would be a weak reference, if the parser is garanteed to be around
as long as you need it?

Anyways, all is fine with me. r=BenB.
Comment on attachment 180420 [details] [diff] [review]
fix the cycle

Marking this r+ based on comment 2 and requesting approval for 1.8b2 for this
leak fix.
Attachment #180420 - Flags: review?(ben.bucksch)
Attachment #180420 - Flags: review+
Attachment #180420 - Flags: approval1.8b2?
Ben, the problem with just setting |mParser = nsnull| or using a weak ref, is
that the parser may go away before the content sink does, which could
potentially cause problems. In the case of not using the temp nsCOMPtr, the sink
could get deleted before the assignment to mParser takes place, which would crash.
Comment on attachment 180420 [details] [diff] [review]
fix the cycle

a=asa
Attachment #180420 - Flags: approval1.8b2? → approval1.8b2+
Fix checked in.
Status: ASSIGNED → RESOLVED
Closed: 19 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: