MonoGame App Shows Crash Dialog On Exit

Hi,

Using MG 3.6 I’m getting crashlogs displayed when quitting my app, this has been reported by a number of users though it doesn’t appear to happen on every device.

Does anyone know of a workaround for this? I tried using the latest develop build to see if the issue persisted but I could get my game to run using that at all, divide by zero exceptions in MG audio loading code and (if I caught those) app just launching and quitting with no apparent error message at all.

Here’s some of the output from the 3.6 crashlog. I’m using Game.Exit() but have also tried System.Environment.Exit() and NSApplication.SharedApplication.Terminate (NSApplication.SharedApplication);

Process:               JetBoardJoust.MacOS [33985]
Path:                  /Volumes/VOLUME/*/JetBoardJoust.MacOS.app/Contents/MacOS/JetBoardJoust.MacOS
Identifier:            com.bitbull.jbj
Version:               0.0.2
Code Type:             X86-64 (Native)
Parent Process:        ??? [1]
Responsible:           JetBoardJoust.MacOS [33985]
User ID:               501

Date/Time:             2017-04-24 16:37:24.559 +0100
OS Version:            Mac OS X 10.11.1 (15B42)
Report Version:        11
Anonymous UUID:        BB06A84C-3419-1A91-6253-02F1C274F2EB

Sleep/Wake UUID:       8592ED5B-B5A0-4E54-8750-3143B147AD08

Time Awake Since Boot: 470000 seconds
Time Since Wake:       31000 seconds

System Integrity Protection: enabled

Crashed Thread:        0  tid_160b  Dispatch queue: com.apple.main-thread

Exception Type:        EXC_BAD_ACCESS (SIGSEGV)
Exception Codes:       KERN_INVALID_ADDRESS at 0x0000000000000000
Exception Note:        EXC_CORPSE_NOTIFY

VM Regions Near 0:
--> 
    __TEXT                 0000000100000000-00000001003b0000 [ 3776K] r-x/rwx SM=COW  /Volumes/VOLUME/*/JetBoardJoust.MacOS.app/Contents/MacOS/JetBoardJoust.MacOS

Thread 0 Crashed:: tid_160b  Dispatch queue: com.apple.main-thread
0   com.bitbull.jbj               	0x0000000100295cdd eglib_log_adapter + 13 (mono-logger.c:366)
1   com.bitbull.jbj               	0x00000001002abef3 monoeg_g_log + 211 (goutput.c:112)
2   com.bitbull.jbj               	0x0000000100279ca1 _wapi_handle_share_release + 177 (mono-os-mutex.h:98)
3   com.bitbull.jbj               	0x000000010027dc1d file_close + 77 (io.c:475)
4   com.bitbull.jbj               	0x00000001002a211f mono_w32handle_unref_full + 495 (w32handle.c:716)
5   com.bitbull.jbj               	0x00000001002a1e9d mono_w32handle_cleanup + 141 (w32handle.c:347)
6   com.bitbull.jbj               	0x0000000100182b35 ves_icall_System_Environment_Exit + 37 (icall.c:6776)
7   ???                           	0x000000011b3cb539 0 + 4751930681
8   ???                           	0x00000001051373e1 0 + 4380128225
9   com.bitbull.jbj               	0x00000001001217d7 mono_jit_runtime_invoke + 2247 (mini-runtime.c:2575)
10  com.bitbull.jbj               	0x00000001001df6b8 do_runtime_invoke + 88 (object.c:2820)
11  com.bitbull.jbj               	0x00000001001e2c10 do_exec_main_checked + 144 (object.c:4641)
12  com.bitbull.jbj               	0x000000010007af6a mono_jit_exec + 298 (driver.g.c:1049)
13  com.bitbull.jbj               	0x000000010007d47a mono_main + 8458 (driver.g.c:2172)
14  com.bitbull.jbj               	0x0000000100020664 xamarin_main + 980 (launcher.m:606)
15  com.bitbull.jbj               	0x0000000100021374 main + 36 (launcher.m:617)
16  com.bitbull.jbj               	0x0000000100001264 start + 52

Thread 1:
0   libsystem_kernel.dylib        	0x00007fff83e2278a __workq_kernreturn + 10
1   libsystem_pthread.dylib       	0x00007fff9026658c _pthread_wqthread + 1283
2   libsystem_pthread.dylib       	0x00007fff90264375 start_wqthread + 13

