mirror of
https://github.com/dart-lang/sdk
synced 2024-11-02 12:24:24 +00:00
[vm] Fix crash when pausing on unhandled exception in async function without awaiter
TEST=service/pause_on_unhandled_async_exceptions4_test Fixes https://github.com/dart-lang/sdk/issues/51175 Change-Id: I54c2041a9eb28a9a73d608ebfa0bceca522d1287 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/283128 Reviewed-by: Ryan Macnak <rmacnak@google.com> Commit-Queue: Alexander Markov <alexmarkov@google.com>
This commit is contained in:
parent
9a608aa7d8
commit
6362064134
5 changed files with 85 additions and 0 deletions
|
@ -0,0 +1,40 @@
|
|||
// Copyright (c) 2023, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
// Verifies that execution can be stopped on an unhandled exception
|
||||
// in async method which is not awaited.
|
||||
// Regression test for https://github.com/dart-lang/sdk/issues/51175.
|
||||
|
||||
import 'package:observatory/service_io.dart';
|
||||
import 'package:observatory/models.dart' as M;
|
||||
import 'package:test/test.dart';
|
||||
import 'test_helper.dart';
|
||||
import 'service_test_common.dart';
|
||||
|
||||
doThrow() async {
|
||||
await null; // force async gap
|
||||
throw 'TheException';
|
||||
}
|
||||
|
||||
testeeMain() async {
|
||||
doThrow();
|
||||
}
|
||||
|
||||
var tests = <IsolateTest>[
|
||||
hasStoppedWithUnhandledException,
|
||||
(Isolate isolate) async {
|
||||
print("We stopped!");
|
||||
var stack = await isolate.getStack();
|
||||
expect(stack['asyncCausalFrames'], isNotNull);
|
||||
var asyncStack = stack['asyncCausalFrames'];
|
||||
expect(asyncStack.length, greaterThanOrEqualTo(2));
|
||||
expect(asyncStack[0].toString(), contains('doThrow'));
|
||||
expect(asyncStack[1].kind, equals(M.FrameKind.asyncSuspensionMarker));
|
||||
}
|
||||
];
|
||||
|
||||
main(args) => runIsolateTests(args, tests,
|
||||
pause_on_unhandled_exceptions: true,
|
||||
testeeConcurrent: testeeMain,
|
||||
extraArgs: extraDebuggingArgs);
|
|
@ -147,6 +147,7 @@ pause_on_exceptions_test: SkipByDesign # Debugger is disabled in AOT mode.
|
|||
pause_on_start_then_step_test: SkipByDesign # Debugger is disabled in AOT mode.
|
||||
pause_on_unhandled_async_exceptions2_test: SkipByDesign # Debugger is disabled in AOT mode.
|
||||
pause_on_unhandled_async_exceptions3_test: SkipByDesign # Debugger is disabled in AOT mode.
|
||||
pause_on_unhandled_async_exceptions4_test: SkipByDesign # Debugger is disabled in AOT mode.
|
||||
pause_on_unhandled_async_exceptions_test: SkipByDesign # Debugger is disabled in AOT mode.
|
||||
pause_on_unhandled_exceptions_test: SkipByDesign # Debugger is disabled in AOT mode.
|
||||
positive_token_pos_test: SkipByDesign # Debugger is disabled in AOT mode.
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
// Copyright (c) 2023, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
// Verifies that execution can be stopped on an unhandled exception
|
||||
// in async method which is not awaited.
|
||||
// Regression test for https://github.com/dart-lang/sdk/issues/51175.
|
||||
|
||||
import 'package:observatory_2/service_io.dart';
|
||||
import 'package:observatory_2/models.dart' as M;
|
||||
import 'package:test/test.dart';
|
||||
import 'test_helper.dart';
|
||||
import 'service_test_common.dart';
|
||||
|
||||
doThrow() async {
|
||||
await null; // force async gap
|
||||
throw 'TheException';
|
||||
}
|
||||
|
||||
testeeMain() async {
|
||||
doThrow();
|
||||
}
|
||||
|
||||
var tests = <IsolateTest>[
|
||||
hasStoppedWithUnhandledException,
|
||||
(Isolate isolate) async {
|
||||
print("We stopped!");
|
||||
var stack = await isolate.getStack();
|
||||
expect(stack['asyncCausalFrames'], isNotNull);
|
||||
var asyncStack = stack['asyncCausalFrames'];
|
||||
expect(asyncStack.length, greaterThanOrEqualTo(2));
|
||||
expect(asyncStack[0].toString(), contains('doThrow'));
|
||||
expect(asyncStack[1].kind, equals(M.FrameKind.asyncSuspensionMarker));
|
||||
}
|
||||
];
|
||||
|
||||
main(args) => runIsolateTests(args, tests,
|
||||
pause_on_unhandled_exceptions: true,
|
||||
testeeConcurrent: testeeMain,
|
||||
extraArgs: extraDebuggingArgs);
|
|
@ -164,6 +164,7 @@ pause_on_exceptions_test: SkipByDesign # Debugger is disabled in AOT mode.
|
|||
pause_on_start_then_step_test: SkipByDesign # Debugger is disabled in AOT mode.
|
||||
pause_on_unhandled_async_exceptions2_test: SkipByDesign # Debugger is disabled in AOT mode.
|
||||
pause_on_unhandled_async_exceptions3_test: SkipByDesign # Debugger is disabled in AOT mode.
|
||||
pause_on_unhandled_async_exceptions4_test: SkipByDesign # Debugger is disabled in AOT mode.
|
||||
pause_on_unhandled_async_exceptions_test: SkipByDesign # Debugger is disabled in AOT mode.
|
||||
pause_on_unhandled_exceptions_test: SkipByDesign # Debugger is disabled in AOT mode.
|
||||
positive_token_pos_test: SkipByDesign # Debugger is disabled in AOT mode.
|
||||
|
|
|
@ -796,6 +796,9 @@ bool ActivationFrame::HandlesException(const Instance& exc_obj) {
|
|||
Object::Handle(SuspendState::Cast(suspend_state).function_data());
|
||||
futureOrListener =
|
||||
caller_closure_finder.GetFutureFutureListener(futureOrListener);
|
||||
if (futureOrListener.IsNull()) {
|
||||
return false;
|
||||
}
|
||||
return caller_closure_finder.HasCatchError(futureOrListener);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue