Closed Bug 8975 Opened 25 years ago Closed 25 years ago

Circular ref counting between nsHTMLFragmentContentSink and nsParser

Categories

(Core :: DOM: HTML Parser, defect, P3)

defect

Tracking

()

VERIFIED FIXED

People

(Reporter: akkzilla, Assigned: vidur)

Details

nsHTMLFragmentContentSink::SetParser addrefs the parser from the
nsHTMLFragmentContentSink; but nsParser::SetContentSink addrefs the content
sink.  We have a circular reference and neither the parser nor the content sink
is ever deleted.  This is a problem because nsHTMLFragmentContentSink maintains
a buffer which may need to be flushed, and it never gets the signal to flush it,
so the end of the fragment is lost.  (I'll work on fixing that problem
separately).

What's the policy on parser and sink ownership?  Neither creates the other -- so
which is master and should addref, which is slave and should not?

A good way to demonstrate this (to developers, I don't expect QA to do this
though if you have a debugger you're welcome to join in the fun) is to run
apprunner -edit, set breakpoints in both addref and release, and also in the
destructors (to see that they're never called) for both nsParser and
nsHTMLFragmentContentSink, then click somewhere in the editor window and type
alt-I (a debug key sequence hardwired to insert a small html fragment).  Then
count the addrefs and releases.
Assignee: rickg → vidur
Vidur -- since you create the parser and the sink, I think you own this problem.
I can fix it if you don't have time -- but my preference is to switch over to
core layout code.
Status: NEW → ASSIGNED
Target Milestone: M9
Yup. There's code in the HTMLContentSink to break the circular reference and I
forgot to include it. Fix will be checked in when the tree opens.
Status: ASSIGNED → RESOLVED
Closed: 25 years ago
Resolution: --- → FIXED
Fix checked in on 8/4. The circular reference is broken in DidBuildModel().
Whiteboard: 8/4 need response from reporter to verify
Status: RESOLVED → VERIFIED
Whiteboard: 8/4 need response from reporter to verify
You need to log in before you can comment on or make changes to this bug.