Thread 2:: Dispatch queue: com.apple.libdispatch-manager
0   libsystem_kernel.dylib        	0x00007fff83e230a2 kevent_qos + 10
1   libdispatch.dylib             	0x00007fff924b711d _dispatch_mgr_invoke + 216
2   libdispatch.dylib             	0x00007fff924b6d85 _dispatch_mgr_thread + 52

Thread 3:
0   libsystem_kernel.dylib        	0x00007fff83e2278a __workq_kernreturn + 10
1   libsystem_pthread.dylib       	0x00007fff9026658c _pthread_wqthread + 1283
2   libsystem_pthread.dylib       	0x00007fff90264375 start_wqthread + 13

Thread 4:
0   libsystem_kernel.dylib        	0x00007fff83e2278a __workq_kernreturn + 10
1   libsystem_pthread.dylib       	0x00007fff9026658c _pthread_wqthread + 1283
2   libsystem_pthread.dylib       	0x00007fff90264375 start_wqthread + 13

Thread 5:

Thread 6:: com.apple.audio.IOThread.client
0   libsystem_kernel.dylib        	0x00007fff83e1cc96 mach_msg_trap + 10
1   libsystem_kernel.dylib        	0x00007fff83e1c0d7 mach_msg + 55
2   com.apple.audio.CoreAudio     	0x00007fff987bc5ee HALB_MachPort::SendMessageWithReply(unsigned int, unsigned int, unsigned int, unsigned int, mach_msg_header_t*, bool, unsigned int) + 98
3   com.apple.audio.CoreAudio     	0x00007fff987bc57c HALB_MachPort::SendSimpleMessageWithSimpleReply(unsigned int, unsigned int, int, int&, bool, unsigned int) + 42
4   com.apple.audio.CoreAudio     	0x00007fff987ba939 HALC_ProxyIOContext::IOWorkLoop() + 1149
5   com.apple.audio.CoreAudio     	0x00007fff987ba3ee HALC_ProxyIOContext::IOThreadEntry(void*) + 88
6   com.apple.audio.CoreAudio     	0x00007fff987ba2c3 HALB_IOThread::Entry(void*) + 75
7   libsystem_pthread.dylib       	0x00007fff902669b1 _pthread_body + 131
8   libsystem_pthread.dylib       	0x00007fff9026692e _pthread_start + 168
9   libsystem_pthread.dylib       	0x00007fff90264385 thread_start + 13

Thread 7:: tid_1be03
0   libsystem_kernel.dylib        	0x00007fff83e1ccd2 semaphore_wait_trap + 10
1   com.bitbull.jbj               	0x000000010029d479 mono_thread_info_end_self_suspend + 73 (mono-os-semaphore.h:90)
2   com.bitbull.jbj               	0x000000010022ab64 mono_thread_execute_interruption + 324 (threads.c:4421)
3   com.bitbull.jbj               	0x000000010022a78f ves_icall_System_Threading_Thread_Sleep_internal + 159 (threads.c:1219)
4   ???                           	0x0000000111d33db9 0 + 4594023865
5   ???                           	0x0000000111d31e47 0 + 4594015815
6   ???                           	0x0000000111d31839 0 + 4594014265
7   com.bitbull.jbj               	0x00000001001217d7 mono_jit_runtime_invoke + 2247 (mini-runtime.c:2575)
8   com.bitbull.jbj               	0x00000001001df6b8 do_runtime_invoke + 88 (object.c:2820)
9   com.bitbull.jbj               	0x000000010023073b start_wrapper + 587 (threads.c:770)
10  com.bitbull.jbj               	0x000000010029e502 inner_start_thread + 354 (mono-threads.c:1183)
11  libsystem_pthread.dylib       	0x00007fff902669b1 _pthread_body + 131
12  libsystem_pthread.dylib       	0x00007fff9026692e _pthread_start + 168
13  libsystem_pthread.dylib       	0x00007fff90264385 thread_start + 13

