mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 05:41:12 +00:00
Bug 1258663 - Crash annotate system call failures in the IPC transport. r=gabor
This commit is contained in:
parent
2b277c167c
commit
f77c0e8c25
@ -7,6 +7,10 @@
|
||||
|
||||
#include "base/process_util.h"
|
||||
|
||||
#ifdef OS_POSIX
|
||||
#include <errno.h>
|
||||
#endif
|
||||
|
||||
#include "mozilla/ipc/MessageChannel.h"
|
||||
#include "mozilla/ipc/ProtocolUtils.h"
|
||||
#include "mozilla/ipc/Transport.h"
|
||||
@ -295,6 +299,22 @@ bool DuplicateHandle(HANDLE aSourceHandle,
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef MOZ_CRASHREPORTER
|
||||
void AnnotateSystemError()
|
||||
{
|
||||
int64_t error = 0;
|
||||
#if defined(XP_WIN)
|
||||
error = ::GetLastError();
|
||||
#elif defined(OS_POSIX)
|
||||
error = errno;
|
||||
#endif
|
||||
if (error) {
|
||||
CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("SystemError"),
|
||||
nsPrintfCString("%lld", error));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
ProtocolErrorBreakpoint(const char* aMsg)
|
||||
{
|
||||
@ -325,6 +345,7 @@ FatalError(const char* aProtocolName, const char* aMsg,
|
||||
nsDependentCString(aProtocolName));
|
||||
CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("IPCFatalErrorMsg"),
|
||||
nsDependentCString(aMsg));
|
||||
AnnotateSystemError();
|
||||
#endif
|
||||
MOZ_CRASH("IPC FatalError in the parent process!");
|
||||
} else {
|
||||
|
@ -333,6 +333,16 @@ DuplicateHandle(HANDLE aSourceHandle,
|
||||
DWORD aOptions);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Annotate the crash reporter with the error error code from the most recent
|
||||
* system call.
|
||||
*/
|
||||
#ifdef MOZ_CRASHREPORTER
|
||||
void AnnotateSystemError();
|
||||
#else
|
||||
#define AnnotateSystemError() do { } while (0)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* An endpoint represents one end of a partially initialized IPDL channel. To
|
||||
* set up a new top-level protocol:
|
||||
|
@ -15,6 +15,7 @@
|
||||
|
||||
#include "mozilla/ipc/Transport.h"
|
||||
#include "mozilla/ipc/FileDescriptor.h"
|
||||
#include "ProtocolUtils.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
@ -70,6 +71,9 @@ DuplicateDescriptor(const TransportDescriptor& aTd)
|
||||
{
|
||||
TransportDescriptor result = aTd;
|
||||
result.mFd.fd = dup(aTd.mFd.fd);
|
||||
if (result.mFd.fd == -1) {
|
||||
AnnotateSystemError();
|
||||
}
|
||||
MOZ_RELEASE_ASSERT(result.mFd.fd != -1, "DuplicateDescriptor failed");
|
||||
return result;
|
||||
}
|
||||
|
@ -64,6 +64,9 @@ TransferHandleToProcess(HANDLE source, base::ProcessId pid)
|
||||
DWORD access = 0;
|
||||
DWORD options = DUPLICATE_SAME_ACCESS;
|
||||
bool ok = DuplicateHandle(source, pid, &handleDup, access, options);
|
||||
if (!ok) {
|
||||
AnnotateSystemError();
|
||||
}
|
||||
MOZ_RELEASE_ASSERT(ok);
|
||||
|
||||
// Now close our own copy of the handle (we're supposed to be transferring,
|
||||
@ -103,6 +106,9 @@ DuplicateDescriptor(const TransportDescriptor& aTd)
|
||||
DWORD options = DUPLICATE_SAME_ACCESS;
|
||||
bool ok = DuplicateHandle(aTd.mServerPipeHandle, base::GetCurrentProcId(),
|
||||
&serverDup, access, options);
|
||||
if (!ok) {
|
||||
AnnotateSystemError();
|
||||
}
|
||||
MOZ_RELEASE_ASSERT(ok);
|
||||
|
||||
TransportDescriptor desc = aTd;
|
||||
|
Loading…
Reference in New Issue
Block a user