mirror of
https://github.com/dart-lang/sdk
synced 2024-10-14 11:03:19 +00:00
adc79bc389
The test standalone/string_overflow_test.dart is causing crashes and out-of-memory thrashing on some configurations. It was originally a regression test that concatenating a string with 2^31 characters did not overflow a 32-bit signed integer. It was changed to exponentially grow a string until an out-of-memory runtime exception is thrown in Dart. On some VM configurations, this crashes the machine instead. Restoring it to only check concatenating a string of 2^31 bytes. Bug: https://github.com/dart-lang/sdk/issues/46225 Change-Id: Ib50625fe14be2613c907a7bc30cd57766693f6aa Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/332423 Reviewed-by: Martin Kustermann <kustermann@google.com>
25 lines
768 B
Dart
25 lines
768 B
Dart
// Copyright (c) 2013, 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.
|
|
|
|
// Test to ensure that the VM does not have an integer overflow issue
|
|
// when concatenating strings and hitting length 2^31.
|
|
// See https://github.com/dart-lang/sdk/issues/11214
|
|
|
|
import "package:expect/expect.dart";
|
|
|
|
main() {
|
|
const length28bits = 1 << 28;
|
|
String a = "a";
|
|
while (a.length < length28bits) {
|
|
a = a + a;
|
|
}
|
|
Expect.equals(a.length, length28bits);
|
|
try {
|
|
final concat = "$a$a$a$a$a$a$a$a";
|
|
Expect.equals(concat.length, 8 * length28bits);
|
|
} on OutOfMemoryError {
|
|
// Allow test to run out of memory instead.
|
|
}
|
|
}
|