0

I have this simple main causing a crash on macos and I am trying to explore its minidump using the breakpad project:

#include <client/mac/handler/exception_handler.h>

// A callback function to run after the minidump has been written.
bool MyMinidumpCallBack(const char* dump_dir, const char* minidump_id,void* context, bool succeeded)
{
    return succeeded;
}
void trigger_crash() { volatile int* a = (int*)(NULL); *a = 1; }
int main(int argc, const char * argv[]) {

    const char* dump_path = "/Users/v-tober/minidump";
    bool always_trigger = true;
    const char* out_of_process_generation = NULL;
    google_breakpad::ExceptionHandler handler = google_breakpad::ExceptionHandler(
                                                                    dump_path, MyFilterCallback, MyMinidumpCallBack, NULL, always_trigger, out_of_process_generation);
    trigger_crash();
    
    return 0;
}

I build the executable inside xcode and generate the .sym file from its build folder:

debug:

  • ./dump_syms -a arm64 CrashTest > CrashTest.sym

release with dsym file:

  • ./dump_syms -a arm64 -g CrashTest.dSYM CrashTest > CrashTest.sym

The debug version has more content:

MODULE mac arm64 AB8E7B6C1C143E8C9406C402F7F1405A0 CrashTest
FUNC 2e7c 18 0 MyFilterCallback(void*)
FUNC 2e94 88 0 MyMinidumpCallBack(char const*, char const*, void*, bool)
FUNC 2f1c 48 0 std::__1::basic_ostream<char, std::__1::char_traits<char>>& std::__1::operator<<<std::__1::char_traits<char>>(std::__1::basic_ostream<char, std::__1::char_traits<char>>&, char const*)
FUNC 2f64 2c 0 std::__1::basic_ostream<char, std::__1::char_traits<char>>::operator<<[abi:v15006](std::__1::basic_ostream<char, std::__1::char_traits<char>>& (*)(std::__1::basic_ostream<char, std::__1::char_traits<char>>&))
FUNC 2f90 58 0 std::__1::basic_ostream<char, std::__1::char_traits<char>>& std::__1::endl<char, std::__1::char_traits<char>>(std::__1::basic_ostream<char, std::__1::char_traits<char>>&)
FUNC 2fe8 1c 0 trigger_crash()
FUNC 3004 134 0 _main
FUNC 3138 34 0 std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>::basic_string[abi:v15006]<std::nullptr_t>(char const*)

the release version has a lot of LINE section:

FILE 0 /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.3.sdk/usr/include/c++/v1/__algorithm/copy.h
FILE 1 /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.3.sdk/usr/include/c++/v1/__algorithm/fill_n.h
FILE 2 /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.3.sdk/usr/include/c++/v1/__iterator/ostreambuf_iterator.h
.............
FILE 8 /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.3.sdk/usr/include/c++/v1/ostream
FILE 9 /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.3.sdk/usr/include/c++/v1/stdexcept
FILE 10 /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.3.sdk/usr/include/c++/v1/streambuf
FILE 11 /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.3.sdk/usr/include/c++/v1/string
FILE 12 /Users/v-tober/Proto/test/thread/CrashTest/CrashTest/main.cpp
FUNC 3654 8 0 MyFilterCallback(void*)
3654 8 21 12
FUNC 365c 168 0 MyMinidumpCallBack(char const*, char const*, void*, bool)
365c 20 28 12
367c 1c 902 8
...............
378c 8 1040 8
3794 18 31 12
37ac 18 0 12
FUNC 37c4 10 0 trigger_crash()
37c4 8 36 12
37cc 4 36 12
37d0 4 36 12
FUNC 37d4 f0 0 main

Both define the trigger_crash function. When I run minidump_stackwalk on the generated .dmp file, the release version is missing the trigger_crash() identifier and got replace by !main

debug stackwalk:

    Thread 0 (crashed)
 0  CrashTest!trigger_crash() + 0x10
     x0 = 0x00000001f59d3c58    x1 = 0x0000000000000000
     x2 = 0x000000000000000e    x3 = 0x00000001f59d0eb0
     x4 = 0x00000001f59d3c60    x5 = 0x0000000000000020
     ....
    x26 = 0x0000000000000000   x27 = 0x0000000000000000
    x28 = 0x0000000000000000    fp = 0x000000016fdff310
     lr = 0x00000001000030b4    sp = 0x000000016fdff180
     pc = 0x0000000100002ff8
    Found by: given as instruction pointer in context
 1  CrashTest!_main + 0xac
     fp = 0x000000016fdff580    lr = 0x000000019a203f28
     sp = 0x000000016fdff320    pc = 0x00000001000030b4
    Found by: previous frame's frame pointer
 2  0x19a203f24
     fp = 0x0000000000000000    lr = 0x3879800000000000
     sp = 0x000000016fdff590    pc = 0x000000019a203f28
    Found by: previous frame's frame pointer

release stackwalk:

0  CrashTest!main [main.cpp : 36 + 0x0]
     x0 = 0x00000001f59d3c58    x1 = 0x0000000000000000
     x2 = 0x000000000000000e    x3 = 0x00000001f59d0eb0
     x4 = 0x00000001f59d3c60    x5 = 0x0000000000000020
     ...
    x26 = 0x0000000000000000   x27 = 0x0000000000000000
    x28 = 0x0000000000000000    fp = 0x000000016fdff310
     lr = 0x0000000100003854    sp = 0x000000016fdff1e0
     pc = 0x000000010000385c
    Found by: given as instruction pointer in context
 1  CrashTest!main [ostream : 902 + 0x14]
     fp = 0x000000016fdff580    lr = 0x000000019a203f28
     sp = 0x000000016fdff320    pc = 0x0000000100003854
    Found by: previous frame's frame pointer
 2  0x19a203f24
     fp = 0x0000000000000000    lr = 0x9b63800000000000
     sp = 0x000000016fdff590    pc = 0x000000019a203f28
    Found by: previous frame's frame pointer

I don't know what causes this issue, I tried to check all build setting options related to strip symbols and enabling debug information but it doesn't change a thing. The Release version was generated using the DWARF with dSYM File. The process was running through Xcode, do you think it can be responsible for the issue?

Paltoquet
  • 1,184
  • 1
  • 10
  • 18

1 Answers1

0

I guess the function got inlined I added an other indirection and I got and the worker method appeared in the call stack.

#include <client/mac/handler/exception_handler.h>

// A callback function to run after the minidump has been written.
bool MyMinidumpCallBack(const char* dump_dir, const char* minidump_id,void* context, bool succeeded)
{
    return succeeded;
}
void trigger_crash() { volatile int* a = (int*)(NULL); *a = 1; }

void worker()
{
    volatile int cmp = 0;
    for(int i = 0; i < count; i++)
    {
        cmp += 2;
    }
    trigger_crash();
}


int main(int argc, const char * argv[]) {

const char* dump_path = "/Users/v-tober/minidump";
bool always_trigger = true;
const char* out_of_process_generation = NULL;
google_breakpad::ExceptionHandler handler = google_breakpad::ExceptionHandler(
                                                                dump_path, MyFilterCallback, MyMinidumpCallBack, NULL, always_trigger, out_of_process_generation);
worker();

return 0;
}
Paltoquet
  • 1,184
  • 1
  • 10
  • 18