Bug 1648590 - Set the crash report remote annotation when we set the remote type. r=kmag

This patch moves the remote type crash annotation code from RecvSetProcessSandbox() to
RecvRemoteType(), where we actually set the remote type. This matters because
RecvSetProcessSandbox() only happens once when the process is created. If the process
is a preallocated process, it will get its remote type updated later, so we need to
also update the annotation.

It seems odd that we were setting the remote type annotation in a method related to
the sandbox and not where we set the remote type. My only guess is that prior to
bug 1332522 RecvSetProcessSandbox() happened first, so maybe they wanted to make sure
the annotation was set as early as possible. At that point in time, the remote type
never changed, so it was okay to just set it wherever, as early as possible.

Anyways, after that bug, the first call to RecvRemoteType() happens earlier, so this
change is strictly better.

I also fixed a typo in ContentParent.

Differential Revision: https://phabricator.services.mozilla.com/D82625
This commit is contained in:
Andrew McCreight 2020-07-10 01:56:13 +00:00
Родитель b8cb958484
Коммит 543079d871
2 изменённых файлов: 9 добавлений и 7 удалений

Просмотреть файл

@ -1650,11 +1650,7 @@ mozilla::ipc::IPCResult ContentChild::RecvSetProcessSandbox(
CrashReporter::Annotation::ContentSandboxCapabilities,
static_cast<int>(SandboxInfo::Get().AsInteger()));
# endif /* XP_LINUX && !OS_ANDROID */
// Use the prefix to avoid URIs from Fission isolated processes.
auto remoteTypePrefix = RemoteTypePrefix(GetRemoteType());
CrashReporter::AnnotateCrashReport(CrashReporter::Annotation::RemoteType,
remoteTypePrefix);
#endif /* MOZ_SANDBOX */
#endif /* MOZ_SANDBOX */
return IPC_OK();
}
@ -2588,6 +2584,8 @@ mozilla::ipc::IPCResult ContentChild::RecvRemoteType(
aRemoteType.get()));
}
auto remoteTypePrefix = RemoteTypePrefix(aRemoteType);
// Update the process name so about:memory's process names are more obvious.
if (aRemoteType == FILE_REMOTE_TYPE) {
SetProcessName(u"file:// Content"_ns);
@ -2597,13 +2595,17 @@ mozilla::ipc::IPCResult ContentChild::RecvRemoteType(
SetProcessName(u"Privileged Content"_ns);
} else if (aRemoteType == LARGE_ALLOCATION_REMOTE_TYPE) {
SetProcessName(u"Large Allocation Web Content"_ns);
} else if (RemoteTypePrefix(aRemoteType) == FISSION_WEB_REMOTE_TYPE) {
} else if (remoteTypePrefix == FISSION_WEB_REMOTE_TYPE) {
SetProcessName(u"Isolated Web Content"_ns);
}
// else "prealloc", "web" or "webCOOP+COEP" type -> "Web Content" already set
mRemoteType.Assign(aRemoteType);
// Use the prefix to avoid URIs from Fission isolated processes.
CrashReporter::AnnotateCrashReport(CrashReporter::Annotation::RemoteType,
remoteTypePrefix);
return IPC_OK();
}

Просмотреть файл

@ -928,7 +928,7 @@ already_AddRefed<ContentParent> ContentParent::GetUsedBrowserProcess(
p->AssertAlive();
// p may be a preallocated process, or (if not PREALLOC_REMOTE_TYPE)
// a perviously-used process that's being recycled. Currently this is
// a previously-used process that's being recycled. Currently this is
// only done for short-duration web (DEFAULT_REMOTE_TYPE) processes
preallocated = p->mRemoteType == PREALLOC_REMOTE_TYPE;
// For pre-allocated process we have not set the opener yet.