summaryrefslogtreecommitdiffstats
path: root/third_party/tcmalloc/chromium/src/thread_cache.cc
diff options
context:
space:
mode:
Diffstat (limited to 'third_party/tcmalloc/chromium/src/thread_cache.cc')
-rw-r--r--third_party/tcmalloc/chromium/src/thread_cache.cc6
1 files changed, 6 insertions, 0 deletions
diff --git a/third_party/tcmalloc/chromium/src/thread_cache.cc b/third_party/tcmalloc/chromium/src/thread_cache.cc
index 64f4deb..fd44a70 100644
--- a/third_party/tcmalloc/chromium/src/thread_cache.cc
+++ b/third_party/tcmalloc/chromium/src/thread_cache.cc
@@ -299,6 +299,12 @@ int ThreadCache::GetSamplePeriod() {
}
void ThreadCache::InitModule() {
+ // There is a slight potential race here because of double-checked
+ // locking idiom. However, as long as the program does a small
+ // allocation before switching to multi-threaded mode, we will be
+ // fine. We increase the chances of doing such a small allocation
+ // by doing one in the constructor of the module_enter_exit_hook
+ // object declared below.
SpinLockHolder h(Static::pageheap_lock());
if (!phinited) {
Static::InitStaticVars();