Closed
Bug 323454
Opened 19 years ago
Closed 19 years ago
[FIX]Don't leak the channel and XMLHttpRequest object if AsyncOpen fails
Categories
(Core :: DOM: Core & HTML, defect, P3)
Core
DOM: Core & HTML
Tracking
()
VERIFIED
FIXED
mozilla1.9alpha1
People
(Reporter: martijn.martijn, Assigned: bzbarsky)
References
()
Details
(Keywords: fixed1.8.1, memory-leak, testcase)
Attachments
(2 files)
|
357 bytes,
text/html
|
Details | |
|
2.13 KB,
patch
|
Biesinger
:
review+
darin.moz
:
superreview+
darin.moz
:
approval-branch-1.8.1+
|
Details | Diff | Splinter Review |
When visiting the url, Mozilla leaks memory:
Summary:
Leaked 2 out of 10 DOM Windows
Leaked 3 out of 36 documents
Leaked 0 out of 4 docshells
I'll attach a testcase from that site that leaks 2 DOM Windows in Mozilla.
| Reporter | ||
Comment 1•19 years ago
|
||
Comment 2•19 years ago
|
||
Related to bug 206520? (XMLHttpRequest related)
| Reporter | ||
Comment 3•19 years ago
|
||
Maybe, except in this testcase, send is called and no event listener is set.
| Reporter | ||
Comment 4•19 years ago
|
||
Apparently, the testcase only leaks when testing locally.
| Assignee | ||
Comment 5•19 years ago
|
||
So the problem here is that OpenContentStream() throws for a nonexistent file:// URI in nsBaseChannel::AsyncOpen. And then we leak because the XMLHttpRequest has the channel in mChannel and the channel has a ref to XMLHttpRequest via the notification callbacks.
Should nsBaseChannel::AsyncOpen drop notification callbacks on any failure? Or should XMLHttpRequest null out mChannel? Or both, perhaps?
Note that this issue is specific to file:// URIs, so the MSN money thing is likely a different issue...
Comment 6•19 years ago
|
||
this would, obviously, be fixed if nonexistant file uris didn't throw in asyncopen, right?
I don't think AsyncOpen should drop notificationCallbacks in this case. maybe xmlhttprequest should set them to null explicitly.
| Assignee | ||
Comment 7•19 years ago
|
||
> this would, obviously, be fixed if nonexistant file uris didn't throw in
> asyncopen, right?
True, but I was wondering about the general behavior (eg if allocating an nsInputStreamPump is OOM).
Is doing anything with a channel after AsyncOpen() fails supported?
Comment 8•19 years ago
|
||
Any caller of nsIChannel::AsyncOpen needs to be prepared for it to fail. The particulars of why it fails here aren't really relevant. XMLHttpRequest should ensure that if AsyncOpen fails that it breaks any reference cycles it may have created. I vote for having XMLHttpRequest clear the channel's notification callbacks in this error case.
| Assignee | ||
Comment 9•19 years ago
|
||
Actually, I was thinking it should just drop the mChannel ref if the AsyncOpen fails.
That said, we should probably check on other AsyncOpen callers and see whether they suffer from similar problems...
Comment 10•19 years ago
|
||
Agreed. Docshell avoids this by hooking up a weakref to itself as the notification callbacks for channels it creates.
| Assignee | ||
Comment 11•19 years ago
|
||
I skimmed the other AsyncOpen callers and they look ok to me.
Assignee: general → bzbarsky
Status: NEW → ASSIGNED
Attachment #212190 -
Flags: superreview?(darin)
Attachment #212190 -
Flags: review?(cbiesinger)
| Assignee | ||
Updated•19 years ago
|
OS: Windows XP → All
Priority: -- → P3
Hardware: PC → All
Summary: Memory leak when visiting MSN Money → [FIX]Memory leak when visiting MSN Money
Target Milestone: --- → mozilla1.9alpha
Comment 12•19 years ago
|
||
Comment on attachment 212190 [details] [diff] [review]
Proposed fix
ok, but chrome apps can access .channel. will they be confused to see the channel go away?
Attachment #212190 -
Flags: superreview?(darin) → superreview+
| Assignee | ||
Comment 13•19 years ago
|
||
Not sure... But they shouldn't be accessing it anyway after a failed AsyncOpen, since it's in an indeterminate state. Since they have no way to tell that, I think this is better than letting them mess with the channel at that point... I would be happy to document that on the interface.
| Reporter | ||
Comment 14•19 years ago
|
||
Thanks for that fix, Boris.
As soon as that fix gets checked in, I'll try to get a minimised testcase again (it's currently confusing to get different memory leaks when you test it locally).
Updated•19 years ago
|
Attachment #212190 -
Flags: review?(cbiesinger) → review+
| Assignee | ||
Comment 15•19 years ago
|
||
Fixed on trunk.
Status: ASSIGNED → RESOLVED
Closed: 19 years ago
Resolution: --- → FIXED
| Assignee | ||
Comment 16•19 years ago
|
||
Comment on attachment 212190 [details] [diff] [review]
Proposed fix
I think it's worth taking this on the branch.
Attachment #212190 -
Flags: approval-branch-1.8.1?(darin)
Updated•19 years ago
|
Summary: [FIX]Memory leak when visiting MSN Money → [FIX]Don't leak the channel and XMLHttpRequest object if AsyncOpen fails
Updated•19 years ago
|
Attachment #212190 -
Flags: approval-branch-1.8.1?(darin) → approval-branch-1.8.1+
| Reporter | ||
Comment 18•19 years ago
|
||
Verified fixed, using 2006-02-22 trunk build.
I still leak with the url as Boris already expected. I filed bug 328311 for it. (hoping I can make a minimal testcase of that).
Status: RESOLVED → VERIFIED
Updated•6 years ago
|
Component: DOM → DOM: Core & HTML
You need to log in
before you can comment on or make changes to this bug.
Description
•