dart-sdk/sdk/lib
Vyacheslav Egorov 46ac1f653f [vm] Treat Future.then(..., onError:...) as catch all handler
Commit a52f2b9 which reworked awaiter stack unwinding and its
integration with debugger introduced the following regression:
it stopped treating `Future` listeners which had both `onValue`
and `onError` callbacks as catch all exception handlers. Only
listners with `onError` callback (those created with
`Future.onError`) were treated as a catch all handler.

This meant that debugger started to treat exceptions in the
code below as uncaught:

```
Future<void> foo() {
  await 0;
  throw '';
}

await foo().then(..., onError: (e, st) {

});
```

This change fixes this regression by checking if
`FutureListener.state & stateCatchError != 0` instead of
more narrow `FutureListener.state == stateCatchError` which
only detects listeners which only catch errors but do not
handle values. The new predicate matches
`FutureListener.handlesError`.

This relands 38e0046cad
with a fix to ensure that we correctly detect `onError`
callbacks which simply forward to a suspended async
function. We do this by marking FutureListener's that originate
from `await` using a bit in the state.

Fixes https://github.com/dart-lang/sdk/issues/53334

TEST=service/pause_on_unhandled_async_exceptions{_zones,}_test

Fixed: 53334
CoreLibraryReviewExempt: No fundamental changes to _FutureListener implementation, just additional bit to detect that this listener originates from await
Change-Id: I90385fc619cbb52925e075dd5c7b171a31ca4cab
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/323481
Commit-Queue: Slava Egorov <vegorov@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2023-08-31 11:47:54 +00:00
..
_http [standalone, io] Don't register service extensions in product mode. 2023-08-30 21:46:17 +00:00
_internal [standalone, io] Don't register service extensions in product mode. 2023-08-30 21:46:17 +00:00
_wasm [dart2wasm] Fix Wasm{Int,Float}Array.fill value types 2023-08-08 15:27:37 +00:00
async [vm] Treat Future.then(..., onError:...) as catch all handler 2023-08-31 11:47:54 +00:00
cli
collection Add a notice about HashMap keys changing hashCode 2023-06-23 00:10:19 +00:00
convert Make utf8.encode() have Uint8List return type 2023-07-11 08:54:33 +00:00
core Remove duplicate doc in Uri.encodeQueryComponent() 2023-08-08 18:11:51 +00:00
developer [vm/compiler] Tag non-ffi force-optimized functions idempotent. 2023-08-18 18:27:58 +00:00
ffi [vm/ffi] Closure callbacks for sync callbacks 2023-08-25 03:35:44 +00:00
html [dart:html] Fix incorrect parameter mention in drawImageScaledFromSource docs 2023-08-23 00:25:29 +00:00
indexed_db/dart2js Tighten introductory text 2023-05-16 13:55:23 +00:00
internal [cfe] Check @patch annotations 2023-06-13 07:27:08 +00:00
io [standalone, io] Don't register service extensions in product mode. 2023-08-30 21:46:17 +00:00
isolate Mark packageConfigSync and resolvePackageUriSync as released in 3.2 2023-08-22 08:05:19 +00:00
js Reland "[pkg:js/dart:js_interop] Move annotations to dart:_js_annotations" 2023-05-02 15:24:18 +00:00
js_interop [dart:js_interop] Add JS types for Symbol/BigInt 2023-08-21 21:54:15 +00:00
js_interop_unsafe [dart:js_interop] Expose dart:js_interop through dart.dev 2023-05-04 17:41:53 +00:00
js_util [js_util] Make callMethod take an Object method. 2023-03-23 00:23:00 +00:00
math Adding class modifiers to dart:math. 2023-03-13 14:01:26 +00:00
mirrors [sdk docs] update sdk libraries to use triple slash docs 2023-03-14 19:10:25 +00:00
svg/dart2js [sdk docs] update sdk libraries to use triple slash docs 2023-03-14 19:10:25 +00:00
typed_data
vmservice Make Iterable be the default implementation of itself. 2023-04-04 21:45:19 +00:00
web_audio/dart2js [sdk docs] update sdk libraries to use triple slash docs 2023-03-14 19:10:25 +00:00
web_gl/dart2js [sdk docs] update sdk libraries to use triple slash docs 2023-03-14 19:10:25 +00:00
web_sql/dart2js [sdk docs] update sdk libraries to use triple slash docs 2023-03-14 19:10:25 +00:00
analysis_options.yaml
libraries.json [dart2wasm] Make implementation libraries part of core to hide internals 2023-08-14 11:09:10 +00:00
libraries.yaml [dart2wasm] Make implementation libraries part of core to hide internals 2023-08-14 11:09:10 +00:00
PRESUBMIT.py
vmservice_libraries.json
vmservice_libraries.yaml