Bug 60872 - [WebKit2] handleMessageDelayed leaks replyEncoder if decoding fails
Summary: [WebKit2] handleMessageDelayed leaks replyEncoder if decoding fails
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit2 (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Darin Adler
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-05-15 23:56 PDT by Adam Barth
Modified: 2011-05-19 10:28 PDT (History)
10 users (show)

See Also:


Attachments
Patch (43.88 KB, patch)
2011-05-17 11:27 PDT, Darin Adler
andersca: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Adam Barth 2011-05-15 23:56:07 PDT
As I wrote in https://bugs.webkit.org/show_bug.cgi?id=60655#c3, I don't think the strict PassOwnPtr fix in https://trac.webkit.org/changeset/86296/trunk/Source/WebKit2/Platform/CoreIPC/HandleMessage.h is correct:

--->8---
I'm not sure this patch is right.  Does that mean we're supposed to leak the replyEncoder if the arguments fail to decode?  If this function is supposed take ownership, It seems more likely we should change the parameter to be a PassOwnPtr.

I tried chasing this for a while, but it mushroomed out of control pretty fast.  I suspect there's a memory management bug here somewhere.

For example, consider PluginControllerProxy::didReceiveSyncPluginControllerProxyMessage.  Whether this function eventually calls delete on its third argument appears to depend on the MessageID.
---8<---

I don't understand this code well enough to know whether this is a real problem, but the code looks really fishy.
Comment 1 Darin Adler 2011-05-16 08:27:04 PDT
Anders might know.
Comment 2 Darin Adler 2011-05-16 08:28:24 PDT
I think the title of this bug is wrong. I’ll retitle after exploring the code for a moment.
Comment 3 Darin Adler 2011-05-16 08:31:08 PDT
As of this writing, handleMessageDelayed is only used for the HandleMouseEventID and GetPluginProcessConnectionID messages.
Comment 4 Darin Adler 2011-05-16 08:34:38 PDT
Yes, there is a leak here when arguments fail to decode. A good way to fix that would be to put the adoptPtr should be in generated code and have handleMessageDelayed take a PassOwnPtr, as Adam seems to be suggesting.

Otherwise, this works fine although it’s a bit awkward. The difference in encoder lifetime is controlled by Connection::dispatchSyncMessage, which calls leakPtr when the reply mode is ManualReply.
Comment 5 Darin Adler 2011-05-17 11:27:47 PDT
Created attachment 93801 [details]
Patch
Comment 6 Darin Adler 2011-05-18 18:36:46 PDT
Committed r86812: <http://trac.webkit.org/changeset/86812>
Comment 9 Darin Adler 2011-05-19 10:02:49 PDT
I see now:

1) I know how to run them.
2) Philippe Normand fixed this for me. Thank you!
Comment 10 Eric Seidel (no email) 2011-05-19 10:02:56 PDT
test-webkitpy runs all python tests (in 30 seconds).  We're working on removing some of the slow ones so that it will be back to < 5 seconds again soon!
Comment 11 Darin Adler 2011-05-19 10:07:59 PDT
(In reply to comment #10)
> test-webkitpy runs all python tests (in 30 seconds).  We're working on removing some of the slow ones so that it will be back to < 5 seconds again soon!

What confused me was the naming here being so different from other related things in WebKit.

When our main test runner is named run-webkit-tests, I would have expected the python test runner to be something like run-webkit-python-tests. Or maybe run-webkitpy-tests.

I was also surprised to learn that:

    1) The name of our python scripts is webkitpy. Seems kinda cryptic to me.
    2) There is a webkitpy directory, but the test-webkitpy script tests things outside that directory.

I think making things a bit more logical and consistent would have made it easier for me to find what I was looking for.
Comment 12 Eric Seidel (no email) 2011-05-19 10:13:06 PDT
(In reply to comment #11)
> (In reply to comment #10)
> > test-webkitpy runs all python tests (in 30 seconds).  We're working on removing some of the slow ones so that it will be back to < 5 seconds again soon!
> 
> What confused me was the naming here being so different from other related things in WebKit.

There was a long naming debate long ago.  I think Chris Jerdonek (who's since left the project) was the main proponent of test-* for test-webkitpy and test-webkitperl.  I'm happy to change them to run-python-tests and run-perl-tests if you'd prefer.

> When our main test runner is named run-webkit-tests, I would have expected the python test runner to be something like run-webkit-python-tests. Or maybe run-webkitpy-tests.
> 
> I was also surprised to learn that:
> 
>     1) The name of our python scripts is webkitpy. Seems kinda cryptic to me.

:shrug:  Again, happy to rename.  It was just the name picked when webkit-patch (then bugzilla-tool) was split out into more than one file and we needed a name for the directory containing said files.  .py is the python file extension.

>     2) There is a webkitpy directory, but the test-webkitpy script tests things outside that directory.

A sign of age.  It used to only test webkitpy.  Then we added more python for QueueStatusServer (queues.webkit.org, which uses python on Google App Engine) and then Adam Roben re-used it to test webkit2's python code.  These things probably all combine now to add weight to a rename decision.

> I think making things a bit more logical and consistent would have made it easier for me to find what I was looking for.

Again, happy to make changes if someone files a bug with concrete proposal.  I'm completely agnostic to the naming, but I can no longer see the forest between the trees here.
Comment 13 Dirk Pranke 2011-05-19 10:22:13 PDT
FWIW I am indifferent to whether we rename the files. Personally I'd also vote for moving at least webkitpy (and possibly webkitperl for consistency) somewhere up higher than under Tools/Scripts, and then hopefully being able to move the other python code underneath the new location. But I don't care enough to do much about it :)
Comment 14 Eric Seidel (no email) 2011-05-19 10:28:38 PDT
Again, they're there for historical reasons. :)  Python and perl both have a default import path of ., so its' easy to import webkitpy directly and webkitperl directly. If we moved them up to Tools, we'd have to do ..webkitpy in python and for perl I'm not even sure how you'd do that. :)