зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1324093 - Part 1: Move MOZ_REALLY_CRASH's null-deref and TerminateProcess into a never-inline function. r=froydnj
The C versus C++ distinction was only there so that Android could make sure it used the global ::abort. I didn't see the need to maintain the distinction for Windows. (Besides, with this change we're no longer doing textual inclusion of "TerminateProcess" in the macro, so people can't take over the name.) Linux's abort sequence wasn't long enough to be troublesome, so I left it alone. MozReview-Commit-ID: Ah5XtWpevGz --HG-- extra : rebase_source : 37c3fb4c50bcba8e48c6a965a02e3f8608940538
This commit is contained in:
Родитель
d27150b889
Коммит
dd8c1f9d4e
|
@ -47,7 +47,7 @@ AnnotateMozCrashReason(const char* reason)
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#ifdef WIN32
|
#ifdef _MSC_VER
|
||||||
/*
|
/*
|
||||||
* TerminateProcess and GetCurrentProcess are defined in <winbase.h>, which
|
* TerminateProcess and GetCurrentProcess are defined in <winbase.h>, which
|
||||||
* further depends on <windef.h>. We hardcode these few definitions manually
|
* further depends on <windef.h>. We hardcode these few definitions manually
|
||||||
|
@ -192,6 +192,9 @@ MOZ_ReportCrash(const char* aStr, const char* aFilename, int aLine)
|
||||||
* Breakpad without requiring system library symbols on all stack-processing
|
* Breakpad without requiring system library symbols on all stack-processing
|
||||||
* machines, as a nested breakpoint would require.
|
* machines, as a nested breakpoint would require.
|
||||||
*
|
*
|
||||||
|
* We use __LINE__ to prevent the compiler from folding multiple crash sites
|
||||||
|
* together, which would make crash reports hard to understand.
|
||||||
|
*
|
||||||
* We use TerminateProcess with the exit code aborting would generate
|
* We use TerminateProcess with the exit code aborting would generate
|
||||||
* because we don't want to invoke atexit handlers, destructors, library
|
* because we don't want to invoke atexit handlers, destructors, library
|
||||||
* unload handlers, and so on when our process might be in a compromised
|
* unload handlers, and so on when our process might be in a compromised
|
||||||
|
@ -200,34 +203,22 @@ MOZ_ReportCrash(const char* aStr, const char* aFilename, int aLine)
|
||||||
* We don't use abort() because it'd cause Windows to annoyingly pop up the
|
* We don't use abort() because it'd cause Windows to annoyingly pop up the
|
||||||
* process error dialog multiple times. See bug 345118 and bug 426163.
|
* process error dialog multiple times. See bug 345118 and bug 426163.
|
||||||
*
|
*
|
||||||
* We follow TerminateProcess() with a call to MOZ_NoReturn() so that the
|
|
||||||
* compiler doesn't hassle us to provide a return statement after a
|
|
||||||
* MOZ_REALLY_CRASH() call.
|
|
||||||
*
|
|
||||||
* (Technically these are Windows requirements, not MSVC requirements. But
|
* (Technically these are Windows requirements, not MSVC requirements. But
|
||||||
* practically you need MSVC for debugging, and we only ship builds created
|
* practically you need MSVC for debugging, and we only ship builds created
|
||||||
* by MSVC, so doing it this way reduces complexity.)
|
* by MSVC, so doing it this way reduces complexity.)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
__declspec(noreturn) __inline void MOZ_NoReturn() {}
|
static MOZ_COLD MOZ_NORETURN MOZ_NEVER_INLINE void MOZ_NoReturn(int aLine)
|
||||||
|
{
|
||||||
|
*((volatile int*) NULL) = aLine;
|
||||||
|
TerminateProcess(GetCurrentProcess(), 3);
|
||||||
|
}
|
||||||
|
|
||||||
# ifdef __cplusplus
|
# define MOZ_REALLY_CRASH() \
|
||||||
# define MOZ_REALLY_CRASH() \
|
do { \
|
||||||
do { \
|
__debugbreak(); \
|
||||||
::__debugbreak(); \
|
MOZ_NoReturn(__LINE__); \
|
||||||
*((volatile int*) NULL) = __LINE__; \
|
} while (0)
|
||||||
::TerminateProcess(::GetCurrentProcess(), 3); \
|
|
||||||
::MOZ_NoReturn(); \
|
|
||||||
} while (0)
|
|
||||||
# else
|
|
||||||
# define MOZ_REALLY_CRASH() \
|
|
||||||
do { \
|
|
||||||
__debugbreak(); \
|
|
||||||
*((volatile int*) NULL) = __LINE__; \
|
|
||||||
TerminateProcess(GetCurrentProcess(), 3); \
|
|
||||||
MOZ_NoReturn(); \
|
|
||||||
} while (0)
|
|
||||||
# endif
|
|
||||||
#else
|
#else
|
||||||
# ifdef __cplusplus
|
# ifdef __cplusplus
|
||||||
# define MOZ_REALLY_CRASH() \
|
# define MOZ_REALLY_CRASH() \
|
||||||
|
|
Загрузка…
Ссылка в новой задаче