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

Issue 2692803006: Track the 'awaiter return' call stack use it to detect uncaught exceptions in async functions (Closed)

Created:
3 years, 10 months ago by Cutch
Modified:
3 years, 9 months ago
Reviewers:
rmacnak, hausner, kevmoo
CC:
reviews_dartlang.org, vm-dev_dartlang.org
Target Ref:
refs/heads/master
Visibility:
Public.

Description

Track the 'awaiter return' call stack use it to detect uncaught exceptions in async functions Tracking the awaiter return call stack: - [x] Each async function closure now knows who is awaiting on their return. This is effectively the asynchronous equivalent of the 'frame pointer'. - [x] Each async* function closure now knows how is listening on their stream. This is effectively the asynchronous equivalent of the 'frame pointer'. Detecting uncaught exceptions in async functions: - [x] Code object keeps a map from :await_jump_var to token position - [x] Exception Handlers keep track if they are generated (as part of compilation) or directly from user code - [x] Debugger maps :await_jump_var to a specific try index Fixes #27242 R=rmacnak@google.com Committed: https://github.com/dart-lang/sdk/commit/cba7e3e79adf41814060119bb61faff7bb658865

Patch Set 1 #

Patch Set 2 : .... #

Patch Set 3 : .. #

Patch Set 4 : port to other architectures #

Total comments: 15

Patch Set 5 : rmacnak review #

Patch Set 6 : rebase #

Total comments: 4

Patch Set 7 : rmacnak review #

Total comments: 14
Unified diffs Side-by-side diffs Delta from patch set Stats (+770 lines, -67 lines) Patch
M runtime/lib/async_patch.dart View 1 2 3 4 4 chunks +37 lines, -3 lines 4 comments Download
A runtime/observatory/tests/service/pause_on_unhandled_async_exceptions2_test.dart View 1 2 3 4 1 chunk +53 lines, -0 lines 0 comments Download
A runtime/observatory/tests/service/pause_on_unhandled_async_exceptions_test.dart View 1 2 1 chunk +65 lines, -0 lines 0 comments Download
M runtime/vm/ast.h View 1 1 chunk +1 line, -0 lines 0 comments Download
M runtime/vm/ast_transformer.cc View 3 chunks +9 lines, -2 lines 0 comments Download
M runtime/vm/code_descriptors.h View 1 2 4 chunks +8 lines, -0 lines 0 comments Download
M runtime/vm/code_descriptors.cc View 1 2 1 chunk +4 lines, -2 lines 0 comments Download
M runtime/vm/compiler.cc View 1 2 3 4 1 chunk +28 lines, -0 lines 0 comments Download
M runtime/vm/debugger.h View 1 2 6 chunks +25 lines, -6 lines 0 comments Download
M runtime/vm/debugger.cc View 1 2 3 4 5 6 9 chunks +358 lines, -34 lines 8 comments Download
M runtime/vm/exceptions.h View 1 2 3 4 1 chunk +1 line, -0 lines 0 comments Download
M runtime/vm/flow_graph.h View 1 2 3 4 2 chunks +10 lines, -0 lines 0 comments Download
M runtime/vm/flow_graph.cc View 1 2 3 4 5 6 1 chunk +1 line, -0 lines 0 comments Download
M runtime/vm/flow_graph_builder.h View 2 chunks +7 lines, -0 lines 0 comments Download
M runtime/vm/flow_graph_builder.cc View 1 2 3 4 5 6 5 chunks +13 lines, -1 line 0 comments Download
M runtime/vm/flow_graph_compiler.h View 1 2 3 4 5 6 1 chunk +2 lines, -0 lines 0 comments Download
M runtime/vm/flow_graph_compiler.cc View 1 2 3 4 5 6 1 chunk +4 lines, -1 line 0 comments Download
M runtime/vm/intermediate_language.h View 1 2 3 4 5 6 4 chunks +11 lines, -2 lines 0 comments Download
M runtime/vm/intermediate_language_arm.cc View 1 2 3 1 chunk +1 line, -0 lines 0 comments Download
M runtime/vm/intermediate_language_arm64.cc View 1 2 3 1 chunk +1 line, -0 lines 0 comments Download
M runtime/vm/intermediate_language_dbc.cc View 1 2 3 1 chunk +1 line, -0 lines 0 comments Download
M runtime/vm/intermediate_language_ia32.cc View 1 2 3 1 chunk +1 line, -0 lines 0 comments Download
M runtime/vm/intermediate_language_mips.cc View 1 2 3 1 chunk +1 line, -0 lines 0 comments Download
M runtime/vm/intermediate_language_x64.cc View 1 2 1 chunk +1 line, -0 lines 0 comments Download
M runtime/vm/kernel_to_il.cc View 1 2 3 4 1 chunk +2 lines, -0 lines 0 comments Download
M runtime/vm/object.h View 1 2 3 4 5 6 2 chunks +14 lines, -1 line 0 comments Download
M runtime/vm/object.cc View 1 2 3 4 5 6 6 chunks +15 lines, -4 lines 0 comments Download
M runtime/vm/object_service.cc View 1 2 3 4 5 6 1 chunk +5 lines, -0 lines 0 comments Download
M runtime/vm/object_test.cc View 1 2 3 4 5 6 1 chunk +8 lines, -4 lines 0 comments Download
M runtime/vm/parser.cc View 1 2 3 4 5 6 8 chunks +63 lines, -6 lines 0 comments Download
M runtime/vm/raw_object.h View 1 2 3 4 5 6 1 chunk +1 line, -0 lines 0 comments Download
M runtime/vm/scopes.cc View 1 chunk +12 lines, -0 lines 0 comments Download
M runtime/vm/symbols.h View 1 4 chunks +7 lines, -1 line 2 comments Download

