From 81ba35b3f73e1d3d6fce2f17ac4b465399f128c4 Mon Sep 17 00:00:00 2001 From: Markus Stange Date: Tue, 10 Nov 2020 01:45:51 +0000 Subject: [PATCH] Bug 1675828 - Call OtherPidMaybeInvalid for the IPC marker because this code can run at times when the other pid is not known. r=jld This avoids a crash from the MOZ_RELEASE_ASSERT in OtherPid() on Android. Differential Revision: https://phabricator.services.mozilla.com/D96262 --- ipc/glue/MessageChannel.cpp | 13 ++++++++----- ipc/glue/ProtocolUtils.h | 2 +- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/ipc/glue/MessageChannel.cpp b/ipc/glue/MessageChannel.cpp index bc9e4406c0c4..f517ac8f23a9 100644 --- a/ipc/glue/MessageChannel.cpp +++ b/ipc/glue/MessageChannel.cpp @@ -2787,11 +2787,14 @@ void MessageChannel::AddProfilerMarker(const IPC::Message& aMessage, mMonitor->AssertCurrentThreadOwns(); #ifdef MOZ_GECKO_PROFILER if (profiler_feature_active(ProfilerFeature::IPCMessages)) { - int32_t pid = mListener->OtherPid(); - PROFILER_ADD_MARKER_WITH_PAYLOAD( - "IPC", IPC, IPCMarkerPayload, - (pid, aMessage.seqno(), aMessage.type(), mSide, aDirection, - MessagePhase::Endpoint, aMessage.is_sync(), TimeStamp::NowUnfuzzed())); + int32_t pid = mListener->OtherPidMaybeInvalid(); + if (pid != kInvalidProcessId) { + PROFILER_ADD_MARKER_WITH_PAYLOAD( + "IPC", IPC, IPCMarkerPayload, + (pid, aMessage.seqno(), aMessage.type(), mSide, aDirection, + MessagePhase::Endpoint, aMessage.is_sync(), + TimeStamp::NowUnfuzzed())); + } } #endif } diff --git a/ipc/glue/ProtocolUtils.h b/ipc/glue/ProtocolUtils.h index 5a685c195b07..554a84d918e3 100644 --- a/ipc/glue/ProtocolUtils.h +++ b/ipc/glue/ProtocolUtils.h @@ -513,9 +513,9 @@ class IToplevelProtocol : public IProtocol { already_AddRefed GetMessageEventTarget( const Message& aMsg); - private: base::ProcessId OtherPidMaybeInvalid() const { return mOtherPid; } + private: int32_t NextId(); template