Index: dart/runtime/vm/gc_marker.cc |
=================================================================== |
--- dart/runtime/vm/gc_marker.cc (revision 32272) |
+++ dart/runtime/vm/gc_marker.cc (working copy) |
@@ -6,6 +6,7 @@ |
#include <map> |
#include <utility> |
+#include <vector> |
#include "vm/allocation.h" |
#include "vm/dart_api_state.h" |
@@ -192,10 +193,14 @@ |
std::pair<DelaySet::iterator, DelaySet::iterator> ret; |
// Visit all elements with a key equal to raw_obj. |
ret = delay_set_.equal_range(raw_obj); |
- for (DelaySet::iterator it = ret.first; it != ret.second; ++it) { |
+ // Create a copy of the range in a temporary vector to iterate over it |
+ // while delay_set_ may be modified. |
+ std::vector<DelaySetEntry> temp_copy(ret.first, ret.second); |
+ delay_set_.erase(ret.first, ret.second); |
+ for (std::vector<DelaySetEntry>::iterator it = temp_copy.begin(); |
+ it != temp_copy.end(); ++it) { |
it->second->VisitPointers(this); |
} |
- delay_set_.erase(ret.first, ret.second); |
raw_obj->ClearWatchedBit(); |
} |
marking_stack_->Push(raw_obj); |
@@ -261,6 +266,7 @@ |
MarkingStack* marking_stack_; |
RawObject* visiting_old_object_; |
typedef std::multimap<RawObject*, RawWeakProperty*> DelaySet; |
+ typedef std::pair<RawObject*, RawWeakProperty*> DelaySetEntry; |
DelaySet delay_set_; |
const bool visit_function_code_; |
GrowableArray<RawFunction*> skipped_code_functions_; |