Bug 1128454 - Add crash report annotations for plugin bridge operation failures. r=billm

This commit is contained in:
Jim Mathies 2015-07-09 19:07:49 -05:00
parent 381dd720a9
commit 9a5c8328b9
11 changed files with 66 additions and 30 deletions

View File

@ -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));
}
}

View File

@ -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;

View File

@ -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

View File

@ -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;
}

View File

@ -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);

View File

@ -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);

View File

@ -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*

View File

@ -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*

View File

@ -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')

View File

@ -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(),

View File

@ -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 */
/* ======================================================================= */