Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(400)

Unified Diff: runtime/vm/raw_object.cc

Issue 936393003: Work around race condition in MakeArray for ASSERTs and document assumptions. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/object.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
« no previous file with comments | « runtime/vm/object.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698