Closed Bug 302737 Opened 19 years ago Closed 19 years ago

[FIX]Plugins leak ns4xPluginStreamListeners and whatever they entrain

Categories

(Core Graveyard :: Plug-ins, defect, P2)

defect

Tracking

(Not tracked)

RESOLVED FIXED
mozilla1.9alpha1

People

(Reporter: bzbarsky, Assigned: bzbarsky)

References

()

Details

(Keywords: fixed1.8.0.7, fixed1.8.1, memory-leak)

Attachments

(1 file)

We end up leaking listeners that are allocated when a plugin calls NPN_GetURL,
with the following stack to the unbalanced addref:

NPN_GetURL (/home/bzbarsky/plugins/libflashplayer.so)
_geturl (../../../../../mozilla/modules/plugin/base/src/ns4xPlugin.cpp:964)
MakeNew4xStreamInternal(_NPP*, char const*, char const*, eNPPStreamTypeInternal,
int, void*, unsigned int, char const*, unsigned char)
(../../../../../mozilla/modules/plugin/base/src/ns4xPlugin.cpp:928)
ns4xPluginInstance::NewNotifyStream(nsIPluginStreamListener**, void*, int, char
const*) (../../../../../mozilla/modules/plugin/base/src/ns4xPluginInstance.cpp:1357)

And indeed, NewNotifyStream addrefs its our param and the caller never releases
it here.  Fixing that makes us crash, since
ns4xPluginStreamListener::CallURLNotify helpfully calls NS_RELEASE_THIS() with
the comment:

235   // Let's not leak this stream listener. Release the reference to the
stream listener 
236   // added for the notify callback in NewNotifyStream. 

Problem is, CallURLNotify has several early returns (in non-failure cases,
even).  So do the methods that call CallURLNotify.  The net result is that it's
pretty easy for us to leak this whole mess.

What I think should happen is that this NS_RELEASE_THIS() should be removed, and
that MakeNew4xStreamInternal should be just release its ptr.  To make sure this
is safe, though, have to trace through the ownership model between this class
and ns4xPluginInstance...
I'm guessing this is 1.9-type stuff at this point.... :(
Attachment #191025 - Flags: review?(jst)
Comment on attachment 191025 [details] [diff] [review]
Like this, perhaps?

I'm not going to claim I completely understand the ownership model for the
objects in question here, but from looking at this change and the surrounding
code it *seems* like this is indeed what we want here.

r=jst to give this some mileage on the trunk...
Attachment #191025 - Flags: review?(jst) → review+
Attachment #191025 - Flags: superreview?(dbaron)
Assignee: nobody → bzbarsky
Priority: -- → P2
Summary: Plugins leak ns4xPluginStreamListeners and whatever they entrain → [FIX]Plugins leak ns4xPluginStreamListeners and whatever they entrain
Target Milestone: --- → mozilla1.9alpha
Comment on attachment 191025 [details] [diff] [review]
Like this, perhaps?

jst, want to just make this an r+sr?
Attachment #191025 - Flags: superreview?(dbaron) → superreview?(jst)
Comment on attachment 191025 [details] [diff] [review]
Like this, perhaps?

Sure, sr=jst too.
Attachment #191025 - Flags: superreview?(jst) → superreview+
Fixed on trunk.
Status: NEW → RESOLVED
Closed: 19 years ago
Resolution: --- → FIXED
Is this leak worth fixing for 1.8.0.1 or 1.8.1?
Blocks: mlk1.8
Keywords: mlk
No idea.  More importantly, I can't give a risk evaluation here; I have no idea what this patch could break.
JST - thoughts on a branch patch for this?
Flags: blocking1.8.1?
Seems worth doing. It's been on the trunk long enough IMO, and this patch applies cleanly (though with some offset) to the branch as well so IMO we could just land this.
Flags: blocking1.8.0.6?
Attachment #191025 - Flags: approval1.8.1?
Flags: blocking1.8.1? → blocking1.8.1+
Target Milestone: mozilla1.9alpha → mozilla1.8.1beta2
Attachment #191025 - Flags: approval1.8.1? → approval1.8.1+
jst, want to land it now that it's approved?
Fixed on branch.  Hadn't realized this got approved...
Keywords: fixed1.8.1
Target Milestone: mozilla1.8.1beta2 → mozilla1.9alpha
Flags: blocking1.8.0.7? → blocking1.8.0.7+
Comment on attachment 191025 [details] [diff] [review]
Like this, perhaps?

approved for 1.8.0 branch, a=dveditz for drivers
Attachment #191025 - Flags: approval1.8.0.7+
Fixed for 1.8.0.7
Keywords: fixed1.8.0.7
Depends on: 354124
So this caused regression bug 354124...  No idea why.  :(
If my analysis in bug 354124 is correct, we probably need to back this out of branches....  and add more plug-in tests to whatever pre-release test suites we run, or not touch plug-in code on branches anymore.

I also feel that this bug is just another indication that trunk is really not getting enough testing in the various modes we support to base decisions on "there haven't been any problems on trunk".
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: