summaryrefslogtreecommitdiff
path: root/chromium/components/crash
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2020-10-12 14:27:29 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2020-10-13 09:35:20 +0000
commitc30a6232df03e1efbd9f3b226777b07e087a1122 (patch)
treee992f45784689f373bcc38d1b79a239ebe17ee23 /chromium/components/crash
parent7b5b123ac58f58ffde0f4f6e488bcd09aa4decd3 (diff)
downloadqtwebengine-chromium-85-based.tar.gz
BASELINE: Update Chromium to 85.0.4183.14085-based
Change-Id: Iaa42f4680837c57725b1344f108c0196741f6057 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'chromium/components/crash')
-rw-r--r--chromium/components/crash/android/crash_keys_android.cc1
-rw-r--r--chromium/components/crash/content/browser/child_exit_observer_android.cc143
-rw-r--r--chromium/components/crash/content/browser/child_exit_observer_android.h39
-rw-r--r--chromium/components/crash/content/browser/crash_handler_host_linux.cc9
-rw-r--r--chromium/components/crash/core/app/breakpad_linux.cc1
-rw-r--r--chromium/components/crash/core/browser/resources/crashes.html1
-rw-r--r--chromium/components/crash/core/common/objc_zombie.mm1
7 files changed, 96 insertions, 99 deletions
diff --git a/chromium/components/crash/android/crash_keys_android.cc b/chromium/components/crash/android/crash_keys_android.cc
index c458cd7fcb0..d321343e57b 100644
--- a/chromium/components/crash/android/crash_keys_android.cc
+++ b/chromium/components/crash/android/crash_keys_android.cc
@@ -6,6 +6,7 @@
#include "base/android/jni_android.h"
#include "base/android/jni_string.h"
+#include "base/stl_util.h"
#include "components/crash/android/jni_headers/CrashKeys_jni.h"
#include "components/crash/core/common/crash_key.h"
diff --git a/chromium/components/crash/content/browser/child_exit_observer_android.cc b/chromium/components/crash/content/browser/child_exit_observer_android.cc
index 20d699b2685..2fea14aaa60 100644
--- a/chromium/components/crash/content/browser/child_exit_observer_android.cc
+++ b/chromium/components/crash/content/browser/child_exit_observer_android.cc
@@ -8,12 +8,13 @@
#include "base/bind.h"
#include "base/check_op.h"
-#include "base/no_destructor.h"
#include "base/stl_util.h"
#include "components/crash/content/browser/crash_memory_metrics_collector_android.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/child_process_data.h"
#include "content/public/browser/child_process_termination_info.h"
+#include "content/public/browser/notification_service.h"
+#include "content/public/browser/notification_types.h"
using content::BrowserThread;
@@ -21,32 +22,14 @@ namespace crash_reporter {
namespace {
-void PopulateTerminationInfoForRenderProcessHost(
- content::RenderProcessHost* rph,
- ChildExitObserver::TerminationInfo* info) {
- info->process_host_id = rph->GetID();
- info->pid = rph->GetProcess().Handle();
- info->process_type = content::PROCESS_TYPE_RENDERER;
- info->app_state = base::android::APPLICATION_STATE_UNKNOWN;
- info->renderer_has_visible_clients = rph->VisibleClientCount() > 0;
- info->renderer_was_subframe = rph->GetFrameDepth() > 0u;
- CrashMemoryMetricsCollector* collector =
- CrashMemoryMetricsCollector::GetFromRenderProcessHost(rph);
-
- // CrashMemoryMetircsCollector is created in chrome_content_browser_client,
- // and does not exist in non-chrome platforms such as android webview /
- // chromecast.
- if (collector) {
- // SharedMemory creation / Map() might fail.
- DCHECK(collector->MemoryMetrics());
- info->blink_oom_metrics = *collector->MemoryMetrics();
- }
-}
+base::LazyInstance<ChildExitObserver>::DestructorAtExit g_instance =
+ LAZY_INSTANCE_INITIALIZER;
void PopulateTerminationInfo(
const content::ChildProcessTerminationInfo& content_info,
ChildExitObserver::TerminationInfo* info) {
info->binding_state = content_info.binding_state;
+ info->threw_exception_during_init = content_info.threw_exception_during_init;
info->was_killed_intentionally_by_browser =
content_info.was_killed_intentionally_by_browser;
info->remaining_process_with_strong_binding =
@@ -63,13 +46,6 @@ void PopulateTerminationInfo(
info->renderer_was_subframe = content_info.renderer_was_subframe;
}
-ChildExitObserver* CreateSingletonInstance() {
- static base::NoDestructor<ChildExitObserver> s_instance;
- return s_instance.get();
-}
-
-ChildExitObserver* g_instance = nullptr;
-
} // namespace
ChildExitObserver::TerminationInfo::TerminationInfo() = default;
@@ -84,17 +60,26 @@ void ChildExitObserver::Create() {
// If this DCHECK fails in a unit test then a previously executing
// test that makes use of ChildExitObserver forgot to create a
// ShadowingAtExitManager.
- DCHECK(!g_instance);
- g_instance = CreateSingletonInstance();
+ DCHECK(!g_instance.IsCreated());
+ g_instance.Get();
}
// static
ChildExitObserver* ChildExitObserver::GetInstance() {
- DCHECK(g_instance);
- return g_instance;
+ DCHECK(g_instance.IsCreated());
+ return g_instance.Pointer();
}
ChildExitObserver::ChildExitObserver() {
+ notification_registrar_.Add(this,
+ content::NOTIFICATION_RENDERER_PROCESS_CREATED,
+ content::NotificationService::AllSources());
+ notification_registrar_.Add(this,
+ content::NOTIFICATION_RENDERER_PROCESS_TERMINATED,
+ content::NotificationService::AllSources());
+ notification_registrar_.Add(this,
+ content::NOTIFICATION_RENDERER_PROCESS_CLOSED,
+ content::NotificationService::AllSources());
BrowserChildProcessObserver::Add(this);
scoped_observer_.Add(crashpad::CrashHandlerHost::Get());
}
@@ -175,48 +160,70 @@ void ChildExitObserver::BrowserChildProcessKilled(
// Subsequent BrowserChildProcessHostDisconnected will call OnChildExit.
}
-void ChildExitObserver::OnRenderProcessHostCreated(
- content::RenderProcessHost* rph) {
- process_host_id_to_pid_[rph->GetID()] = rph->GetProcess().Handle();
- rph_observers_.Add(rph);
-}
-
-void ChildExitObserver::RenderProcessExited(
- content::RenderProcessHost* host,
- const content::ChildProcessTerminationInfo& termination_info) {
- OnRenderProcessHostGone(host, termination_info);
-}
-
-void ChildExitObserver::RenderProcessHostDestroyed(
- content::RenderProcessHost* host) {
- OnRenderProcessHostGone(host, base::nullopt);
-}
+void ChildExitObserver::Observe(int type,
+ const content::NotificationSource& source,
+ const content::NotificationDetails& details) {
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
+ content::RenderProcessHost* rph =
+ content::Source<content::RenderProcessHost>(source).ptr();
+ TerminationInfo info;
+ info.process_host_id = rph->GetID();
+ info.pid = rph->GetProcess().Handle();
+ info.process_type = content::PROCESS_TYPE_RENDERER;
+ info.app_state = base::android::APPLICATION_STATE_UNKNOWN;
+ info.renderer_has_visible_clients = rph->VisibleClientCount() > 0;
+ info.renderer_was_subframe = rph->GetFrameDepth() > 0u;
+ CrashMemoryMetricsCollector* collector =
+ CrashMemoryMetricsCollector::GetFromRenderProcessHost(rph);
-void ChildExitObserver::OnRenderProcessHostGone(
- content::RenderProcessHost* host,
- base::Optional<content::ChildProcessTerminationInfo> termination_info) {
- const auto& iter = process_host_id_to_pid_.find(host->GetID());
+ // CrashMemoryMetircsCollector is created in chrome_content_browser_client,
+ // and does not exist in non-chrome platforms such as android webview /
+ // chromecast.
+ if (collector) {
+ // SharedMemory creation / Map() might fail.
+ DCHECK(collector->MemoryMetrics());
+ info.blink_oom_metrics = *collector->MemoryMetrics();
+ }
+ switch (type) {
+ case content::NOTIFICATION_RENDERER_PROCESS_TERMINATED: {
+ // NOTIFICATION_RENDERER_PROCESS_TERMINATED is sent when the renderer
+ // process is cleanly shutdown.
+ info.normal_termination = true;
+ break;
+ }
+ case content::NOTIFICATION_RENDERER_PROCESS_CLOSED: {
+ // We do not care about android fast shutdowns as it is a known case where
+ // the renderer is intentionally killed when we are done with it.
+ info.normal_termination = rph->FastShutdownStarted();
+ info.app_state = base::android::ApplicationStatusListener::GetState();
+ const auto& content_info =
+ *content::Details<content::ChildProcessTerminationInfo>(details)
+ .ptr();
+ PopulateTerminationInfo(content_info, &info);
+ break;
+ }
+ case content::NOTIFICATION_RENDERER_PROCESS_CREATED: {
+ // The child process pid isn't available when process is gone, keep a
+ // mapping between process_host_id and pid, so we can find it later.
+ process_host_id_to_pid_[rph->GetID()] = rph->GetProcess().Handle();
+ return;
+ }
+ default:
+ NOTREACHED();
+ return;
+ }
+ const auto& iter = process_host_id_to_pid_.find(rph->GetID());
+ // NOTIFICATION_RENDERER_PROCESS_CLOSED corresponds to death of an underlying
+ // RenderProcess. NOTIFICATION_RENDERER_PROCESS_TERMINATED corresponds to when
+ // the RenderProcessHost's lifetime is ending. Ideally, we'd only listen to
+ // the former, but if the RenderProcessHost is destroyed before the
+ // RenderProcess, then the former is never sent.
if (iter == process_host_id_to_pid_.end()) {
return;
}
-
- rph_observers_.Remove(host);
- TerminationInfo info;
- PopulateTerminationInfoForRenderProcessHost(host, &info);
if (info.pid == base::kNullProcessHandle) {
info.pid = iter->second;
}
-
- if (termination_info.has_value()) {
- // We do not care about android fast shutdowns as it is a known case where
- // the renderer is intentionally killed when we are done with it.
- info.normal_termination = host->FastShutdownStarted();
- info.app_state = base::android::ApplicationStatusListener::GetState();
- PopulateTerminationInfo(*termination_info, &info);
- } else {
- info.normal_termination = true;
- }
-
process_host_id_to_pid_.erase(iter);
OnChildExit(&info);
}
diff --git a/chromium/components/crash/content/browser/child_exit_observer_android.h b/chromium/components/crash/content/browser/child_exit_observer_android.h
index 4fda992a013..c7c8d1bb29d 100644
--- a/chromium/components/crash/content/browser/child_exit_observer_android.h
+++ b/chromium/components/crash/content/browser/child_exit_observer_android.h
@@ -11,17 +11,15 @@
#include "base/android/application_status_listener.h"
#include "base/android/child_process_binding_types.h"
-#include "base/no_destructor.h"
-#include "base/optional.h"
+#include "base/lazy_instance.h"
#include "base/process/process.h"
#include "base/scoped_observer.h"
#include "base/synchronization/lock.h"
#include "components/crash/content/browser/crash_handler_host_linux.h"
#include "content/public/browser/browser_child_process_observer.h"
-#include "content/public/browser/child_process_termination_info.h"
+#include "content/public/browser/notification_observer.h"
+#include "content/public/browser/notification_registrar.h"
#include "content/public/browser/render_process_host.h"
-#include "content/public/browser/render_process_host_creation_observer.h"
-#include "content/public/browser/render_process_host_observer.h"
#include "content/public/common/child_process_host.h"
#include "content/public/common/process_type.h"
#include "third_party/blink/public/common/oom_intervention/oom_intervention_types.h"
@@ -36,8 +34,7 @@ namespace crash_reporter {
// purpose of reacting to child process crashes.
// The ChildExitObserver instance exists on the browser main thread.
class ChildExitObserver : public content::BrowserChildProcessObserver,
- public content::RenderProcessHostCreationObserver,
- public content::RenderProcessHostObserver,
+ public content::NotificationObserver,
public crashpad::CrashHandlerHost::Observer {
public:
struct TerminationInfo {
@@ -48,7 +45,9 @@ class ChildExitObserver : public content::BrowserChildProcessObserver,
TerminationInfo(const TerminationInfo& other);
TerminationInfo& operator=(const TerminationInfo& other);
- bool is_crashed() const { return crash_signo != kInvalidSigno; }
+ bool is_crashed() const {
+ return crash_signo != kInvalidSigno || threw_exception_during_init;
+ }
int process_host_id = content::ChildProcessHost::kInvalidUniqueID;
// |pid| may not be valid if termination happens before the process has
@@ -70,6 +69,7 @@ class ChildExitObserver : public content::BrowserChildProcessObserver,
// because those fields hold no useful information on Android.
base::android::ChildBindingState binding_state =
base::android::ChildBindingState::UNBOUND;
+ bool threw_exception_during_init = false;
bool was_killed_intentionally_by_browser = false;
int remaining_process_with_strong_binding = 0;
int remaining_process_with_moderate_binding = 0;
@@ -135,7 +135,7 @@ class ChildExitObserver : public content::BrowserChildProcessObserver,
void ChildReceivedCrashSignal(base::ProcessId pid, int signo) override;
private:
- friend class base::NoDestructor<ChildExitObserver>;
+ friend struct base::LazyInstanceTraitsBase<ChildExitObserver>;
ChildExitObserver();
~ChildExitObserver() override;
@@ -147,23 +147,15 @@ class ChildExitObserver : public content::BrowserChildProcessObserver,
const content::ChildProcessData& data,
const content::ChildProcessTerminationInfo& info) override;
- // RenderProcessHostCreationObserver:
- void OnRenderProcessHostCreated(
- content::RenderProcessHost* process_host) override;
-
- // RenderProcessHostObserver:
- void RenderProcessExited(
- content::RenderProcessHost* host,
- const content::ChildProcessTerminationInfo& info) override;
- void RenderProcessHostDestroyed(content::RenderProcessHost* host) override;
+ // NotificationObserver implementation:
+ void Observe(int type,
+ const content::NotificationSource& source,
+ const content::NotificationDetails& details) override;
// Called on child process exit (including crash).
void OnChildExit(TerminationInfo* info);
- // Called on RenderProcessHost removal.
- void OnRenderProcessHostGone(
- content::RenderProcessHost* host,
- base::Optional<content::ChildProcessTerminationInfo> termination_info);
+ content::NotificationRegistrar notification_registrar_;
base::Lock registered_clients_lock_;
std::vector<std::unique_ptr<Client>> registered_clients_;
@@ -181,9 +173,6 @@ class ChildExitObserver : public content::BrowserChildProcessObserver,
crashpad::CrashHandlerHost::Observer>
scoped_observer_{this};
- ScopedObserver<content::RenderProcessHost, content::RenderProcessHostObserver>
- rph_observers_{this};
-
DISALLOW_COPY_AND_ASSIGN(ChildExitObserver);
};
diff --git a/chromium/components/crash/content/browser/crash_handler_host_linux.cc b/chromium/components/crash/content/browser/crash_handler_host_linux.cc
index e63d26f25a3..618857ae995 100644
--- a/chromium/components/crash/content/browser/crash_handler_host_linux.cc
+++ b/chromium/components/crash/content/browser/crash_handler_host_linux.cc
@@ -31,7 +31,6 @@
#include "base/stl_util.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
-#include "base/task/post_task.h"
#include "base/task/thread_pool.h"
#include "base/threading/scoped_blocking_call.h"
#include "base/threading/thread.h"
@@ -137,8 +136,8 @@ CrashHandlerHostLinux::CrashHandlerHostLinux(const std::string& process_type,
process_socket_ = fds[0];
browser_socket_ = fds[1];
- base::PostTask(
- FROM_HERE, {BrowserThread::IO},
+ content::GetIOThreadTaskRunner({})->PostTask(
+ FROM_HERE,
base::BindOnce(&CrashHandlerHostLinux::Init, base::Unretained(this)));
}
@@ -526,8 +525,8 @@ CrashHandlerHost* CrashHandlerHost::Get() {
}
int CrashHandlerHost::GetDeathSignalSocket() {
- static bool initialized = base::PostTask(
- FROM_HERE, {BrowserThread::IO},
+ static bool initialized = content::GetIOThreadTaskRunner({})->PostTask(
+ FROM_HERE,
base::BindOnce(&CrashHandlerHost::Init, base::Unretained(this)));
DCHECK(initialized);
diff --git a/chromium/components/crash/core/app/breakpad_linux.cc b/chromium/components/crash/core/app/breakpad_linux.cc
index 8ca43e2a8a1..d2ca4a9056e 100644
--- a/chromium/components/crash/core/app/breakpad_linux.cc
+++ b/chromium/components/crash/core/app/breakpad_linux.cc
@@ -31,6 +31,7 @@
#include "base/files/file_path.h"
#include "base/lazy_instance.h"
#include "base/linux_util.h"
+#include "base/logging.h"
#include "base/macros.h"
#include "base/path_service.h"
#include "base/posix/eintr_wrapper.h"
diff --git a/chromium/components/crash/core/browser/resources/crashes.html b/chromium/components/crash/core/browser/resources/crashes.html
index d5bb41652bd..e04058e786a 100644
--- a/chromium/components/crash/core/browser/resources/crashes.html
+++ b/chromium/components/crash/core/browser/resources/crashes.html
@@ -80,6 +80,5 @@
<p id="noCrashes" hidden>$i18n{noCrashesMessage}</p>
</div>
- <script src="chrome://resources/js/jstemplate_compiled.js"></script>
</body>
</html>
diff --git a/chromium/components/crash/core/common/objc_zombie.mm b/chromium/components/crash/core/common/objc_zombie.mm
index 3df847911f8..9f4104949d6 100644
--- a/chromium/components/crash/core/common/objc_zombie.mm
+++ b/chromium/components/crash/core/common/objc_zombie.mm
@@ -14,6 +14,7 @@
#include "base/debug/stack_trace.h"
#include "base/logging.h"
+#include "base/notreached.h"
#include "base/posix/eintr_wrapper.h"
#include "base/strings/stringprintf.h"
#include "base/synchronization/lock.h"