summaryrefslogtreecommitdiffstats
path: root/runtime/gc
diff options
context:
space:
mode:
authorMathieu Chartier <mathieuc@google.com>2014-04-28 17:30:04 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2014-04-28 17:30:04 +0000
commitec3a2157d2a3e8bcfb34e9a2f2aa54254a8eec19 (patch)
tree71e31fe365dcd0fd124073ef626ad4365dce6996 /runtime/gc
parent5dee5df89aa2cefef6c886d5b9b642cc6f1c595b (diff)
parent4fd2050ff1da3892b5e79276f831e09b2f8e5bc9 (diff)
downloadart-ec3a2157d2a3e8bcfb34e9a2f2aa54254a8eec19.zip
art-ec3a2157d2a3e8bcfb34e9a2f2aa54254a8eec19.tar.gz
art-ec3a2157d2a3e8bcfb34e9a2f2aa54254a8eec19.tar.bz2
Merge "Fix racy DCHECKS."
Diffstat (limited to 'runtime/gc')
-rw-r--r--runtime/gc/allocator/rosalloc.cc8
1 files changed, 6 insertions, 2 deletions
diff --git a/runtime/gc/allocator/rosalloc.cc b/runtime/gc/allocator/rosalloc.cc
index 821aa2d..ff59016 100644
--- a/runtime/gc/allocator/rosalloc.cc
+++ b/runtime/gc/allocator/rosalloc.cc
@@ -600,8 +600,12 @@ void* RosAlloc::AllocFromRun(Thread* self, size_t size, size_t* bytes_allocated)
// Use a thread-local run.
Run* thread_local_run = reinterpret_cast<Run*>(self->GetRosAllocRun(idx));
// Allow invalid since this will always fail the allocation.
- DCHECK(non_full_runs_[idx].find(thread_local_run) == non_full_runs_[idx].end());
- DCHECK(full_runs_[idx].find(thread_local_run) == full_runs_[idx].end());
+ if (kIsDebugBuild) {
+ // Need the lock to prevent race conditions.
+ MutexLock mu(self, *size_bracket_locks_[idx]);
+ CHECK(non_full_runs_[idx].find(thread_local_run) == non_full_runs_[idx].end());
+ CHECK(full_runs_[idx].find(thread_local_run) == full_runs_[idx].end());
+ }
DCHECK(thread_local_run != nullptr);
DCHECK(thread_local_run->IsThreadLocal() || thread_local_run == dedicated_full_run_);
slot_addr = thread_local_run->AllocSlot();