From 5d9f6da6541c24077f236fe9a1837e0e8261a3ea Mon Sep 17 00:00:00 2001 From: ulan Date: Mon, 9 May 2016 04:55:14 -0700 Subject: [PATCH] Instrument callers of Semaphore::Signal to help with investigation of flaky crashes. BUG=chromium:609249 LOG=NO Review-Url: https://codereview.chromium.org/1961893002 Cr-Commit-Position: refs/heads/master@{#36106} --- src/base/platform/semaphore.cc | 14 +++++++------- src/base/platform/semaphore.h | 3 ++- src/debug/debug.cc | 2 +- src/heap/mark-compact.cc | 4 ++-- src/heap/page-parallel-job.h | 2 +- src/heap/spaces.cc | 3 ++- src/log.cc | 2 +- 7 files changed, 16 insertions(+), 14 deletions(-) diff --git a/src/base/platform/semaphore.cc b/src/base/platform/semaphore.cc index c94bfa7953..64489f91c2 100644 --- a/src/base/platform/semaphore.cc +++ b/src/base/platform/semaphore.cc @@ -34,11 +34,11 @@ Semaphore::~Semaphore() { USE(result); } - -void Semaphore::Signal() { +void Semaphore::Signal(const char* caller) { kern_return_t result = semaphore_signal(native_handle_); DCHECK_EQ(KERN_SUCCESS, result); USE(result); + USE(caller); } @@ -104,11 +104,11 @@ Semaphore::~Semaphore() { USE(result); } - -void Semaphore::Signal() { +void Semaphore::Signal(const char* caller) { int result = sem_post(&native_handle_); if (result != 0) { - V8_Fatal(__FILE__, __LINE__, "Semaphore signal failure: %d\n", errno); + V8_Fatal(__FILE__, __LINE__, + "Semaphore signal failure: %d called by '%s'\n", errno, caller); } } @@ -177,12 +177,12 @@ Semaphore::~Semaphore() { USE(result); } - -void Semaphore::Signal() { +void Semaphore::Signal(const char* caller) { LONG dummy; BOOL result = ReleaseSemaphore(native_handle_, 1, &dummy); DCHECK(result); USE(result); + USE(caller); } diff --git a/src/base/platform/semaphore.h b/src/base/platform/semaphore.h index 18700d1ba0..ad8c7ec68b 100644 --- a/src/base/platform/semaphore.h +++ b/src/base/platform/semaphore.h @@ -37,7 +37,8 @@ class Semaphore final { ~Semaphore(); // Increments the semaphore counter. - void Signal(); + // TODO(ulan): remove caller parameter once crbug.com/609249 is fixed. + void Signal(const char* caller = nullptr); // Suspends the calling thread until the semaphore counter is non zero // and then decrements the semaphore counter. diff --git a/src/debug/debug.cc b/src/debug/debug.cc index 3b5fb5f53d..7272ee6731 100644 --- a/src/debug/debug.cc +++ b/src/debug/debug.cc @@ -2159,7 +2159,7 @@ void Debug::EnqueueCommandMessage(Vector command, client_data); isolate_->logger()->DebugTag("Put command on command_queue."); command_queue_.Put(message); - command_received_.Signal(); + command_received_.Signal("Debug::EnqueueCommandMessage"); // Set the debug command break flag to have the command processed. if (!in_debug_scope()) isolate_->stack_guard()->RequestDebugCommand(); diff --git a/src/heap/mark-compact.cc b/src/heap/mark-compact.cc index 89ca782c26..ad0c58e4a8 100644 --- a/src/heap/mark-compact.cc +++ b/src/heap/mark-compact.cc @@ -480,7 +480,7 @@ class MarkCompactCollector::Sweeper::SweeperTask : public v8::Task { DCHECK_LE(space_id, LAST_PAGED_SPACE); sweeper_->ParallelSweepSpace(static_cast(space_id), 0); } - pending_sweeper_tasks_->Signal(); + pending_sweeper_tasks_->Signal("SweeperTask::Run"); } Sweeper* sweeper_; @@ -585,7 +585,7 @@ bool MarkCompactCollector::Sweeper::IsSweepingCompleted() { base::TimeDelta::FromSeconds(0))) { return false; } - pending_sweeper_tasks_semaphore_.Signal(); + pending_sweeper_tasks_semaphore_.Signal("Sweeper::IsSweepingCompleted"); return true; } diff --git a/src/heap/page-parallel-job.h b/src/heap/page-parallel-job.h index 720e288fc8..4fde2bdb8a 100644 --- a/src/heap/page-parallel-job.h +++ b/src/heap/page-parallel-job.h @@ -161,7 +161,7 @@ class PageParallelJob { current = items_; } } - on_finish_->Signal(); + on_finish_->Signal("PageParallelJob::Task::RunInternal"); } Heap* heap_; diff --git a/src/heap/spaces.cc b/src/heap/spaces.cc index 7cfa4c2949..1ab5de7379 100644 --- a/src/heap/spaces.cc +++ b/src/heap/spaces.cc @@ -356,7 +356,8 @@ class MemoryAllocator::Unmapper::UnmapFreeMemoryTask : public v8::Task { // v8::Task overrides. void Run() override { unmapper_->PerformFreeMemoryOnQueuedChunks(); - unmapper_->pending_unmapping_tasks_semaphore_.Signal(); + unmapper_->pending_unmapping_tasks_semaphore_.Signal( + "Unmapper::UnmapFreeMemoryTask::Run"); } Unmapper* unmapper_; diff --git a/src/log.cc b/src/log.cc index 416204143b..a3557bfb19 100644 --- a/src/log.cc +++ b/src/log.cc @@ -561,7 +561,7 @@ class Profiler: public base::Thread { } else { buffer_[head_] = *sample; head_ = Succ(head_); - buffer_semaphore_.Signal(); // Tell we have an element. + buffer_semaphore_.Signal("Profiler::Insert"); // Tell we have an element. } }