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

Unified Diff: third_party/WebKit/Source/platform/heap/Heap.cpp

Issue 2051053002: Fix data race in blink::ThreadHeap::detach (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix Created 4 years, 6 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/platform/heap/Heap.cpp
diff --git a/third_party/WebKit/Source/platform/heap/Heap.cpp b/third_party/WebKit/Source/platform/heap/Heap.cpp
index c2b0bb3e801c559c2a502c06c84bede3e602c5ac..527b04a16494c04b763afd0016f77c7b9c69dbbe 100644
--- a/third_party/WebKit/Source/platform/heap/Heap.cpp
+++ b/third_party/WebKit/Source/platform/heap/Heap.cpp
@@ -261,6 +261,7 @@ void ThreadHeap::attach(ThreadState* thread)
void ThreadHeap::detach(ThreadState* thread)
{
ASSERT(ThreadState::current() == thread);
+ bool isLastThread = false;
{
// Grab the threadAttachMutex to ensure only one thread can shutdown at
// a time and that no other thread can do a global GC. It also allows
@@ -272,12 +273,16 @@ void ThreadHeap::detach(ThreadState* thread)
thread->runTerminationGC();
ASSERT(m_threads.contains(thread));
m_threads.remove(thread);
+ isLastThread = m_threads.isEmpty();
}
- // The main thread must be the last thread that gets detached.
- ASSERT(!thread->isMainThread() || m_threads.isEmpty());
+ // The last thread begin detached should be the owning thread, which would
+ // be the main thread for the mainThreadHeap and a per thread heap enabled
+ // thread otherwise.
+ if (isLastThread)
+ DCHECK(thread->perThreadHeapEnabled() || thread->isMainThread());
if (thread->isMainThread())
DCHECK_EQ(heapStats().allocatedSpace(), 0u);
- if (m_threads.isEmpty())
+ if (isLastThread)
delete this;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698