Forum Xamarin Xamarin.Mac

How to analyze hang reports and spindumps?

ovi_ovi_ Member ✭✭

Hello everyone. Now i am trying to analyze hang reports. I created simple cocoa application with single button on it. Also add callback method and next code to get UI freeze:

    void Method1()
        {
            // thread 1
            lock (obj1)
            {
                Thread.Sleep(1000);
                lock (obj2)
                {
                    Console.WriteLine("Thread 1 got both locks");
                }
            }
        }

        void Method2()
        {
            // thread 2
            lock (obj2)
            {
                Thread.Sleep(1000);
                InvokeOnMainThread(() =>
                {
                    lock (obj1)
                    {
                        Console.WriteLine("Thread 2 got both locks");
                    }
                });
            }
        }

        partial void Makehang(NSObject sender)
        {
            Task.Run(Method1);
            Task.Run(Method2);
        }

In hang time i collected next spindump:

----------------------------------------
Heavy format: stacks are sorted by count
----------------------------------------



Process:          test [61136]
UUID:             65C806A8-19DF-3DAE-B36E-0995FD72BAD0
Path:             /Users/max/git/testCocoaApp/testCocoaApp/bin/Debug/test.app/Contents/MacOS/test
Architecture:     x86_64
Parent:           launchd [1]
UID:              501
Footprint:        29.35 MB
Start time:       2020-02-26 19:12:56 +0300
End time:         2020-02-26 19:13:06 +0300
Num samples:      1000 (1-1000)
CPU Time:         <0.001s (1556.5K cycles, 361.2K instructions, 4.31c/i)
Note:             Unresponsive for 26 seconds before sampling
Note:             2 idle work queue threads omitted

  Thread 0x989c5    DispatchQueue "com.apple.main-thread"(1)    Thread name "tid_307"    1000 samples (1-1000)    priority 46 (base 46)
  1000  start + 1 (libdyld.dylib + 108541) [0x7fff68ced7fd]
    1000  main + 36 (launcher.m:679,9 in test + 251796) [0x1061bc794]
      1000  xamarin_main + 1144 (launcher.m:661,9 in test + 248120) [0x1061bb938]
        1000  mono_main + 8499 (driver.c:1398,3 in test + 553123) [0x1062060a3]
          1000  mono_jit_exec + 370 (driver.c:1321,13 in test + 540722) [0x106203032]
            1000  mono_runtime_exec_main_checked + 108 (object.c in test + 2529196) [0x1063e87ac]
              1000  mono_runtime_invoke_checked + 135 (object.c:3017,11 in test + 2499479) [0x1063e1397]
                1000  mono_jit_runtime_invoke + 1571 (mini-runtime.c:3184,12 in test + 1207363) [0x1062a5c43]
                  1000  ??? [0x10c555c13]
                    1000  ??? [0x10c555df5]
                      1000  NSApplicationMain + 777 (AppKit + 13413) [0x7fff2e7d0465]
                        1000  -[NSApplication run] + 658 (AppKit + 200862) [0x7fff2e7fe09e]
                          1000  -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 1352 (AppKit + 258944) [0x7fff2e80c380]
                            1000  _DPSNextEvent + 990 (AppKit + 265124) [0x7fff2e80dba4]
                              1000  _BlockUntilNextEventMatchingListInModeWithFilter + 64 (HIToolbox + 192807) [0x7fff3019d127]
                                1000  ReceiveNextEventCommon + 600 (HIToolbox + 193437) [0x7fff3019d39d]
                                  1000  RunCurrentEventLoopInMode + 292 (HIToolbox + 194141) [0x7fff3019d65d]
                                    1000  CFRunLoopRunSpecific + 499 (CoreFoundation + 535507) [0x7fff31647bd3]
                                      1000  __CFRunLoopRun + 1272 (CoreFoundation + 538432) [0x7fff31648740]
                                        1000  __CFRunLoopDoSources0 + 209 (CoreFoundation + 542932) [0x7fff316498d4]
                                          1000  __CFRunLoopDoSource0 + 103 (CoreFoundation + 543424) [0x7fff31649ac0]
                                            1000  __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17 (CoreFoundation + 543521) [0x7fff31649b21]
                                              1000  __NSThreadPerformPerform + 254 (Foundation + 641195) [0x7fff33d268ab]
                                                1000  -[__MonoMac_NSActionDispatcher xamarinApplySelector] + 52 (Xamarin.Mac.registrar.full.x86_64.m:44457,3 in test + 4236244) [0x1065893d4]
                                                  1000  native_to_managed_trampoline_43(objc_object*, objc_selector*, _MonoMethod**, unsigned int) + 237 (Xamarin.Mac.registrar.full.x86_64.m:1820,2 in test + 4235885) [0x10658926d]
                                                    1000  mono_runtime_invoke + 158 (object.c:3072,9 in test + 2518254) [0x1063e5cee]
                                                      1000  mono_runtime_invoke_checked + 135 (object.c:3017,11 in test + 2499479) [0x1063e1397]
                                                        1000  mono_jit_runtime_invoke + 1571 (mini-runtime.c:3184,12 in test + 1207363) [0x1062a5c43]
                                                          1000  ??? [0x10f65ceaa]
                                                            1000  ??? [0x10f65c95e]
                                                              1000  mono_monitor_enter_v4_internal + 93 (monitor.c:1174,9 in test + 2442509) [0x1063d350d]
                                                                1000  mono_monitor_try_enter_inflated + 828 (mono-os-mutex.h:177,8 in test + 2444444) [0x1063d3c9c]
                                                                  1000  __psynch_cvwait + 10 (libsystem_kernel.dylib + 15590) [0x7fff68e30ce6]
                                                                   *1000  psynch_cvcontinue + 0 (pthread + 19403) [0xffffff7f82cb5bcb]

  Thread 0x989d9    Thread name "SGen worker"    1000 samples (1-1000)    priority 31 (base 31)
  1000  thread_start + 15 (libsystem_pthread.dylib + 6203) [0x7fff68eed83b]
    1000  _pthread_start + 148 (libsystem_pthread.dylib + 24165) [0x7fff68ef1e65]
      1000  thread_func + 449 (mono-os-mutex.h:177,8 in test + 3337537) [0x1064add41]
        1000  __psynch_cvwait + 10 (libsystem_kernel.dylib + 15590) [0x7fff68e30ce6]
         *1000  psynch_cvcontinue + 0 (pthread + 19403) [0xffffff7f82cb5bcb]

  Thread 0x989de    Thread name "Finalizer"    1000 samples (1-1000)    priority 31 (base 31)    cpu time <0.001s (151.1K cycles, 60.3K instructions, 2.50c/i)
  1000  thread_start + 15 (libsystem_pthread.dylib + 6203) [0x7fff68eed83b]
    1000  _pthread_start + 148 (libsystem_pthread.dylib + 24165) [0x7fff68ef1e65]
      1000  start_wrapper + 71 (threads.c:1294,8 in test + 2868215) [0x10643b3f7]
        1000  start_wrapper_internal + 374 (threads.c:1221,3 in test + 2868630) [0x10643b596]
          1000  semaphore_wait_trap + 10 (libsystem_kernel.dylib + 4758) [0x7fff68e2e296]
           *1000  semaphore_wait_continue + 0 (kernel + 1474976) [0xffffff80003681a0]

  Thread 0x989ec    Thread name "com.apple.NSEventThread"    1000 samples (1-1000)    priority 46 (base 46)
  1000  thread_start + 15 (libsystem_pthread.dylib + 6203) [0x7fff68eed83b]
    1000  _pthread_start + 148 (libsystem_pthread.dylib + 24165) [0x7fff68ef1e65]
      1000  _NSEventThread + 132 (AppKit + 1980306) [0x7fff2e9b0792]
        1000  CFRunLoopRunSpecific + 499 (CoreFoundation + 535507) [0x7fff31647bd3]
          1000  __CFRunLoopRun + 1695 (CoreFoundation + 538855) [0x7fff316488e7]
            1000  __CFRunLoopServiceMachPort + 322 (CoreFoundation + 544011) [0x7fff31649d0b]
              1000  mach_msg_trap + 10 (libsystem_kernel.dylib + 4698) [0x7fff68e2e25a]
               *1000  ipc_mqueue_receive_continue + 0 (kernel + 1169792) [0xffffff800031d980]

  Thread 0x989f8    Thread name "tid_12a03"    1000 samples (1-1000)    priority 31 (base 31)    cpu time <0.001s (763.1K cycles, 97.0K instructions, 7.87c/i)
  1000  thread_start + 15 (libsystem_pthread.dylib + 6203) [0x7fff68eed83b]
    1000  _pthread_start + 148 (libsystem_pthread.dylib + 24165) [0x7fff68ef1e65]
      1000  start_wrapper + 71 (threads.c:1294,8 in test + 2868215) [0x10643b3f7]
        1000  start_wrapper_internal + 374 (threads.c:1221,3 in test + 2868630) [0x10643b596]
          1000  monitor_thread + 771 (threadpool-worker-default.c:708,8 in test + 2817203) [0x10642ecb3]
            1000  mono_thread_info_sleep + 617 (mono-threads.c:1623 in test + 3467209) [0x1064cd7c9]
              1000  mono_os_cond_timedwait + 81 (mono-os-mutex.c:44,8 in test + 3417857) [0x1064c1701]
                1000  __psynch_cvwait + 10 (libsystem_kernel.dylib + 15590) [0x7fff68e30ce6]
                 *1000  psynch_cvcontinue + 0 (pthread + 19403) [0xffffff7f82cb5bcb]

  Thread 0x989f9    Thread name "Thread Pool Worker"    1000 samples (1-1000)    priority 31 (base 31)
  1000  ??? [0x700008571000]
    1000  ??? [0x10dd83a33]
      1000  xamarin_dyn_objc_msgSend + 217 (test + 246025) [0x1061bb109]
        1000  -[NSObject(NSThreadPerformAdditions) performSelectorOnMainThread:withObject:waitUntilDone:] + 124 (Foundation + 323002) [0x7fff33cd8dba]
          1000  -[NSObject(NSThreadPerformAdditions) performSelector:onThread:withObject:waitUntilDone:modes:] + 836 (Foundation + 324199) [0x7fff33cd9267]
            1000  __psynch_cvwait + 10 (libsystem_kernel.dylib + 15590) [0x7fff68e30ce6]
             *1000  psynch_cvcontinue + 0 (pthread + 19403) [0xffffff7f82cb5bcb]

  Thread 0x989fa    Thread name "Thread Pool Worker"    1000 samples (1-1000)    priority 31 (base 31)
  1000  thread_start + 15 (libsystem_pthread.dylib + 6203) [0x7fff68eed83b]
    1000  _pthread_start + 148 (libsystem_pthread.dylib + 24165) [0x7fff68ef1e65]
      1000  start_wrapper + 71 (threads.c:1294,8 in test + 2868215) [0x10643b3f7]
        1000  start_wrapper_internal + 374 (threads.c:1221,3 in test + 2868630) [0x10643b596]
          1000  worker_thread + 364 (threadpool-worker-default.c:500,3 in test + 2818268) [0x10642f0dc]
            1000  worker_callback + 1074 (threadpool.c:368 in test + 2827378) [0x106431472]
              1000  mono_runtime_try_invoke + 158 (object.c:3017,11 in test + 2506190) [0x1063e2dce]
                1000  mono_jit_runtime_invoke + 1571 (mini-runtime.c:3184,12 in test + 1207363) [0x1062a5c43]
                  1000  ??? [0x10dd824fb]
                    1000  ??? [0x10f65b023]
                      1000  ??? [0x10f65bacb]
                        1000  ??? [0x10f65c0a3]
                          1000  ??? [0x10f65c219]
                            1000  ??? [0x10f65c95e]
                              1000  mono_monitor_enter_v4_internal + 93 (monitor.c:1174,9 in test + 2442509) [0x1063d350d]
                                1000  mono_monitor_try_enter_inflated + 828 (mono-os-mutex.h:177,8 in test + 2444444) [0x1063d3c9c]
                                  1000  __psynch_cvwait + 10 (libsystem_kernel.dylib + 15590) [0x7fff68e30ce6]
                                   *1000  psynch_cvcontinue + 0 (pthread + 19403) [0xffffff7f82cb5bcb]

  Thread 0x989ff    Thread name "Thread Pool Worker"    1000 samples (1-1000)    priority 31 (base 31)
  1000  thread_start + 15 (libsystem_pthread.dylib + 6203) [0x7fff68eed83b]
    1000  _pthread_start + 148 (libsystem_pthread.dylib + 24165) [0x7fff68ef1e65]
      1000  start_wrapper + 71 (threads.c:1294,8 in test + 2868215) [0x10643b3f7]
        1000  start_wrapper_internal + 374 (threads.c:1221,3 in test + 2868630) [0x10643b596]
          1000  semaphore_timedwait_trap + 10 (libsystem_kernel.dylib + 4782) [0x7fff68e2e2ae]
           *1000  semaphore_wait_continue + 0 (kernel + 1474976) [0xffffff80003681a0]

  Thread 0x989fe    Thread name "Thread Pool Worker"    573 samples (1-573)    priority 31 (base 31)
  573  thread_start + 15 (libsystem_pthread.dylib + 6203) [0x7fff68eed83b]
    573  _pthread_start + 148 (libsystem_pthread.dylib + 24165) [0x7fff68ef1e65]
      573  start_wrapper + 71 (threads.c:1294,8 in test + 2868215) [0x10643b3f7]
        573  start_wrapper_internal + 374 (threads.c:1221,3 in test + 2868630) [0x10643b596]
          573  semaphore_timedwait_trap + 10 (libsystem_kernel.dylib + 4782) [0x7fff68e2e2ae]
           *573  semaphore_wait_continue + 0 (kernel + 1474976) [0xffffff80003681a0]

  Binary Images:
           0x10617f000 -        0x10675cfff  com.companyname.test 1.0 (1)            <65C806A8-19DF-3DAE-B36E-0995FD72BAD0>  /Users/max/git/testCocoaApp/testCocoaApp/bin/Debug/test.app/Contents/MacOS/test
        0x7fff2e7cd000 -     0x7fff2f588fff  com.apple.AppKit 6.9 (1894.30.142)      <5A1752C0-67F4-3EDF-97DA-81AB42824B7B>  /System/Library/Frameworks/AppKit.framework/Versions/C/AppKit
        0x7fff3016e000 -     0x7fff30462fff  com.apple.HIToolbox 2.1.1 (994)         <03BF3899-5DD5-3C1F-9DC6-B4C71CD656B6>  /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/HIToolbox.framework/Versions/A/HIToolbox
        0x7fff315c5000 -     0x7fff31a45fff  com.apple.CoreFoundation 6.9 (1674.114) <5810CC45-FB5D-3A78-861F-7BE03F9B2FDD>  /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation
        0x7fff33c8a000 -     0x7fff34052fff  com.apple.Foundation 6.9 (1674.114)     <532BBAE7-F2BA-3779-94E0-BFEDF2D7AB38>  /System/Library/Frameworks/Foundation.framework/Versions/C/Foundation
        0x7fff68cd3000 -     0x7fff68d08fff  libdyld.dylib (733.8)                   <8B0DFE8A-42CF-32C8-B121-83C22BF25F69>  /usr/lib/system/libdyld.dylib
        0x7fff68e2d000 -     0x7fff68e59fff  libsystem_kernel.dylib (6153.81.5)      <23909F45-79C3-34C9-A28F-337915925E5E>  /usr/lib/system/libsystem_kernel.dylib
        0x7fff68eec000 -     0x7fff68ef6fff  libsystem_pthread.dylib (416.60.2)      <AAF506F4-9455-3CC4-8E0B-6791E3C0993C>  /usr/lib/system/libsystem_pthread.dylib
   *0xffffff7f82cb1000 - 0xffffff7f82cb8fff  com.apple.kec.pthread 1.0 (1)           <A897FB4B-D1A2-39CF-9485-375DED353852>  /System/Library/Extensions/pthread.kext/Contents/MacOS/pthread
   *0xffffff8000200000 - 0xffffff8000bfffff  kernel (6153.81.5)                      <A8DDE75C-CD97-3C37-B35D-1070CC50D2CE>  /System/Library/Kernels/kernel

Then I've tried to get my function name by symbolicating with atos tool, but couldn't. Can anyone help me? Can i get more detail info from hang reports or no? May be there is another solution to analyze application freezes on mac?

Will be happy for any help. Thanks in advance.

Best Answer

Answers

Sign In or Register to comment.