Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(443)

Issue 1375933003: Add SetAbortOnUncaughtExceptionCallback API (Closed)

Created:
5 years, 2 months ago by julien.gilli
Modified:
5 years, 2 months ago
CC:
v8-reviews_googlegroups.com, Paweł Hajdan Jr.
Base URL:
git@github.com:v8/v8.git@master
Target Ref:
refs/pending/heads/master
Project:
v8
Visibility:
Public.

Description

Add SetAbortOnUncaughtExceptionCallback API The --abort-on-uncaught-exception command line switch makes Isolate::Throw abort if the error being thrown cannot be caught by a try/catch block. Embedders may want to use other mechanisms than try/catch blocks to handle uncaught exceptions. For instance, Node.js has "domain" objects that have error handlers that can handle uncaught exception like following: var d = domain.create(); d.on('error', function onError(err) { console.log('Handling error'); }); d.run(function() { throw new Error("boom"); }); These error handlers are called by isolates' message listeners. If --abort-on-uncaught-exception is *not* used, the isolate's message listener will be called, which will in turn call the domain's error handler. The process will output 'Handling error' and will exit successfully (not due to an uncaught exception). This is the behavior that Node.js users expect. However, if --abort-on-uncaught-exception is used and when throwing an error within a domain that has an error handler, the process will abort and the domain's error handler will not be called. This is not the behavior that Node.js users expect. Having a SetAbortOnUncaughtExceptionCallback API allows embedders to determine when it's not appropriate to abort and instead handle the exception via the isolate's message listener. In the example above, Node.js would set a custom callback with SetAbortOnUncaughtExceptionCallback that would be implemented as following (the sample code has been simplified to remove what's not relevant to this change): bool ShouldAbortOnUncaughtException(Isolate* isolate) { return !IsDomainActive(); } Now when --abort-on-uncaught-exception is used, Isolate::Throw would call that callback and determine that it should not abort if a domain with an error handler is active. Instead, the isolate's message listener would be called and the error would be handled by the domain's error handler. I believe this can also be useful for other embedders. BUG= R=bmeurer@chromium.org Committed: https://crrev.com/1ee712ab8687e5f4dec93d45da068d37d28feb8b Cr-Commit-Position: refs/heads/master@{#31111}

Patch Set 1 #

Total comments: 22

Patch Set 2 : Update according to code review #

Total comments: 10

Patch Set 3 : Update after second code review #

Unified diffs Side-by-side diffs Delta from patch set Stats (+79 lines, -7 lines) Patch
M include/v8.h View 1 1 chunk +13 lines, -0 lines 0 comments Download
M src/api.cc View 1 1 chunk +7 lines, -0 lines 0 comments Download
M src/isolate.h View 1 2 chunks +6 lines, -0 lines 0 comments Download
M src/isolate.cc View 1 2 3 chunks +22 lines, -7 lines 0 comments Download
M test/cctest/test-api.cc View 1 2 1 chunk +31 lines, -0 lines 0 comments Download

Messages

Total messages: 28 (4 generated)
julien.gilli
5 years, 2 months ago (2015-09-30 22:09:56 UTC) #1
julien.gilli
On 2015/09/30 22:09:56, julien.gilli wrote: Please note that I'm submitting this as a request for ...
5 years, 2 months ago (2015-09-30 22:16:49 UTC) #2
Benedikt Meurer
API changes should be reviewed by the bindings team.
5 years, 2 months ago (2015-10-01 07:18:05 UTC) #4
Michael Starzinger
I don't have a strong opinion on whether we want to support this as part ...
5 years, 2 months ago (2015-10-01 16:34:39 UTC) #6
Michael Starzinger
https://codereview.chromium.org/1375933003/diff/1/include/v8.h File include/v8.h (right): https://codereview.chromium.org/1375933003/diff/1/include/v8.h#newcode5383 include/v8.h:5383: * If FLAG_abort_on_uncaught_exception is true, then V8 will abort ...
5 years, 2 months ago (2015-10-01 16:36:30 UTC) #7
IMPULsE13
On 2015/09/30 22:09:56, julien.gilli wrote:
5 years, 2 months ago (2015-10-01 19:09:53 UTC) #8
julien.gilli
Thank you for the review. Updated this changelist according to it, PTAL. https://codereview.chromium.org/1375933003/diff/1/include/v8.h File include/v8.h ...
5 years, 2 months ago (2015-10-01 19:18:11 UTC) #9
jochen (gone - plz use gerrit)
can you explain why you don't just make the message handler abort if no domain ...
5 years, 2 months ago (2015-10-02 13:19:13 UTC) #10
julien.gilli
On 2015/10/02 13:19:13, jochen wrote: > can you explain why you don't just make the ...
5 years, 2 months ago (2015-10-02 17:04:23 UTC) #11
jochen (gone - plz use gerrit)
On 2015/10/02 at 17:04:23, julien.gilli wrote: > On 2015/10/02 13:19:13, jochen wrote: > > can ...
5 years, 2 months ago (2015-10-05 15:12:06 UTC) #12
Michael Starzinger
LGTM on the implementation with one last suggestion. Two comments about the tests, I would ...
5 years, 2 months ago (2015-10-05 16:13:57 UTC) #13
Michael Starzinger
https://codereview.chromium.org/1375933003/diff/20001/test/cctest/test-abort-on-uncaught-exception.cc File test/cctest/test-abort-on-uncaught-exception.cc (right): https://codereview.chromium.org/1375933003/diff/20001/test/cctest/test-abort-on-uncaught-exception.cc#newcode37 test/cctest/test-abort-on-uncaught-exception.cc:37: bool NoAbortOnUncaughtException(v8::Isolate* isolate) { return false; } Also, we ...
5 years, 2 months ago (2015-10-05 16:18:39 UTC) #14
julien.gilli
On 2015/10/05 15:12:06, jochen wrote: > On 2015/10/02 at 17:04:23, julien.gilli wrote: > > On ...
5 years, 2 months ago (2015-10-05 17:22:58 UTC) #15
julien.gilli
On 2015/10/05 15:12:06, jochen wrote: > On 2015/10/02 at 17:04:23, julien.gilli wrote: > > On ...
5 years, 2 months ago (2015-10-05 17:23:00 UTC) #16
julien.gilli
Updated according to latest code review comments, PTAL and thank you all for your feedback. ...
5 years, 2 months ago (2015-10-05 17:24:25 UTC) #17
Michael Starzinger
Yep, still looks good, ready for CQ from my end. https://codereview.chromium.org/1375933003/diff/20001/src/isolate.cc File src/isolate.cc (right): https://codereview.chromium.org/1375933003/diff/20001/src/isolate.cc#newcode1020 ...
5 years, 2 months ago (2015-10-05 17:39:06 UTC) #18
julien.gilli
On 2015/10/05 17:39:06, Michael Starzinger wrote: > Yep, still looks good, ready for CQ from ...
5 years, 2 months ago (2015-10-05 17:41:08 UTC) #19
Michael Starzinger
On 2015/10/05 17:41:08, julien.gilli wrote: > On 2015/10/05 17:39:06, Michael Starzinger wrote: > > Yep, ...
5 years, 2 months ago (2015-10-05 17:46:00 UTC) #20
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1375933003/40001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1375933003/40001
5 years, 2 months ago (2015-10-05 17:48:20 UTC) #23
julien.gilli
On 2015/10/05 17:48:20, commit-bot: I haz the power wrote: > CQ is trying da patch. ...
5 years, 2 months ago (2015-10-05 18:32:57 UTC) #24
Michael Starzinger
On 2015/10/05 18:32:57, julien.gilli wrote: > On 2015/10/05 17:48:20, commit-bot: I haz the power wrote: ...
5 years, 2 months ago (2015-10-05 18:54:08 UTC) #25
commit-bot: I haz the power
Committed patchset #3 (id:40001)
5 years, 2 months ago (2015-10-05 18:55:11 UTC) #26
commit-bot: I haz the power
Patchset 3 (id:??) landed as https://crrev.com/1ee712ab8687e5f4dec93d45da068d37d28feb8b Cr-Commit-Position: refs/heads/master@{#31111}
5 years, 2 months ago (2015-10-05 18:55:25 UTC) #27
julien.gilli
5 years, 2 months ago (2015-10-05 21:54:21 UTC) #28
Message was sent while issue was closed.
On 2015/10/05 18:55:25, commit-bot: I haz the power wrote:
> Patchset 3 (id:??) landed as
> https://crrev.com/1ee712ab8687e5f4dec93d45da068d37d28feb8b
> Cr-Commit-Position: refs/heads/master@{#31111}

Thank you Michael, jochen and Benedikt for your help!

Powered by Google App Engine
This is Rietveld 408576698