Random crashing when loading audio from file at runtime

Hey folks!

Recently I’ve been experiencing a crash when trying to load in audio at runtime. It happens sporadically with no apparent cause. You can load audio fine for an hour, but then it’ll just randomly crash to desktop. This seems to affect both windows and Mac.

On Mac, the error ‘mono_os_sem_init: semaphore_create failed with error 268640044’.

On windows it gives the error ‘SymGetSymFromAddr64, GetLastError: ‘Attempt to access invalid address.’’.

This has been observed in Unity 2018.3.0f2 and 2018.3.14f1.

I get these too occasionally. They are reported to me by end users who run the executable on their mac and pc. They seem to be related to the garbage collector, not to audio. It looks like the GC tries to write to the log file and then crashes.
It may be that this started happening since I turned the “use incremental GC” switch on.

mono_os_sem_init: semaphore_create failed with error 268451842
Obtained 11 stack frames.
#0 0x007fff6d5a433a in __pthread_kill
#1 0x007fff6d52b808 in abort
#2 0x00000112b30df2 in mono_log_write_logfile
#3 0x00000112b44dfc in monoeg_g_logv
#4 0x00000112b44efd in monoeg_g_log
#5 0x00000112b3b3bf in mono_thread_info_attach
#6 0x00000112aecaa6 in start_wrapper
#7 0x00000112b60d12 in GC_inner_start_routine
#8 0x00000112b60ca7 in GC_start_routine
#9 0x007fff6d661109 in _pthread_start
#10 0x007fff6d65cb8b in thread_start

Thread 64 Crashed:
0 libsystem_kernel.dylib 0x00007fff6d5a433a __pthread_kill + 10
1 libsystem_pthread.dylib 0x00007fff6d660e60 pthread_kill + 430
2 libsystem_c.dylib 0x00007fff6d52b808 abort + 120
3 UnityPlayer.dylib 0x000000010bfd76e2 0x10b75d000 + 8890082
4 libmonobdwgc-2.0.dylib 0x0000000112a37c15 mono_chain_signal + 79
5 libmonobdwgc-2.0.dylib 0x0000000112a37f58 sigabrt_signal_handler + 86
6 libsystem_platform.dylib 0x00007fff6d6555fd _sigtramp + 29
7 ??? 000000000000000000 0 + 0
8 libsystem_c.dylib 0x00007fff6d52b808 abort + 120
9 libmonobdwgc-2.0.dylib 0x0000000112b30df2 mono_log_write_logfile + 346
10 libmonobdwgc-2.0.dylib 0x0000000112b44dfc monoeg_g_logv + 83
11 libmonobdwgc-2.0.dylib 0x0000000112b44efd monoeg_g_log + 134
12 libmonobdwgc-2.0.dylib 0x0000000112b3b3bf mono_thread_info_attach + 454
13 libmonobdwgc-2.0.dylib 0x0000000112aecaa6 start_wrapper + 37
14 libmonobdwgc-2.0.dylib 0x0000000112b60d12 GC_inner_start_routine + 90
15 libmonobdwgc-2.0.dylib 0x0000000112b60ca7 GC_start_routine + 28
16 libsystem_pthread.dylib 0x00007fff6d661109 _pthread_start + 148
17 libsystem_pthread.dylib 0x00007fff6d65cb8b thread_start + 15
Thread 64 crashed with X86 Thread State (64-bit):
rax: 0x0000000000000000 rbx: 0x000070000e2ec000 rcx: 0x000070000e2eb5c8 rdx: 0x0000000000000000
rdi: 0x0000000003ff4307 rsi: 0x0000000000000006 rbp: 0x000070000e2eb5f0 rsp: 0x000070000e2eb5c8
r8: 0x00000000000130a8 r9: 0x0000000000000000 r10: 0x000070000e2ec000 r11: 0x0000000000000246
r12: 0x0000000003ff4307 r13: 0x43aabf126fb600cb r14: 0x0000000000000006 r15: 0x0000000000000016
rip: 0x00007fff6d5a433a rfl: 0x0000000000000246 cr2: 0x000000010cdca351