Messages

Total messages: 17 (7 generated)
Cutch
3 years, 10 months ago (2017-02-21 21:12:43 UTC) #4
kevmoo
So it wasn't a simple fix? :-) Thanks so much!
3 years, 10 months ago (2017-02-22 15:59:37 UTC) #7
rmacnak
Some initial thoughts https://codereview.chromium.org/2692803006/diff/60001/runtime/lib/async_patch.dart File runtime/lib/async_patch.dart (right): https://codereview.chromium.org/2692803006/diff/60001/runtime/lib/async_patch.dart#newcode219 runtime/lib/async_patch.dart:219: Object _awaiter; /// The closure implementing ...
3 years, 10 months ago (2017-02-23 17:50:56 UTC) #8
Cutch
https://codereview.chromium.org/2692803006/diff/60001/runtime/lib/async_patch.dart File runtime/lib/async_patch.dart (right): https://codereview.chromium.org/2692803006/diff/60001/runtime/lib/async_patch.dart#newcode219 runtime/lib/async_patch.dart:219: Object _awaiter; On 2017/02/23 17:50:55, rmacnak wrote: > /// ...
3 years, 10 months ago (2017-02-24 20:19:21 UTC) #9
Cutch
https://codereview.chromium.org/2692803006/diff/60001/runtime/vm/debugger.cc File runtime/vm/debugger.cc (right): https://codereview.chromium.org/2692803006/diff/60001/runtime/vm/debugger.cc#newcode717 runtime/vm/debugger.cc:717: if (fp() == 0) { On 2017/02/23 17:50:56, rmacnak ...
3 years, 10 months ago (2017-02-24 20:19:22 UTC) #10
rmacnak
lgtm https://codereview.chromium.org/2692803006/diff/100001/runtime/vm/debugger.cc File runtime/vm/debugger.cc (right): https://codereview.chromium.org/2692803006/diff/100001/runtime/vm/debugger.cc#newcode1977 runtime/vm/debugger.cc:1977: StackFrameIterator iterator(false); false -> kDontValidateFrames
3 years, 9 months ago (2017-02-27 18:17:09 UTC) #11
Cutch
https://codereview.chromium.org/2692803006/diff/100001/runtime/vm/debugger.cc File runtime/vm/debugger.cc (right): https://codereview.chromium.org/2692803006/diff/100001/runtime/vm/debugger.cc#newcode1977 runtime/vm/debugger.cc:1977: StackFrameIterator iterator(false); On 2017/02/27 18:17:09, rmacnak wrote: > false ...
3 years, 9 months ago (2017-02-27 22:15:33 UTC) #12
Cutch
Committed patchset #7 (id:120001) manually as cba7e3e79adf41814060119bb61faff7bb658865 (presubmit successful).
3 years, 9 months ago (2017-02-27 22:16:23 UTC) #14
hausner
A few post-submit comments. https://codereview.chromium.org/2692803006/diff/100001/runtime/vm/object.cc File runtime/vm/object.cc (right): https://codereview.chromium.org/2692803006/diff/100001/runtime/vm/object.cc#newcode12500 runtime/vm/object.cc:12500: TokenPosition token_pos, token_pos appears to ...
3 years, 9 months ago (2017-02-28 19:04:51 UTC) #16
Cutch
3 years, 9 months ago (2017-02-28 21:46:53 UTC) #17
Message was sent while issue was closed.
See: https://codereview.chromium.org/2720723006

