[vm, isolate] Fix length truncation in message snapshots, take 2.
Only run test on x64 VMs.
Bug: https://github.com/dart-lang/sdk/issues/35635
Change-Id: I3ab16a96669a9f29187954896e59a3341dce5dc4
Reviewed-on: https://dart-review.googlesource.com/c/89925
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
diff --git a/runtime/vm/snapshot.cc b/runtime/vm/snapshot.cc
index 5a4d2f5..ea491de 100644
--- a/runtime/vm/snapshot.cc
+++ b/runtime/vm/snapshot.cc
@@ -187,9 +187,9 @@
}
RawSmi* BaseReader::ReadAsSmi() {
- intptr_t value = Read<int32_t>();
- ASSERT((value & kSmiTagMask) == kSmiTag);
- return reinterpret_cast<RawSmi*>(value);
+ RawSmi* value = Read<RawSmi*>();
+ ASSERT((reinterpret_cast<uword>(value) & kSmiTagMask) == kSmiTag);
+ return value;
}
intptr_t BaseReader::ReadSmiValue() {
diff --git a/tests/lib_2/isolate/int32_length_overflow_test.dart b/tests/lib_2/isolate/int32_length_overflow_test.dart
new file mode 100644
index 0000000..3502ce9
--- /dev/null
+++ b/tests/lib_2/isolate/int32_length_overflow_test.dart
@@ -0,0 +1,93 @@
+// Copyright (c) 2019, 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:async";
+import "dart:isolate";
+import "dart:typed_data";
+import "package:expect/expect.dart";
+
+const large = 1 << 30;
+
+void child(replyPort) {
+ print("Child start");
+
+ print("Child Uint8List");
+ dynamic x = new Uint8List(large);
+ for (int i = 0; i < 4; i++) {
+ x[i] = i;
+ }
+ for (int i = x.length - 4; i < x.length; i++) {
+ x[i] = x.length - i;
+ }
+ replyPort.send(x);
+ x = null;
+
+ // Too slow.
+ // print("Child Array");
+ // x = new List(large);
+ // for (int i = 0; i < 4; i++) {
+ // x[i] = i;
+ // }
+ // replyPort.send(x);
+ // x = null;
+
+ print("Child OneByteString");
+ x = null;
+ x = "Z";
+ while (x.length < large) {
+ x = x * 2;
+ }
+ replyPort.send(x);
+ x = null;
+
+ print("Child done");
+}
+
+Future<void> main(List<String> args) async {
+ print("Parent start");
+
+ ReceivePort port = new ReceivePort();
+ Isolate.spawn(child, port.sendPort);
+ StreamIterator<dynamic> incoming = new StreamIterator<dynamic>(port);
+
+ print("Parent Uint8");
+ Expect.isTrue(await incoming.moveNext());
+ dynamic x = incoming.current;
+ Expect.isTrue(x is Uint8List);
+ Expect.equals(large, x.length);
+ for (int i = 0; i < 4; i++) {
+ Expect.equals(i, x[i]);
+ }
+ for (int i = x.length - 4; i < x.length; i++) {
+ Expect.equals(x.length - i, x[i]);
+ }
+ x = null;
+
+ // Too slow.
+ // print("Parent Array");
+ // Expect.isTrue(await incoming.moveNext());
+ // x = incoming.current;
+ // Expect.isTrue(x is List);
+ // Expect.equals(large, x.length);
+ // for (int i = 0; i < 4; i++) {
+ // Expect.equals(i, x[i]);
+ // }
+ // x = null;
+
+ print("Parent OneByteString");
+ Expect.isTrue(await incoming.moveNext());
+ x = incoming.current;
+ Expect.isTrue(x is String);
+ Expect.equals(large, x.length);
+ for (int i = 0; i < 4; i++) {
+ Expect.equals("Z", x[i]);
+ }
+ for (int i = x.length - 4; i < x.length; i++) {
+ Expect.equals("Z", x[i]);
+ }
+ x = null;
+
+ port.close();
+ print("Parent done");
+}
diff --git a/tests/lib_2/lib_2.status b/tests/lib_2/lib_2.status
index dc0745a..b2f880d 100644
--- a/tests/lib_2/lib_2.status
+++ b/tests/lib_2/lib_2.status
@@ -183,6 +183,9 @@
[ $arch == simarm || $arch == simarmv5te || $arch == simarmv6 ]
convert/utf85_test: Skip # Pass, Slow Issue 12644.
+[ $arch != x64 || $compiler == dartkb || $runtime != vm ]
+isolate/int32_length_overflow_test: SkipSlow
+
[ $compiler == app_jit || $mode == product || $runtime != vm ]
isolate/checked_test: Skip # Unsupported.