Bug 1870278 - Remove diagnostics code around mozilla::net::LoadInfo::SetReservedClientInfo. r=dom-worker-reviewers,asuth

To help investigate the crash in bug 1761208, we added code to register
the top frames of the call stack when reservedClientInfo is
set, such that it can be recovered from crash dumps. That happened in
bug 1868304. Now that we have collected these call stacks, we can remove
this diagnostics code which is currently shipped to all Nightly users
on Windows x64.

Differential Revision: https://phabricator.services.mozilla.com/D196577
This commit is contained in:
Yannis Juglaret 2023-12-15 17:26:12 +00:00
Родитель a9c9ffa5f1
Коммит f996f5df8e
2 изменённых файлов: 0 добавлений и 67 удалений

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

@ -22,7 +22,6 @@
#include "mozilla/dom/WindowGlobalParent.h"
#include "mozilla/net/CookieJarSettings.h"
#include "mozilla/NullPrincipal.h"
#include "mozilla/StackWalk.h"
#include "mozilla/StaticPrefs_network.h"
#include "mozilla/StaticPrefs_security.h"
#include "mozIThirdPartyUtil.h"
@ -51,23 +50,6 @@ using namespace mozilla::dom;
namespace mozilla::net {
#if defined(NIGHTLY_BUILD) && defined(XP_WIN) && defined(_M_X64)
/* static */ void LoadInfo::StackTrace::StackWalkCallback(uint32_t aFrameNumber,
void* aPc, void* aSp,
void* aClosure) {
StackTrace* st = (StackTrace*)aClosure;
MOZ_ASSERT(st->mLength < kMaxFrames);
st->mPcs[st->mLength] = aPc;
st->mLength++;
MOZ_ASSERT(st->mLength == aFrameNumber);
}
void LoadInfo::StackTrace::Fill() {
mLength = 0;
MozStackWalk(StackWalkCallback, nullptr, kMaxFrames, this);
}
#endif // NIGHTLY_BUILD && XP_WIN && _M_X64
static nsCString CurrentRemoteType() {
MOZ_ASSERT(XRE_IsParentProcess() || XRE_IsContentProcess());
if (ContentChild* cc = ContentChild::GetSingleton()) {
@ -791,11 +773,6 @@ LoadInfo::LoadInfo(
mHasInjectedCookieForCookieBannerHandling(
aHasInjectedCookieForCookieBannerHandling),
mWasSchemelessInput(aWasSchemelessInput) {
#if defined(NIGHTLY_BUILD) && defined(XP_WIN) && defined(_M_X64)
if (mReservedClientInfo.isSome()) {
mReservedClientInfoEmplaceTrace.Fill();
}
#endif // NIGHTLY_BUILD && XP_WIN && _M_X64
// Only top level TYPE_DOCUMENT loads can have a null loadingPrincipal
MOZ_ASSERT(mLoadingPrincipal ||
aContentPolicyType == nsIContentPolicy::TYPE_DOCUMENT);
@ -2149,15 +2126,6 @@ UniquePtr<ClientSource> LoadInfo::TakeReservedClientSource() {
return std::move(mReservedClientSource);
}
#if defined(NIGHTLY_BUILD) && defined(XP_WIN) && defined(_M_X64)
[[clang::optnone]] MOZ_NEVER_INLINE static void CrashWithEmplaceTrace(
const LoadInfo::StackTrace& aEmplaceStackTrace) {
// Make a copy of the stack trace available on the crashing thread's stack
LoadInfo::StackTrace emplaceStackTrace [[maybe_unused]]{aEmplaceStackTrace};
MOZ_CRASH("mReservedClientInfo already set, emplace stack trace available");
}
#endif // NIGHTLY_BUILD && XP_WIN && _M_X64
void LoadInfo::SetReservedClientInfo(const ClientInfo& aClientInfo) {
MOZ_DIAGNOSTIC_ASSERT(mInitialClientInfo.isNothing());
// Treat assignments of the same value as a no-op. The emplace below
@ -2166,16 +2134,10 @@ void LoadInfo::SetReservedClientInfo(const ClientInfo& aClientInfo) {
if (mReservedClientInfo.ref() == aClientInfo) {
return;
}
#if defined(NIGHTLY_BUILD) && defined(XP_WIN) && defined(_M_X64)
CrashWithEmplaceTrace(mReservedClientInfoEmplaceTrace);
#endif // NIGHTLY_BUILD && XP_WIN && _M_X64
MOZ_DIAGNOSTIC_ASSERT(false, "mReservedClientInfo already set");
mReservedClientInfo.reset();
}
mReservedClientInfo.emplace(aClientInfo);
#if defined(NIGHTLY_BUILD) && defined(XP_WIN) && defined(_M_X64)
mReservedClientInfoEmplaceTrace.Fill();
#endif // NIGHTLY_BUILD && XP_WIN && _M_X64
}
void LoadInfo::OverrideReservedClientInfoInParent(
@ -2186,9 +2148,6 @@ void LoadInfo::OverrideReservedClientInfoInParent(
mInitialClientInfo.reset();
mReservedClientInfo.reset();
mReservedClientInfo.emplace(aClientInfo);
#if defined(NIGHTLY_BUILD) && defined(XP_WIN) && defined(_M_X64)
mReservedClientInfoEmplaceTrace.Fill();
#endif // NIGHTLY_BUILD && XP_WIN && _M_X64
}
const Maybe<ClientInfo>& LoadInfo::GetReservedClientInfo() {

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

@ -305,32 +305,6 @@ class LoadInfo final : public nsILoadInfo {
Maybe<mozilla::dom::ClientInfo> mClientInfo;
UniquePtr<mozilla::dom::ClientSource> mReservedClientSource;
Maybe<mozilla::dom::ClientInfo> mReservedClientInfo;
// Diagnostics code for bug 1761208
#if defined(NIGHTLY_BUILD) && defined(XP_WIN) && defined(_M_X64)
public:
class StackTrace {
public:
static const size_t kMaxFrames = 24;
// The number of PCs in the stack trace.
size_t mLength;
// The PCs in the stack trace. Only the first mLength are initialized.
const void* mPcs[kMaxFrames];
public:
void Fill();
private:
static void StackWalkCallback(uint32_t aFrameNumber, void* aPc, void* aSp,
void* aClosure);
};
private:
StackTrace mReservedClientInfoEmplaceTrace;
#endif // NIGHTLY_BUILD && XP_WIN && _M_X64
Maybe<mozilla::dom::ClientInfo> mInitialClientInfo;
Maybe<mozilla::dom::ServiceWorkerDescriptor> mController;
RefPtr<mozilla::dom::PerformanceStorage> mPerformanceStorage;