https://codereview.chromium.org/2692803006/diff/100001/runtime/vm/object.cc
File runtime/vm/object.cc (right):

https://codereview.chromium.org/2692803006/diff/100001/runtime/vm/object.cc#n...
runtime/vm/object.cc:12500: TokenPosition token_pos,
On 2017/02/28 19:04:51, hausner wrote:
> token_pos appears to be unused.

Yes, this was part of development and I may use it in the future if my current
search for exception handler logic based on token position (and not PC) doesn't
hold up.

https://codereview.chromium.org/2692803006/diff/120001/runtime/lib/async_patc...
File runtime/lib/async_patch.dart (right):

https://codereview.chromium.org/2692803006/diff/120001/runtime/lib/async_patc...
runtime/lib/async_patch.dart:72: if (object is! _StreamImpl) {
On 2017/02/28 19:04:51, hausner wrote:
> Curious: why not simply
> 
> if (object is _StreamImpl) {
>   object._awaiter = awaiter;
> }

I was just copying the _awaitHelper pattern :)

https://codereview.chromium.org/2692803006/diff/120001/runtime/lib/async_patc...
runtime/lib/async_patch.dart:92: if (local is! _StreamImpl) {
On 2017/02/28 19:04:51, hausner wrote:
> ditto

ditto

https://codereview.chromium.org/2692803006/diff/120001/runtime/vm/debugger.cc
File runtime/vm/debugger.cc (right):

https://codereview.chromium.org/2692803006/diff/120001/runtime/vm/debugger.cc...
runtime/vm/debugger.cc:721: intptr_t var_desc_len = var_descriptors_.Length();
On 2017/02/28 19:04:51, hausner wrote:
> This is a duplicate variable definition that shadows the outer one.

Good catch!

https://codereview.chromium.org/2692803006/diff/120001/runtime/vm/debugger.cc...
runtime/vm/debugger.cc:732: } else {
On 2017/02/28 19:04:51, hausner wrote:
> Can't these two cases be unified? When the entry with the right name is found,
> then assert that if it's not a live frame, the variable must be in the
context.

Done.

https://codereview.chromium.org/2692803006/diff/120001/runtime/vm/debugger.cc...
runtime/vm/debugger.cc:781: intptr_t var_desc_len = var_descriptors_.Length();
On 2017/02/28 19:04:51, hausner wrote:
> Same comments as in GetAsyncCompleter() above

I've actually made a helper function which these two call passing in the Symbol.

https://codereview.chromium.org/2692803006/diff/120001/runtime/vm/debugger.cc...
runtime/vm/debugger.cc:855: while (try_index >= try_index_threshold) {
On 2017/02/28 19:04:51, hausner wrote:
> I realize this is a direct transformation from the old code that used the
> literal 0, but why not
> 
> while (try_index != CatchClauseNode::kInvalidTryIndex) { ...
> 
> This seems more appropriate, because the code really doesn't care about the
fact
> that 0 is the index of an implicit try. (In fact, in non-async code, index 0
can
> be a user-defined try index.)

This code used to care but then I made further changes. I've gone with your
suggestion and changed it to be != CatchClauseNode::kInvalidTryIndex.

https://codereview.chromium.org/2692803006/diff/120001/runtime/vm/symbols.h
File runtime/vm/symbols.h (right):

https://codereview.chromium.org/2692803006/diff/120001/runtime/vm/symbols.h#n...
runtime/vm/symbols.h:49: V(Controller, ":controller")                           
                     \
On 2017/02/28 19:04:51, hausner wrote:
> In other cases, the internal name is called ColonXXX. Maybe do this there too
to
> avoid Controller2 name?

Done.

Powered by Google App Engine
This is Rietveld 408576698