зеркало из https://github.com/mozilla/gecko-dev.git
Bug 644707 - Avoid calling system abort(), generate useful stack traces through a manual segfault instead. r=ted
This commit is contained in:
Родитель
7855e8f09c
Коммит
03ee59ca0a
|
@ -47,6 +47,7 @@
|
|||
# include <windows.h> // for DebugBreak
|
||||
#elif defined(XP_UNIX)
|
||||
# include <unistd.h> // for _exit
|
||||
# include <signal.h>
|
||||
#endif
|
||||
|
||||
#if defined(XP_WIN) || defined(XP_OS2)
|
||||
|
@ -72,19 +73,39 @@ mozalloc_abort(const char* const msg)
|
|||
fputs(msg, stderr);
|
||||
fputs("\n", stderr);
|
||||
|
||||
#if defined(XP_UNIX) && !defined(XP_MACOSX)
|
||||
abort();
|
||||
#elif defined(_MSC_VER)
|
||||
#if defined(_MSC_VER)
|
||||
__debugbreak();
|
||||
#elif defined(XP_WIN)
|
||||
DebugBreak();
|
||||
#endif
|
||||
// abort() doesn't trigger breakpad on Mac, "fall through" to the
|
||||
// fail-safe code
|
||||
|
||||
// Still haven't aborted? Try dereferencing null.
|
||||
// On *NIX platforms the prefered way to abort is by touching bad memory,
|
||||
// since this generates a stack trace inside our own code (avoiding
|
||||
// problems with starting the trace inside libc, where we might not have
|
||||
// symbols and can get lost).
|
||||
|
||||
TouchBadMemory();
|
||||
|
||||
// If we haven't aborted yet, we can try to raise SIGABRT which might work
|
||||
// on some *NIXs, but not OS X (it doesn't trigger breakpad there).
|
||||
// Note that we don't call abort(), since raise is likelier to give us
|
||||
// useful stack data, and also since abort() is redirected to call this
|
||||
// function (see below).
|
||||
#if defined(XP_UNIX) && !defined(XP_MACOSX)
|
||||
raise(SIGABRT);
|
||||
#endif
|
||||
|
||||
// Still haven't aborted? Try _exit().
|
||||
_exit(127);
|
||||
}
|
||||
|
||||
#if defined(XP_UNIX)
|
||||
// Define abort() here, so that it is used instead of the system abort(). This
|
||||
// lets us control the behavior when aborting, in order to get better results
|
||||
// on *NIX platfrorms. See mozalloc_abort for details.
|
||||
void abort(void)
|
||||
{
|
||||
mozalloc_abort("Redirecting call to abort() to mozalloc_abort\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче