Closed Bug 200094 Opened 22 years ago Closed 22 years ago

FTP control connection-related leaks

Categories

(Core Graveyard :: Networking: FTP, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: bryner, Assigned: dougt)

Details

(Keywords: memory-leak)

Attachments

(2 files)

We're no longer leaking nsFtpControlConnections, but its socket transport and some related objects are leaking. The reason is that there's a circular reference. I'll try my best to illustrate: nsFtpControlConnection | | (mOutStream) V nsPipeOutputStream ^ | (mSource) | nsStreamCopierIB ^ | (mNotify) | | (mSink) | V nsSocketOutputStream So, without any explicit cleanup, the SocketOutputStream (really nsSocketTransport) and the StreamCopierIB leak each other, causing the nsPipeOutputStream (really nsPipe) and the SocketTransportService to leak. This might be a symptom of a more generic problem (shouldn't these objects be able to clean up after themselves when you release all references to them?) I'll leave that question for Darin and Doug. We can easily break the cycle in this case though, by calling Close on mOutStream in nsFtpControlConnection::Disconnect.
Comment on attachment 119053 [details] [diff] [review] explicitly break the cycle Feel free to smack this down if there's a way to fix this generically.
Attachment #119053 - Flags: superreview?(darin)
Attachment #119053 - Flags: review?(dougt)
The above diagram is somewhat ambiguous... it's the nsPipeInputStream, not the nsPipeOutputStream, that's the nsStreamCopierIB's |mSource|. But they're both really just the pipe object.
bryner: zero'ing out mOutStream should be equivalent to calling Close on the output stream. notice that the pipe's output and input streams each have separate reference counts. though there is an overall reference count for the entire pipe object, there are separate read and write ref counts. when those individual ref counts go to zero, Close is called on the respective input or output stream. so, it sounds like there is an extra reference to the pipe's output stream somewhere.
Attached patch alternate patchSplinter Review
this patch also breaks the cycle. i'm still not entirely sure why the original code doesn't work. but, something about closing mOutStream first is critical.
Attachment #119053 - Flags: superreview?(darin)
Attachment #119053 - Flags: review?(dougt)
Attachment #119104 - Flags: superreview+
Attachment #119104 - Flags: review?(dougt)
Attachment #119104 - Flags: review?(dougt) → review+
At Darin's request I opened bug 200219 about the more general problem. I went ahead and checked in this patch.
Status: NEW → RESOLVED
Closed: 22 years ago
Resolution: --- → FIXED
Product: Core → Core Graveyard
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: