diff options
-rw-r--r-- | chrome/app/breakpad_win.cc | 16 | ||||
-rw-r--r-- | chrome/browser/DEPS | 4 | ||||
-rw-r--r-- | chrome/browser/hang_monitor/hang_crash_dump_win.cc | 60 | ||||
-rw-r--r-- | chrome/browser/hang_monitor/hang_crash_dump_win.h | 6 | ||||
-rw-r--r-- | chrome/browser/ui/hung_plugin_tab_helper.cc | 11 | ||||
-rw-r--r-- | ppapi/host/ppapi_host.cc | 3 | ||||
-rw-r--r-- | ppapi/ppapi_shared.gypi | 2 | ||||
-rw-r--r-- | ppapi/proxy/host_dispatcher.cc | 5 | ||||
-rw-r--r-- | ppapi/shared_impl/ppapi_message_tracker.cc | 47 | ||||
-rw-r--r-- | ppapi/shared_impl/ppapi_message_tracker.h | 50 |
10 files changed, 54 insertions, 150 deletions
diff --git a/chrome/app/breakpad_win.cc b/chrome/app/breakpad_win.cc index d4f7eed..ca1e667 100644 --- a/chrome/app/breakpad_win.cc +++ b/chrome/app/breakpad_win.cc @@ -130,6 +130,22 @@ InjectDumpProcessWithoutCrash(HANDLE process) { 0, 0, NULL); } +// The following two functions do exactly the same thing as the two above. But +// we want the signatures to be different so that we can easily track them in +// crash reports. +// TODO(yzshen): Remove when enough information is collected and the hang rate +// of pepper/renderer processes is reduced. +DWORD WINAPI DumpForHangDebuggingThread(void*) { + DumpProcessWithoutCrash(); + return 0; +} + +extern "C" HANDLE __declspec(dllexport) __cdecl +InjectDumpForHangDebugging(HANDLE process) { + return CreateRemoteThread(process, NULL, 0, DumpForHangDebuggingThread, + 0, 0, NULL); +} + // Reduces the size of the string |str| to a max of 64 chars. Required because // breakpad's CustomInfoEntry raises an invalid_parameter error if the string // we want to set is longer. diff --git a/chrome/browser/DEPS b/chrome/browser/DEPS index e949f2c..b57c3f5 100644 --- a/chrome/browser/DEPS +++ b/chrome/browser/DEPS @@ -16,10 +16,6 @@ include_rules = [ "+ppapi/host", "+ppapi/proxy", "+ppapi/shared_impl/api_id.h", - # Provide debug info for detecting inter-process pepper deadlocks. - # TODO(yzshen): Remove when enough information is collected and the hang rate - # of pepper/renderer processes is reduced. - "+ppapi/shared_impl/ppapi_message_tracker.h", # Defines some types that are marshalled over IPC. "+ppapi/shared_impl/ppp_flash_browser_operations_shared.h", "+rlz", diff --git a/chrome/browser/hang_monitor/hang_crash_dump_win.cc b/chrome/browser/hang_monitor/hang_crash_dump_win.cc index c327519..456aa38 100644 --- a/chrome/browser/hang_monitor/hang_crash_dump_win.cc +++ b/chrome/browser/hang_monitor/hang_crash_dump_win.cc @@ -7,7 +7,6 @@ #include "base/logging.h" #include "chrome/common/chrome_constants.h" #include "content/public/common/result_codes.h" -#include "ppapi/shared_impl/ppapi_message_tracker.h" namespace { @@ -17,20 +16,6 @@ static const int kTerminateTimeoutMS = 2000; // How long do we wait for the crash to be generated (in ms). static const int kGenerateDumpTimeoutMS = 10000; -DWORD WINAPI DumpIfHandlingPepper(void*) { - typedef void (__cdecl *DumpFunction)(); - if (ppapi::PpapiMessageTracker::GetInstance()->IsHandlingMessage()) { - DumpFunction request_dump = reinterpret_cast<DumpFunction>(GetProcAddress( - GetModuleHandle(chrome::kBrowserProcessExecutableName), - "DumpProcessWithoutCrash")); - DCHECK(request_dump) << "Failed loading DumpProcessWithoutCrash: error " << - GetLastError(); - if (request_dump) - request_dump(); - } - return 0; -} - } // namespace void CrashDumpAndTerminateHungChildProcess(HANDLE hprocess) { @@ -60,24 +45,31 @@ void CrashDumpAndTerminateHungChildProcess(HANDLE hprocess) { WaitForSingleObject(hprocess, kTerminateTimeoutMS); } -void CrashDumpIfProcessHandlingPepper(HANDLE hprocess) { - // Unlike CrashDumpAndTerminateHungChildProcess() which creates a remote - // thread using function pointer relative to chrome.exe, here we create a - // remote thread using function pointer relative to chrome.dll. The reason is - // that there are separate PpapiMessageTracker singletons for chrome.dll and - // chrome.exe (in non-component build). We cannot access the information - // collected by PpapiMessageTracker of chrome.dll in chrome.exe. - // - // This is less safe, because chrome.dll may be loaded at different addresses - // in different processes. We could cause crash in that case. However, it - // should be rare and we are only doing this temporarily for debugging on the - // Canary channel. - HANDLE remote_thread = CreateRemoteThread(hprocess, NULL, 0, - DumpIfHandlingPepper, 0, 0, NULL); - DCHECK(remote_thread) << "Failed creating remote thread: error " << - GetLastError(); - if (remote_thread) { - WaitForSingleObject(remote_thread, kGenerateDumpTimeoutMS); - CloseHandle(remote_thread); +void CrashDumpForHangDebugging(HANDLE hprocess) { + if (hprocess == GetCurrentProcess()) { + typedef void (__cdecl *DumpFunction)(); + DumpFunction request_dump = reinterpret_cast<DumpFunction>(GetProcAddress( + GetModuleHandle(chrome::kBrowserProcessExecutableName), + "DumpProcessWithoutCrash")); + DCHECK(request_dump) << "Failed loading DumpProcessWithoutCrash: error " << + GetLastError(); + if (request_dump) + request_dump(); + } else { + typedef HANDLE (__cdecl *DumpFunction)(HANDLE); + DumpFunction request_dump = reinterpret_cast<DumpFunction>(GetProcAddress( + GetModuleHandle(chrome::kBrowserProcessExecutableName), + "InjectDumpForHangDebugging")); + DCHECK(request_dump) << "Failed loading InjectDumpForHangDebugging: error " + << GetLastError(); + if (request_dump) { + HANDLE remote_thread = request_dump(hprocess); + DCHECK(remote_thread) << "Failed creating remote thread: error " << + GetLastError(); + if (remote_thread) { + WaitForSingleObject(remote_thread, kGenerateDumpTimeoutMS); + CloseHandle(remote_thread); + } + } } } diff --git a/chrome/browser/hang_monitor/hang_crash_dump_win.h b/chrome/browser/hang_monitor/hang_crash_dump_win.h index a3d02b7..1f7d798 100644 --- a/chrome/browser/hang_monitor/hang_crash_dump_win.h +++ b/chrome/browser/hang_monitor/hang_crash_dump_win.h @@ -11,8 +11,8 @@ // process. void CrashDumpAndTerminateHungChildProcess(HANDLE hprocess); -// Causes the given process to generate a crash dump if it is handling pepper -// messages. -void CrashDumpIfProcessHandlingPepper(HANDLE hprocess); +// TODO(yzshen): Remove when enough information is collected and the hang rate +// of pepper/renderer processes is reduced. +void CrashDumpForHangDebugging(HANDLE hprocess); #endif // CHROME_BROWSER_HANG_MONITOR_HANG_CRASH_DUMP_WIN_H_ diff --git a/chrome/browser/ui/hung_plugin_tab_helper.cc b/chrome/browser/ui/hung_plugin_tab_helper.cc index 39513bd9..26dc863 100644 --- a/chrome/browser/ui/hung_plugin_tab_helper.cc +++ b/chrome/browser/ui/hung_plugin_tab_helper.cc @@ -67,11 +67,15 @@ class OwnedHandleVector { DISALLOW_COPY_AND_ASSIGN(OwnedHandleVector); }; +void DumpBrowserInBlockingPool() { + CrashDumpForHangDebugging(::GetCurrentProcess()); +} + void DumpRenderersInBlockingPool(OwnedHandleVector* renderer_handles) { for (std::vector<HANDLE>::const_iterator iter = renderer_handles->data().begin(); iter != renderer_handles->data().end(); ++iter) { - CrashDumpIfProcessHandlingPepper(*iter); + CrashDumpForHangDebugging(*iter); } } @@ -316,7 +320,10 @@ void HungPluginTabHelper::KillPlugin(int child_id) { // due to our crash dump uploading restrictions. So we just don't generate // renderer crash dumps in that case. if (renderer_handles->data().size() > 0 && - renderer_handles->data().size() < 8) { + renderer_handles->data().size() < 4) { + content::BrowserThread::PostBlockingPoolSequencedTask( + kDumpChildProcessesSequenceName, FROM_HERE, + base::Bind(&DumpBrowserInBlockingPool)); content::BrowserThread::PostBlockingPoolSequencedTask( kDumpChildProcessesSequenceName, FROM_HERE, base::Bind(&DumpRenderersInBlockingPool, diff --git a/ppapi/host/ppapi_host.cc b/ppapi/host/ppapi_host.cc index 3a7add1..0ec37b6 100644 --- a/ppapi/host/ppapi_host.cc +++ b/ppapi/host/ppapi_host.cc @@ -13,7 +13,6 @@ #include "ppapi/proxy/ppapi_messages.h" #include "ppapi/proxy/resource_message_params.h" #include "ppapi/shared_impl/host_resource.h" -#include "ppapi/shared_impl/ppapi_message_tracker.h" namespace ppapi { namespace host { @@ -40,12 +39,10 @@ PpapiHost::~PpapiHost() { } bool PpapiHost::Send(IPC::Message* msg) { - ScopedTrackPpapiMessage track_ppapi_message; return sender_->Send(msg); } bool PpapiHost::OnMessageReceived(const IPC::Message& msg) { - ScopedTrackPpapiMessage track_ppapi_message; bool handled = true; IPC_BEGIN_MESSAGE_MAP(PpapiHost, msg) IPC_MESSAGE_HANDLER(PpapiHostMsg_ResourceCall, diff --git a/ppapi/ppapi_shared.gypi b/ppapi/ppapi_shared.gypi index 8d59def..25d0228 100644 --- a/ppapi/ppapi_shared.gypi +++ b/ppapi/ppapi_shared.gypi @@ -36,8 +36,6 @@ 'shared_impl/platform_file.h', 'shared_impl/ppapi_globals.cc', 'shared_impl/ppapi_globals.h', - 'shared_impl/ppapi_message_tracker.cc', - 'shared_impl/ppapi_message_tracker.h', 'shared_impl/ppapi_permissions.cc', 'shared_impl/ppapi_permissions.h', 'shared_impl/ppapi_preferences.cc', diff --git a/ppapi/proxy/host_dispatcher.cc b/ppapi/proxy/host_dispatcher.cc index b89032a..0170edb 100644 --- a/ppapi/proxy/host_dispatcher.cc +++ b/ppapi/proxy/host_dispatcher.cc @@ -13,7 +13,6 @@ #include "ppapi/proxy/ppapi_messages.h" #include "ppapi/proxy/resource_creation_proxy.h" #include "ppapi/shared_impl/ppapi_globals.h" -#include "ppapi/shared_impl/ppapi_message_tracker.h" namespace ppapi { namespace proxy { @@ -132,8 +131,6 @@ bool HostDispatcher::IsPlugin() const { } bool HostDispatcher::Send(IPC::Message* msg) { - ScopedTrackPpapiMessage track_ppapi_message; - TRACE_EVENT2("ppapi proxy", "HostDispatcher::Send", "Class", IPC_MESSAGE_ID_CLASS(msg->type()), "Line", IPC_MESSAGE_ID_LINE(msg->type())); @@ -172,8 +169,6 @@ bool HostDispatcher::Send(IPC::Message* msg) { } bool HostDispatcher::OnMessageReceived(const IPC::Message& msg) { - ScopedTrackPpapiMessage track_ppapi_message; - TRACE_EVENT2("ppapi proxy", "HostDispatcher::OnMessageReceived", "Class", IPC_MESSAGE_ID_CLASS(msg.type()), "Line", IPC_MESSAGE_ID_LINE(msg.type())); diff --git a/ppapi/shared_impl/ppapi_message_tracker.cc b/ppapi/shared_impl/ppapi_message_tracker.cc deleted file mode 100644 index 4fba69f..0000000 --- a/ppapi/shared_impl/ppapi_message_tracker.cc +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "ppapi/shared_impl/ppapi_message_tracker.h" - -#include "base/logging.h" -#include "base/memory/singleton.h" - -namespace ppapi { - -//static -PpapiMessageTracker* PpapiMessageTracker::GetInstance() { - return Singleton<PpapiMessageTracker>::get(); -} - -PpapiMessageTracker::PpapiMessageTracker() : enter_count_(0) { -} - -PpapiMessageTracker::~PpapiMessageTracker() { -} - -void PpapiMessageTracker::EnterMessageHandling() { - base::AutoLock auto_lock(lock_); - enter_count_++; -} - -void PpapiMessageTracker::ExitMessageHandling() { - base::AutoLock auto_lock(lock_); - DCHECK_GT(enter_count_, 0); - enter_count_--; -} - -bool PpapiMessageTracker::IsHandlingMessage() { - base::AutoLock auto_lock(lock_); - return enter_count_ > 0; -} - -ScopedTrackPpapiMessage::ScopedTrackPpapiMessage() { - PpapiMessageTracker::GetInstance()->EnterMessageHandling(); -} - -ScopedTrackPpapiMessage::~ScopedTrackPpapiMessage() { - PpapiMessageTracker::GetInstance()->ExitMessageHandling(); -} - -} // namespace ppapi diff --git a/ppapi/shared_impl/ppapi_message_tracker.h b/ppapi/shared_impl/ppapi_message_tracker.h deleted file mode 100644 index d817b97..0000000 --- a/ppapi/shared_impl/ppapi_message_tracker.h +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef PPAPI_SHARED_IMPL_PPAPI_MESSAGE_TRACKER_H_ -#define PPAPI_SHARED_IMPL_PPAPI_MESSAGE_TRACKER_H_ - -#include "base/basictypes.h" -#include "base/synchronization/lock.h" -#include "ppapi/shared_impl/ppapi_shared_export.h" - -template <typename T> struct DefaultSingletonTraits; - -namespace ppapi { - -// PpapiMessageTracker uses a counter to record whether anyone is sending or -// receiving pepper messages in the current process. -// This class is thread safe. -class PPAPI_SHARED_EXPORT PpapiMessageTracker { - public: - static PpapiMessageTracker* GetInstance(); - - void EnterMessageHandling(); - void ExitMessageHandling(); - bool IsHandlingMessage(); - - private: - friend struct DefaultSingletonTraits<PpapiMessageTracker>; - - PpapiMessageTracker(); - ~PpapiMessageTracker(); - - base::Lock lock_; - int enter_count_; - - DISALLOW_COPY_AND_ASSIGN(PpapiMessageTracker); -}; - -class PPAPI_SHARED_EXPORT ScopedTrackPpapiMessage { - public: - ScopedTrackPpapiMessage(); - ~ScopedTrackPpapiMessage(); - - private: - DISALLOW_COPY_AND_ASSIGN(ScopedTrackPpapiMessage); -}; - -} // namespace ppapi - -#endif // PPAPI_SHARED_IMPL_PPAPI_MESSAGE_TRACKER_H_ |