mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 05:11:16 +00:00
Bug 1128454 - Add crash report annotations for plugin bridge operation failures. r=billm
This commit is contained in:
parent
381dd720a9
commit
9a5c8328b9
@ -1047,7 +1047,7 @@ ContentParent::RecvBridgeToChildProcess(const ContentParentId& aCpId)
|
||||
ContentParentId parentId;
|
||||
if (cpm->GetParentProcessId(cp->ChildID(), &parentId) &&
|
||||
parentId == this->ChildID()) {
|
||||
return PContentBridge::Bridge(this, cp);
|
||||
return NS_SUCCEEDED(PContentBridge::Bridge(this, cp));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1052,7 +1052,7 @@ GMPParent::EnsureProcessLoaded(base::ProcessId* aID)
|
||||
bool
|
||||
GMPParent::Bridge(GMPServiceParent* aGMPServiceParent)
|
||||
{
|
||||
if (!PGMPContent::Bridge(aGMPServiceParent, this)) {
|
||||
if (NS_FAILED(PGMPContent::Bridge(aGMPServiceParent, this))) {
|
||||
return false;
|
||||
}
|
||||
++mGMPContentChildCount;
|
||||
|
@ -129,7 +129,18 @@ mozilla::plugins::SetupBridge(uint32_t aPluginId,
|
||||
// We'll handle the bridging asynchronously
|
||||
return true;
|
||||
}
|
||||
return PPluginModule::Bridge(aContentParent, chromeParent);
|
||||
*rv = PPluginModule::Bridge(aContentParent, chromeParent);
|
||||
if (NS_FAILED(*rv)) {
|
||||
#if defined(MOZ_CRASHREPORTER)
|
||||
// We are going to abort due to the failure, lets note the cause
|
||||
// in the report for diagnosing.
|
||||
nsAutoCString error;
|
||||
error.AppendPrintf("%X", *rv);
|
||||
CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("BridgePluginError"), error);
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
#ifdef MOZ_CRASHREPORTER_INJECTOR
|
||||
|
@ -179,34 +179,41 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
bool
|
||||
nsresult
|
||||
Bridge(const PrivateIPDLInterface&,
|
||||
MessageChannel* aParentChannel, ProcessId aParentPid,
|
||||
MessageChannel* aChildChannel, ProcessId aChildPid,
|
||||
ProtocolId aProtocol, ProtocolId aChildProtocol)
|
||||
{
|
||||
if (!aParentPid || !aChildPid) {
|
||||
return false;
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
TransportDescriptor parentSide, childSide;
|
||||
if (!CreateTransport(aParentPid, &parentSide, &childSide)) {
|
||||
return false;
|
||||
nsresult rv;
|
||||
if (NS_FAILED(rv = CreateTransport(aParentPid, &parentSide, &childSide))) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
if (!aParentChannel->Send(new ChannelOpened(parentSide,
|
||||
aChildPid,
|
||||
aProtocol,
|
||||
IPC::Message::PRIORITY_URGENT)) ||
|
||||
!aChildChannel->Send(new ChannelOpened(childSide,
|
||||
aParentPid,
|
||||
aChildProtocol,
|
||||
IPC::Message::PRIORITY_URGENT))) {
|
||||
IPC::Message::PRIORITY_URGENT))) {
|
||||
CloseDescriptor(parentSide);
|
||||
CloseDescriptor(childSide);
|
||||
return false;
|
||||
return NS_ERROR_BRIDGE_OPEN_PARENT;
|
||||
}
|
||||
return true;
|
||||
|
||||
if (!aChildChannel->Send(new ChannelOpened(childSide,
|
||||
aParentPid,
|
||||
aChildProtocol,
|
||||
IPC::Message::PRIORITY_URGENT))) {
|
||||
CloseDescriptor(parentSide);
|
||||
CloseDescriptor(childSide);
|
||||
return NS_ERROR_BRIDGE_OPEN_CHILD;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
bool
|
||||
@ -224,7 +231,7 @@ Open(const PrivateIPDLInterface&,
|
||||
}
|
||||
|
||||
TransportDescriptor parentSide, childSide;
|
||||
if (!CreateTransport(parentId, &parentSide, &childSide)) {
|
||||
if (NS_FAILED(CreateTransport(parentId, &parentSide, &childSide))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -295,7 +295,7 @@ FatalError(const char* aProtocolName, const char* aMsg,
|
||||
|
||||
struct PrivateIPDLInterface {};
|
||||
|
||||
bool
|
||||
nsresult
|
||||
Bridge(const PrivateIPDLInterface&,
|
||||
MessageChannel*, base::ProcessId, MessageChannel*, base::ProcessId,
|
||||
ProtocolId, ProtocolId);
|
||||
|
@ -24,8 +24,9 @@ class FileDescriptor;
|
||||
|
||||
typedef IPC::Channel Transport;
|
||||
|
||||
bool CreateTransport(base::ProcessId aProcIdOne,
|
||||
TransportDescriptor* aOne, TransportDescriptor* aTwo);
|
||||
nsresult CreateTransport(base::ProcessId aProcIdOne,
|
||||
TransportDescriptor* aOne,
|
||||
TransportDescriptor* aTwo);
|
||||
|
||||
Transport* OpenDescriptor(const TransportDescriptor& aTd,
|
||||
Transport::Mode aMode);
|
||||
|
@ -21,9 +21,10 @@ using base::ProcessHandle;
|
||||
namespace mozilla {
|
||||
namespace ipc {
|
||||
|
||||
bool
|
||||
CreateTransport(base::ProcessId /*unused*/,
|
||||
TransportDescriptor* aOne, TransportDescriptor* aTwo)
|
||||
nsresult
|
||||
CreateTransport(base::ProcessId aProcIdOne,
|
||||
TransportDescriptor* aOne,
|
||||
TransportDescriptor* aTwo)
|
||||
{
|
||||
wstring id = IPC::Channel::GenerateVerifiedChannelID(std::wstring());
|
||||
// Use MODE_SERVER to force creation of the socketpair
|
||||
@ -32,7 +33,7 @@ CreateTransport(base::ProcessId /*unused*/,
|
||||
int fd2, dontcare;
|
||||
t.GetClientFileDescriptorMapping(&fd2, &dontcare);
|
||||
if (fd1 < 0 || fd2 < 0) {
|
||||
return false;
|
||||
return NS_ERROR_TRANSPORT_INIT;
|
||||
}
|
||||
|
||||
// The Transport closes these fds when it goes out of scope, so we
|
||||
@ -40,12 +41,12 @@ CreateTransport(base::ProcessId /*unused*/,
|
||||
fd1 = dup(fd1);
|
||||
fd2 = dup(fd2);
|
||||
if (fd1 < 0 || fd2 < 0) {
|
||||
return false;
|
||||
return NS_ERROR_DUPLICATE_HANDLE;
|
||||
}
|
||||
|
||||
aOne->mFd = base::FileDescriptor(fd1, true/*close after sending*/);
|
||||
aTwo->mFd = base::FileDescriptor(fd2, true/*close after sending*/);
|
||||
return true;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
Transport*
|
||||
|
@ -18,16 +18,17 @@ using base::ProcessHandle;
|
||||
namespace mozilla {
|
||||
namespace ipc {
|
||||
|
||||
bool
|
||||
nsresult
|
||||
CreateTransport(base::ProcessId aProcIdOne,
|
||||
TransportDescriptor* aOne, TransportDescriptor* aTwo)
|
||||
TransportDescriptor* aOne,
|
||||
TransportDescriptor* aTwo)
|
||||
{
|
||||
wstring id = IPC::Channel::GenerateVerifiedChannelID(std::wstring());
|
||||
// Use MODE_SERVER to force creation of the pipe
|
||||
Transport t(id, Transport::MODE_SERVER, nullptr);
|
||||
HANDLE serverPipe = t.GetServerPipeHandle();
|
||||
if (!serverPipe) {
|
||||
return false;
|
||||
return NS_ERROR_TRANSPORT_INIT;
|
||||
}
|
||||
|
||||
// NB: we create the server pipe immediately, instead of just
|
||||
@ -39,13 +40,13 @@ CreateTransport(base::ProcessId aProcIdOne,
|
||||
DWORD access = 0;
|
||||
DWORD options = DUPLICATE_SAME_ACCESS;
|
||||
if (!DuplicateHandle(serverPipe, aProcIdOne, &serverDup, access, options)) {
|
||||
return false;
|
||||
return NS_ERROR_DUPLICATE_HANDLE;
|
||||
}
|
||||
|
||||
aOne->mPipeName = aTwo->mPipeName = id;
|
||||
aOne->mServerPipe = serverDup;
|
||||
aTwo->mServerPipe = INVALID_HANDLE_VALUE;
|
||||
return true;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
Transport*
|
||||
|
@ -331,6 +331,7 @@ Type.BOOL = Type('bool')
|
||||
Type.INT = Type('int')
|
||||
Type.INT32 = Type('int32_t')
|
||||
Type.INTPTR = Type('intptr_t')
|
||||
Type.NSRESULT = Type('nsresult')
|
||||
Type.UINT32 = Type('uint32_t')
|
||||
Type.UINT32PTR = Type('uint32_t', ptr=1)
|
||||
Type.SIZE = Type('size_t')
|
||||
|
@ -1680,7 +1680,7 @@ class _GenerateProtocolCode(ipdl.ast.Visitor):
|
||||
'Bridge',
|
||||
params=[ Decl(parentHandleType, parentvar.name),
|
||||
Decl(childHandleType, childvar.name) ],
|
||||
ret=Type.BOOL))
|
||||
ret=Type.NSRESULT))
|
||||
bridgefunc.addstmt(StmtReturn(ExprCall(
|
||||
ExprVar('mozilla::ipc::Bridge'),
|
||||
args=[ _backstagePass(),
|
||||
|
@ -769,6 +769,20 @@
|
||||
#undef MODULE
|
||||
|
||||
|
||||
/* ======================================================================= */
|
||||
/* 28: NS_ERROR_MODULE_IPC */
|
||||
/* ======================================================================= */
|
||||
#define MODULE NS_ERROR_MODULE_IPC
|
||||
// Initial creation of a Transport object failed internally for unknown reasons.
|
||||
ERROR(NS_ERROR_TRANSPORT_INIT, FAILURE(1)),
|
||||
// Generic error related to duplicating handle failures.
|
||||
ERROR(NS_ERROR_DUPLICATE_HANDLE, FAILURE(2)),
|
||||
// Bridging: failure trying to open the connection to the parent
|
||||
ERROR(NS_ERROR_BRIDGE_OPEN_PARENT, FAILURE(3)),
|
||||
// Bridging: failure trying to open the connection to the child
|
||||
ERROR(NS_ERROR_BRIDGE_OPEN_CHILD, FAILURE(4)),
|
||||
#undef MODULE
|
||||
|
||||
/* ======================================================================= */
|
||||
/* 29: NS_ERROR_MODULE_SVG */
|
||||
/* ======================================================================= */
|
||||
|
Loading…
Reference in New Issue
Block a user