How to symbolicate a Hang report for OS X apps?

2.9k views Asked by At

One of my apps (release version) was unresponsive, so I had to force-quit it.

OS X presented a Hang report (no crash report), which I copied to a *.crash file.

I'm aware of I can use services such as HockeyApp or atos directly to symbolicate Crash Reports, but how can I symbolicate Hang reports for OS X apps?

1

There are 1 answers

0
Raffael On BEST ANSWER

After some time, I found out how to handle the Hang reports, which are slightly different from normal crash reports. Here's what I did:

  1. In Xcode look up the corresponding archive of the app that crashed in the Organizer and reveal it in Finder (right-click).
  2. Right-click the archive and choose Show Package Contents.
  3. Copy the *.app from Products and the corresponding *.dSYM file from the dSYMs directory into a new folder, e.g., on your Desktop. You will have a MyApp.app and a MyApp.app.dSYM in the new folder. The naming of the files is important.
  4. ls into the new folder via the Terminal.

Now to use the atos tool ('convert numeric addresses to symbols of binary images or processes'), we need to first determine the load address of your app at runtime, and the address of the stack frame while the app was hanging.

  1. Open the Hang report, and find a line which says Binary Images: somewhere below the Heaviest stack for ... line. In my case this looks similar to:

    Binary Images:
         **0x107b0f000** -        0x108b59fff  com.company.MyApp 1.1.0 (2)  <6080DCE1-9086-311C-899F-CC22B32D694D>  /Applications/MyApp.app/Contents/MacOS/MyApp
          0x7fff89c7e000 -     0x7fff89c87fff  libsystem_pthread.dylib (105.10.1)  <3103AA7F-3BAE-3673-9649-47FFD7E15C97>  /usr/lib/system/libsystem_pthread.dylib
          0x7fff8b0bf000 -     0x7fff8bc06fff  com.apple.AppKit 6.9 (1344.36)      <D94A7D32-A789-37EA-A85C-BEFA7DE716E6>  /System/Library/Frameworks/AppKit.framework/Versions/C/AppKit
          0x7fff8bd6e000 -     0x7fff8c09cfff  com.apple.Foundation 6.9 (1152.12)  <C0EE9DA6-C111-358A-8874-DA175BB797D6>  /System/Library/Frameworks/Foundation.framework/Versions/C/Foundation
    

The address 0x107b0f000 surrounded by ** is our load-address, which you should copy.

  1. Next, we need to find the addresses we want to find symbol information for, that is, get the actual method signatures and the code lines, which led to the hang. Therefore, look up your app's name in the stack at the beginning of the Hang report, below 'Heaviest stack':

    Heaviest stack for the main thread of the target process:
      10  start + 1 (libdyld.dylib + 13769) [0x7fff91df35c9]
      10  NSApplicationMain + 1832 (AppKit + 10612) [0x7fff8b0c1974]
      10  -[NSApplication run] + 594 (AppKit + 95459) [0x7fff8b0d64e3]
      10  -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 194 (AppKit + 145072) [0x7fff8b0e26b0]
      10  _DPSNextEvent + 964 (AppKit + 147201) [0x7fff8b0e2f01]
      10  _BlockUntilNextEventMatchingListInModeWithFilter + 71 (HIToolbox + 190347) [0x7fff96ae378b]
      10  ReceiveNextEventCommon + 431 (HIToolbox + 190794) [0x7fff96ae394a]
      10  RunCurrentEventLoopInMode + 235 (HIToolbox + 191439) [0x7fff96ae3bcf]
      10  CFRunLoopRunSpecific + 296 (CoreFoundation + 464984) [0x7fff901f1858]
      10  __CFRunLoopRun + 927 (CoreFoundation + 466495) [0x7fff901f1e3f]
      10  __CFRunLoopDoSources0 + 269 (CoreFoundation + 469005) [0x7fff901f280d]
      10  __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17 (CoreFoundation + 525953) [0x7fff90200681]
      10  __NSThreadPerformPerform + 293 (Foundation + 416988) [0x7fff8bdd3cdc]
      10  ??? (MyApp + 62967) [0x108b1e5f7]
      8  ??? (MyApp + 48600) [0x108b1add8]
      8  -[IKImageBrowserView(ImageBrowserLayout) itemFrameAtIndex:] + 63 (ImageKit + 400983) [0x7fff91140e57]
    [...]
    

At the end of this example stack trace, you find MyApp listed twice. Copy both addresses, 0x108b1e5f7, 0x108b1add8, and close the report.

  1. Now we are ready to use atos. In the Terminal enter the following and press Return:

    atos -o MyApp.app/Contents/MacOS/MyApp -arch x86_64 -l 0x107b0f000 0x108b1e5f7  0x108b1add8
    
  2. atos will symbolicate the addressess using the *.dSYM file within the same directory and hopefully output something like:

    -[MainWindowController loadDidFinish:] (in MyApp) (MainWindowController.m:127)
    -[MainWindowController view:stringForToolTip:point:userData:] (in MyApp) (MainWindowController.m:231)
    

Yay, that looks promising! If atos outputs the same addresses you've put it, instead of code lines, something went wrong. The top source for errors here are probably wrong memory addresses, so make sure, you've chosen the right ones.

Let me know if you have further questions (@raffael_me).