Thread 8:: Timer-Scheduler
0   libsystem_kernel.dylib        	0x00007fff83e1ccd2 semaphore_wait_trap + 10
1   com.bitbull.jbj               	0x000000010029d479 mono_thread_info_end_self_suspend + 73 (mono-os-semaphore.h:90)
2   com.bitbull.jbj               	0x000000010022ab64 mono_thread_execute_interruption + 324 (threads.c:4421)
3   com.bitbull.jbj               	0x000000010022b8a4 mono_wait_uninterrupted + 180 (threads.c:1593)
4   com.bitbull.jbj               	0x000000010022bb5d ves_icall_System_Threading_WaitHandle_WaitOne_internal + 109 (threads.c:1722)
5   ???                           	0x000000011b1969df 0 + 4749617631
6   ???                           	0x000000011b1967cb 0 + 4749617099
7   ???                           	0x0000000111d31e47 0 + 4594015815
8   ???                           	0x0000000111d31839 0 + 4594014265
9   com.bitbull.jbj               	0x00000001001217d7 mono_jit_runtime_invoke + 2247 (mini-runtime.c:2575)
10  com.bitbull.jbj               	0x00000001001df6b8 do_runtime_invoke + 88 (object.c:2820)
11  com.bitbull.jbj               	0x000000010023073b start_wrapper + 587 (threads.c:770)
12  com.bitbull.jbj               	0x000000010029e502 inner_start_thread + 354 (mono-threads.c:1183)
13  libsystem_pthread.dylib       	0x00007fff902669b1 _pthread_body + 131
14  libsystem_pthread.dylib       	0x00007fff9026692e _pthread_start + 168
15  libsystem_pthread.dylib       	0x00007fff90264385 thread_start + 13

Thread 9:: com.apple.NSEventThread
0   libsystem_kernel.dylib        	0x00007fff83e1cc96 mach_msg_trap + 10
1   libsystem_kernel.dylib        	0x00007fff83e1c0d7 mach_msg + 55
2   com.apple.CoreFoundation      	0x00007fff906802b4 __CFRunLoopServiceMachPort + 212
3   com.apple.CoreFoundation      	0x00007fff9067f77c __CFRunLoopRun + 1356
4   com.apple.CoreFoundation      	0x00007fff9067efc8 CFRunLoopRunSpecific + 296
5   com.apple.AppKit              	0x00007fff83301d49 _NSEventThread + 149
6   libsystem_pthread.dylib       	0x00007fff902669b1 _pthread_body + 131
7   libsystem_pthread.dylib       	0x00007fff9026692e _pthread_start + 168
8   libsystem_pthread.dylib       	0x00007fff90264385 thread_start + 13

Thread 0 crashed with X86 Thread State (64-bit):
  rax: 0x0000000000000004  rbx: 0x0000000000000000  rcx: 0x0000000000000000  rdx: 0x00000001012009a0
  rdi: 0x0000000000000000  rsi: 0x0000000000000004  rbp: 0x00007fff5fbfecd0  rsp: 0x00007fff5fbfecd0
   r8: 0x0000000000000000   r9: 0x00000001002c8426  r10: 0x00007fff98e25501  r11: 0x00000001012009e9
  r12: 0x0000000000000000  r13: 0x00000000000005d8  r14: 0x0000000000000004  r15: 0x72008c4387450d06
  rip: 0x0000000100295cdd  rfl: 0x0000000000010202  cr2: 0x0000000000000000
  
Logical CPU:     6
Error Code:      0x00000004
Trap Number:     14

@BitBull, did you ever find a solution for this?
It looks like I’m seeing the same issue which I can’t find a solution for.
Did you found out anything that could help me?

I am still having issues with this. Still working on the same game too!

It’s not crashing currently but it’s just hanging with the spinning beach ball when I exit and I often have to force-quit. I haven’t looked into this for ages but will have to revisit when I finally get to the point of releasing something.

If you have any joy please post back - I think I’m still on MG 3.6. I try and avoid updating anything unless absolutely necessary.

I finally have something that seems to work for this. haven’t tested exhaustively but it seems to be quitting without error or the spinning beach ball. I think it’s the last line that’s the clincher…

	public override void QuitApp()
	{
        Game.Exit ();

        foreach (NSWindow window in NSApplication.SharedApplication.Windows )
        {
            window.Close();
        }
        System.Diagnostics.Process.GetCurrentProcess().Kill();
    }