Closed
Bug 814470
Opened 13 years ago
Closed 13 years ago
AsyncFetchAndSetIconFromNetwork may leak channel when setup fails
Categories
(Toolkit :: Places, defect)
Toolkit
Places
Tracking
()
RESOLVED
FIXED
mozilla20
People
(Reporter: nmaier, Assigned: nmaier)
References
Details
Attachments
(1 file, 2 obsolete files)
4.49 KB,
patch
|
akeybl
:
approval-mozilla-aurora+
akeybl
:
approval-mozilla-b2g18+
|
Details | Diff | Splinter Review |
The AsyncFetchAndSetIconFromNetwork helper tracks the associated channel in the mChannel member. In ::Run, the channel setup may fail in such a way that a leak is created, e.g. when the nsIChannel::AsyncOpen fails, as the channel references AFASIFN and vice versa, creating circular references.
This blocks bug 719180, which changes the jar channel implementation so that ::AsyncOpen there will fail early in some cases (instead of failing in OnStopRequest later). Please note that even without said changes ::AsyncOpen may fail causing a leak in this helper.
Assignee | ||
Comment 1•13 years ago
|
||
Do not track the channel in the first place, thus avoiding a circular references
Marco, since you seem to have written the original code, can you please review?
Assignee | ||
Comment 2•13 years ago
|
||
Green try: https://tbpl.mozilla.org/?tree=Try&rev=d823eea1abc0
The patch does not depend on the bug 719180 patches on top.
Comment 3•13 years ago
|
||
Does AsyncOpen ensure the channel stays alive by itself until done? Otherwise, would it be fine to just null mChannel if AsyncOpen fails?
Regarding the change to AsyncFetchAndSetIconFromNetwork::OnStopRequest, in which case we we may reach that point with a success status code, but unable to QI the request to nsIChannel? Note that in any case GetExpirationTimeFromChannel should be capable to handle invalid argument by itself, at a maximum we may add an abort to ensure doesn't happen.
Regardless all of this, please try to keep changes to a minimum, there's no need to do all of that "cleanup" (like the NS_ENSURE_SUCCESS replacements, or moving nsresult) just to fix this bug.
Assignee | ||
Comment 4•13 years ago
|
||
(In reply to Marco Bonardo [:mak] from comment #3)
> Does AsyncOpen ensure the channel stays alive by itself until done?
AFAIK, yes. As long as AsyncOpen succeeded, something will always strong-ref the channel until OnStopRequest.
> Regarding the change to AsyncFetchAndSetIconFromNetwork::OnStopRequest, in
> which case we we may reach that point with a success status code, but unable
> to QI the request to nsIChannel?
This should always QI to nsIChannel, yes. MOZ_ASSERT would work as well to make sure of that.
Comment 5•13 years ago
|
||
Comment on attachment 684460 [details] [diff] [review]
Fix a leak when channel setup in AsyncFetchAndSetIconFromNetwork fails
Review of attachment 684460 [details] [diff] [review]:
-----------------------------------------------------------------
Ok, so I'd just like to get a minimal patch without code polish
Attachment #684460 -
Flags: review?(mak77)
Assignee | ||
Comment 6•13 years ago
|
||
Comments addressed
Attachment #684460 -
Attachment is obsolete: true
Attachment #685287 -
Flags: review?(mak77)
Comment 7•13 years ago
|
||
Comment on attachment 685287 [details] [diff] [review]
Bug 814470: Fix a leak when channel setup in AsyncFetchAndSetIconFromNetwork fails
Review of attachment 685287 [details] [diff] [review]:
-----------------------------------------------------------------
It looks good, thank you.
::: toolkit/components/places/AsyncFaviconHelpers.cpp
@@ +565,5 @@
> nsCOMPtr<nsIURI> iconURI;
> nsresult rv = NS_NewURI(getter_AddRefs(iconURI), mIcon.spec);
> NS_ENSURE_SUCCESS(rv, rv);
> +
> + nsCOMPtr<nsIChannel> channel;
nit: the added empty like doesn't look needed here
Attachment #685287 -
Flags: review?(mak77) → review+
Assignee | ||
Comment 8•13 years ago
|
||
Same patch, sans that newline.
Green try: https://tbpl.mozilla.org/?tree=Try&rev=240962f65a48
Assignee | ||
Updated•13 years ago
|
Keywords: checkin-needed
Updated•13 years ago
|
Attachment #685287 -
Attachment is obsolete: true
Comment 9•13 years ago
|
||
Keywords: checkin-needed
Comment 10•13 years ago
|
||
Status: ASSIGNED → RESOLVED
Closed: 13 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla20
Comment 11•13 years ago
|
||
Attachment #685574 -
Flags: approval-mozilla-b2g18?
Attachment #685574 -
Flags: approval-mozilla-aurora?
Updated•13 years ago
|
Attachment #685574 -
Flags: approval-mozilla-b2g18?
Attachment #685574 -
Flags: approval-mozilla-b2g18+
Attachment #685574 -
Flags: approval-mozilla-aurora?
Attachment #685574 -
Flags: approval-mozilla-aurora+
Comment 12•13 years ago
|
||
You need to log in
before you can comment on or make changes to this bug.
Description
•