RESOLVED FIXED 88451
Extra HandleScope in V8Proxy
https://bugs.webkit.org/show_bug.cgi?id=88451
Summary Extra HandleScope in V8Proxy
Eriq Augustine
Reported 2012-06-06 13:42:02 PDT
Extra HandleScope in V8Proxy
Attachments
Patch (1.23 KB, patch)
2012-06-06 13:51 PDT, Eriq Augustine
no flags
Patch (5.35 KB, patch)
2012-06-06 16:06 PDT, Eriq Augustine
no flags
Archive of layout-test-results from ec2-cr-linux-04 (514.27 KB, application/zip)
2012-06-07 04:55 PDT, WebKit Review Bot
no flags
Patch (5.54 KB, patch)
2012-06-07 13:36 PDT, Eriq Augustine
no flags
Eriq Augustine
Comment 1 2012-06-06 13:51:30 PDT
WebKit Review Bot
Comment 2 2012-06-06 13:54:31 PDT
Attachment 146102 [details] did not pass style-queue: Failed to run "['Tools/Scripts/check-webkit-style', '--diff-files', u'Source/WebCore/ChangeLog', u'Source/WebCor..." exit_code: 1 Source/WebCore/ChangeLog:11: You should remove the 'No new tests' and either add and list tests, or explain why no new tests were possible. [changelog/nonewtests] [5] Total errors found: 1 in 1 files If any of these errors are false positives, please file a bug against check-webkit-style.
Eriq Augustine
Comment 3 2012-06-06 14:01:14 PDT
I have not been able to get a test to expose this error in WebKit alone, however I have got it to crash chromium. Regardless, I believe that there is a clear problem here. In V8Proxy::evaluateInIsolatedWorld(), the extra HandleScope will cause any Values placed into |results| to be destroyed with the HandleScope. The V8Proxy is only called from the v8 ScriptController, and a HandleScope is created there. The ScriptController then wraps any Value in a ScriptValue which internally uses a Persistent Handle, ensuring the safety of the Values. An alternative to just deleting the HandleScope would be to add the ability for a HandleScope to Close() around multiple Handles.
Adam Barth
Comment 4 2012-06-06 14:46:55 PDT
Comment on attachment 146102 [details] Patch I see, the problem is that we're trying to return local handles in |results|. Which function above this one is responsible for having a HandleScope?
Adam Barth
Comment 5 2012-06-06 14:48:35 PDT
I see what you've written in Comment #3. Can you be more specific about the functions involved? I can grep around the codebase, but that will delay feedback from me on this patch.
jochen
Comment 6 2012-06-06 14:52:51 PDT
What about making the result a v8::Array instead of a WTF::Vector?
Adam Barth
Comment 7 2012-06-06 14:59:22 PDT
> What about making the result a v8::Array instead of a WTF::Vector? You'd still need to have a v8::Local<v8::Array>. Wouldn't that have the same problem?
jochen
Comment 8 2012-06-06 15:00:30 PDT
(In reply to comment #7) > > What about making the result a v8::Array instead of a WTF::Vector? > > You'd still need to have a v8::Local<v8::Array>. Wouldn't that have the same problem? You can return a single handle from a handle scope. The v8::Array in turn would reference all the handles to the results, and so everything stays alive
Adam Barth
Comment 9 2012-06-06 15:09:41 PDT
> You can return a single handle from a handle scope. The v8::Array in turn would reference all the handles to the results, and so everything stays alive Woah, crazy. How is the lifetime of that handle managed? Maybe that only works if there's a HandleScope above you to manage the lifetime of the handle? I guess it depends on whether this HandleScope is redundant. If someone higher up on the stack is always holding a HandleScope, then probably should just delete this one.
jochen
Comment 10 2012-06-06 15:18:16 PDT
(In reply to comment #9) > > You can return a single handle from a handle scope. The v8::Array in turn would reference all the handles to the results, and so everything stays alive > > Woah, crazy. How is the lifetime of that handle managed? Maybe that only works if there's a HandleScope above you to manage the lifetime of the handle? Yes, it requires an outer handle scope. > I guess it depends on whether this HandleScope is redundant. If someone higher up on the stack is always holding a HandleScope, then probably should just delete this one. It seems less brittle to have a handlescope close to where you create handles, so it's clear what is supposed to survive and what is local only
Eriq Augustine
Comment 11 2012-06-06 16:06:00 PDT
Eriq Augustine
Comment 12 2012-06-06 16:06:54 PDT
(In reply to comment #10) > It seems less brittle to have a handlescope close to where you create handles, so it's clear what is supposed to survive and what is local only I agree. I went with the v8::Array solution.
Adam Barth
Comment 13 2012-06-06 16:08:09 PDT
Comment on attachment 146137 [details] Patch That's certainly very pretty.
WebKit Review Bot
Comment 14 2012-06-07 04:55:10 PDT
Comment on attachment 146137 [details] Patch Attachment 146137 [details] did not pass chromium-ews (chromium-xvfb): Output: http://queues.webkit.org/results/12919135 New failing tests: userscripts/window-onerror-for-isolated-world-1.html userscripts/window-onerror-for-isolated-world-2.html
WebKit Review Bot
Comment 15 2012-06-07 04:55:16 PDT
Created attachment 146256 [details] Archive of layout-test-results from ec2-cr-linux-04 The attached test failures were seen while running run-webkit-tests on the chromium-ews. Bot: ec2-cr-linux-04 Port: <class 'webkitpy.common.config.ports.ChromiumXVFBPort'> Platform: Linux-2.6.35-28-virtual-x86_64-with-Ubuntu-10.10-maverick
Eriq Augustine
Comment 16 2012-06-07 13:36:48 PDT
Eriq Augustine
Comment 17 2012-06-07 13:38:04 PDT
Comment on attachment 146372 [details] Patch Added a little safeguard incase evaluate returns an empty handle. I think v8::Array has a problem with being passed an empty handle.
Adam Barth
Comment 18 2012-06-13 10:00:05 PDT
Comment on attachment 146372 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=146372&action=review > Source/WebCore/bindings/v8/V8Proxy.cpp:263 > + if (evaluationResult.IsEmpty()) > + evaluationResult = v8::Local<v8::Value>::New(v8::Undefined()); Does this line make sense? I thought empty handles and v8::Undefined where the same...
Eriq Augustine
Comment 19 2012-06-13 11:09:19 PDT
(In reply to comment #18) > (From update of attachment 146372 [details]) > View in context: https://bugs.webkit.org/attachment.cgi?id=146372&action=review > > > Source/WebCore/bindings/v8/V8Proxy.cpp:263 > > + if (evaluationResult.IsEmpty()) > > + evaluationResult = v8::Local<v8::Value>::New(v8::Undefined()); > > Does this line make sense? I thought empty handles and v8::Undefined where the same... I don't think they act the same (at least in the context of v8:Arrays). I looked at how v8:Array Sets and it just dereferences the handle which asserts if the handle is empty
Adam Barth
Comment 20 2012-06-13 11:12:05 PDT
Comment on attachment 146372 [details] Patch Ok.
WebKit Review Bot
Comment 21 2012-06-13 11:45:58 PDT
Comment on attachment 146372 [details] Patch Clearing flags on attachment: 146372 Committed r120229: <http://trac.webkit.org/changeset/120229>
WebKit Review Bot
Comment 22 2012-06-13 11:46:04 PDT
All reviewed patches have been landed. Closing bug.
Note You need to log in before you can comment on or make changes to this bug.