Skip to content
Permalink
Browse files
Changed WTFCrash to not trash the crash site register state.
https://bugs.webkit.org/show_bug.cgi?id=153996

Reviewed by Geoffrey Garen.

When doing post-mortem crash site analysis using data from crash reports, it is
immensely valuable to be able to infer the crashing program's state from the
register values at crash time.  However, for RELEASE_ASSERT failures, we crash
using WTFCrash(), and WTFCrash() is currently implemented as a function call
that, in turn, calls a lot of other functions to do crash handling before
actually crashing.  As a result, the register values captured in the crash
reports are not likely to still contain the values used by the caller function
that failed the RELEASE_ASSERT.

This patch aims to remedy this issue for non-debug builds on OS(DARWIN) ports.
It does so by changing WTFCrash() into an inlined function that has an inlined
asm statement to issues the CPU specific breakpoint trap instruction.  As a
result, for non-debug OS(DARWIN) builds, crashes due to failed RELEASE_ASSERTs
will now show up in crash reports as crashing due to EXC_BREAKPOINT (SIGTRAP)
instead of a EXC_BAD_ACCESS (SIGSEGV) on address 0xbbadbeef.

For debug and non-DARWIN builds, WTFCrash() behavior currently remains unchanged.

* wtf/Assertions.cpp:
* wtf/Assertions.h:



Canonical link: https://commits.webkit.org/172198@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@196397 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
Mark Lam committed Feb 10, 2016
1 parent 0127c13 commit 07d2bb0366d09ad77a5d8af1160d3586374c8f0d
Showing with 51 additions and 1 deletion.
  1. +28 −0 Source/WTF/ChangeLog
  2. +2 −0 Source/WTF/wtf/Assertions.cpp
  3. +21 −1 Source/WTF/wtf/Assertions.h
@@ -1,3 +1,31 @@
2016-02-09 Mark Lam <mark.lam@apple.com>

Changed WTFCrash to not trash the crash site register state.
https://bugs.webkit.org/show_bug.cgi?id=153996

Reviewed by Geoffrey Garen.

When doing post-mortem crash site analysis using data from crash reports, it is
immensely valuable to be able to infer the crashing program's state from the
register values at crash time. However, for RELEASE_ASSERT failures, we crash
using WTFCrash(), and WTFCrash() is currently implemented as a function call
that, in turn, calls a lot of other functions to do crash handling before
actually crashing. As a result, the register values captured in the crash
reports are not likely to still contain the values used by the caller function
that failed the RELEASE_ASSERT.

This patch aims to remedy this issue for non-debug builds on OS(DARWIN) ports.
It does so by changing WTFCrash() into an inlined function that has an inlined
asm statement to issues the CPU specific breakpoint trap instruction. As a
result, for non-debug OS(DARWIN) builds, crashes due to failed RELEASE_ASSERTs
will now show up in crash reports as crashing due to EXC_BREAKPOINT (SIGTRAP)
instead of a EXC_BAD_ACCESS (SIGSEGV) on address 0xbbadbeef.

For debug and non-DARWIN builds, WTFCrash() behavior currently remains unchanged.

* wtf/Assertions.cpp:
* wtf/Assertions.h:

2016-02-09 Csaba Osztrogonác <ossy@webkit.org>

[GTK][EFL] Fix several build configuration related to SamplingProfiler after r196245
@@ -312,6 +312,7 @@ void WTFSetCrashHook(WTFCrashHookFunction function)
globalHook = function;
}

#if !defined(NDEBUG) || !OS(DARWIN)
void WTFCrash()
{
if (globalHook)
@@ -326,6 +327,7 @@ void WTFCrash()
((void(*)())0)();
#endif
}
#endif // !defined(NDEBUG) || !OS(DARWIN)

void WTFCrashWithSecurityImplication()
{
@@ -162,7 +162,27 @@ WTF_EXPORT_PRIVATE bool WTFIsDebuggerAttached();
#ifdef __cplusplus
extern "C" {
#endif
WTF_EXPORT_PRIVATE NO_RETURN_DUE_TO_CRASH void WTFCrash();
#if defined(NDEBUG) && OS(DARWIN)
ALWAYS_INLINE NO_RETURN_DUE_TO_CRASH void WTFCrash()
{
// Crash with a SIGTRAP i.e EXC_BREAKPOINT.
// We are not using __builtin_trap because it is only guaranteed to abort, but not necessarily
// trigger a SIGTRAP. Instead, we use inline asm to ensure that we trigger the SIGTRAP.
#if CPU(X86_64) || CPU(X86)
asm volatile ("int3");
#elif CPU(ARM_THUMB2)
asm volatile ("bkpt #0");
#elif CPU(ARM64)
asm volatile ("brk #0");
#else
#error "Unsupported CPU".
#endif
__builtin_unreachable();
}
#else
WTF_EXPORT_PRIVATE NO_RETURN_DUE_TO_CRASH void WTFCrash();
#endif

#ifdef __cplusplus
}
#endif

0 comments on commit 07d2bb0

Please sign in to comment.