Index: runtime/vm/raw_object.cc |
=================================================================== |
--- runtime/vm/raw_object.cc (revision 43879) |
+++ runtime/vm/raw_object.cc (working copy) |
@@ -216,6 +216,18 @@ |
#if defined(DEBUG) |
uword tags = ptr()->tags_; |
intptr_t tags_size = SizeTag::decode(tags); |
+ if ((class_id == kArrayCid) && (instance_size > tags_size && tags_size > 0)) { |
+ // TODO(22501): Array::MakeArray could be in the process of shrinking |
+ // the array (see comment therein), having already updated the tags but not |
+ // yet set the new length. Wait a millisecond and try again. |
+ int retries_remaining = 1000; // ... but not forever. |
+ do { |
+ OS::Sleep(1); |
+ const RawArray* raw_array = reinterpret_cast<const RawArray*>(this); |
+ intptr_t array_length = Smi::Value(raw_array->ptr()->length_); |
+ instance_size = Array::InstanceSize(array_length); |
+ } while ((instance_size > tags_size) && (--retries_remaining > 0)); |
+ } |
if ((instance_size != tags_size) && (tags_size != 0)) { |
FATAL3("Size mismatch: %" Pd " from class vs %" Pd " from tags %" Px "\n", |
instance_size, tags_size, tags); |