dart-sdk/tests/standalone/out_of_memory_unhandled_exception_test.dart
Ryan Macnak e078d4f00a [vm] Avoid allocations when reporting unhandled exceptions.
Bug: https://github.com/dart-lang/sdk/issues/43642
Bug: b/169880355
Change-Id: I260b9d47f2b65d3cb4a48b966557d139978947e2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/165740
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2020-10-05 20:42:02 +00:00

37 lines
1 KiB
Dart

// Copyright (c) 2020, 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.
import "dart:io";
import "package:expect/expect.dart";
main(args) async {
if (args.contains("--child")) {
var leak = [];
while (true) {
leak = [leak];
}
} else {
var exec = Platform.resolvedExecutable;
var args = <String>[];
args.addAll(Platform.executableArguments);
args.add("--old_gen_heap_size=20");
args.add(Platform.script.toFilePath());
args.add("--child");
// Should report an unhandled out of memory exception without crashing.
print("+ $exec " + args.join(" "));
var result = await Process.run(exec, args);
print("exit: ${result.exitCode}");
print("stdout:");
print(result.stdout);
print("stderr:");
print(result.stderr);
Expect.equals(255, result.exitCode, "Unhandled exception, not crash");
Expect.isTrue(result.stderr.contains("Out of Memory"));
}
}