This patch is a proposed solution for https://code.google.com/p/address-sanitizer/issues/detail?id=375:
When the stacktraces are captured and printed by ASan itself, they are fine, but when the program has already printed the report (or is just printing it), capturing a stacktrace via other means is broken. "Other means" include OS X CrashReporter, debuggers or calling backtrace() within the program. For example calling backtrace() from a sanitizer_set_death_callback function prints a very truncated stacktrace:
0 crashlog-stacktraces.c.tmp 0x000000010fb1c397 death_function + 471 1 libclang_rt.asan_osx_dynamic.dylib 0x000000010fb72c1f _ZN11__sanitizer3DieEv + 15
The same can happen even within lldb (I'm seeing this for 32-bit x86):
(lldb) bt * thread #1: tid = 0x9ec2d, 0x0000209a crashlog-stacktraces.c.tmp`death_function + 42 at crashlog-stacktraces.c:10, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1 * frame #0: 0x0000209a crashlog-stacktraces.c.tmp`death_function + 42 at crashlog-stacktraces.c:10 frame #1: 0x0005eaf6 libclang_rt.asan_osx_dynamic.dylib`__sanitizer::Die() + 22 frame #2: 0x00058136 libclang_rt.asan_osx_dynamic.dylib`__asan::ScopedInErrorReport::~ScopedInErrorReport() + 102 frame #3: 0x00057fcf libclang_rt.asan_osx_dynamic.dylib`__asan::ScopedInErrorReport::~ScopedInErrorReport() + 15 frame #4: 0x00057acc libclang_rt.asan_osx_dynamic.dylib`__asan_report_error + 4204 (lldb)
This patch forces __asan_report_error to always have a stack frame by using the ENABLE_FRAME_POINTER macro, which we are already using elsewhere (asan_mac.cc).