Deadlock in xamarin_release_trampoline
- Dominant language
- C#
- Stars
- 2.9k
- Forks
- 576
- Avg merge
- 2d 12h
- Merged PRs (30d)
- 123
Description
Relevant stack traces:
```
thread #46, name = 'tid_21b17'
frame #0: 0x00007ff8074f49b6 libsystem_kernel.dylib`semaphore_wait_trap + 10
frame #1: 0x000000010a2f78f9 xammac_tests`mono_os_sem_timedwait [inlined] mono_os_sem_wait at mono-os-semaphore.h:84:8 [opt]
frame #2: 0x000000010a2f78e4 xammac_tests`mono_os_sem_timedwait(sem=0x000000010a5e0dd4, timeout_ms=, flags=MONO_SEM_FLAGS_NONE) at mono-os-semaphore.h:103:32 [opt]
frame #3: 0x000000010a2f7445 xammac_tests`mono_threads_wait_pending_operations at mono-threads.c:319:8 [opt]
frame #4: 0x000000010a25464e xammac_tests`sgen_client_stop_world at sgen-stw.c:306:3 [opt]
frame #5: 0x000000010a25456c xammac_tests`sgen_client_stop_world(generation=1, serial_collection=1) at sgen-stw.c:124:2 [opt]
frame #6: 0x000000010a2a88b6 xammac_tests`sgen_stop_world(generation=1, serial_collection=1) at sgen-gc.c:3871:2 [opt]
frame #7: 0x000000010a2a54b4 xammac_tests`sgen_perform_collection [inlined] sgen_perform_collection_inner(requested_size=, generation_to_collect=, reason=, forced_serial=, stw=) at sgen-gc.c:2566:3 [opt]
frame #8: 0x000000010a2a5455 xammac_tests`sgen_perform_collection(requested_size=0, generation_to_collect=1, reason="user request", forced_serial=1, stw=1) at sgen-gc.c:2679:2 [opt]
frame #9: 0x000000010a2a6713 xammac_tests`sgen_gc_collect(generation=1) at sgen-gc.c:3132:2 [opt]
frame #10: 0x000000010a24cfa6 xammac_tests`mono_gc_collect(generation=) at sgen-mono.c:2565:2 [opt]
frame #11: 0x00000001150fcf68
frame #12: 0x00000001109cc87b
frame #13: 0x000000010a0eede3 xammac_tests`mono_jit_runtime_invoke(method=, obj=, params=0x0000700008379f58, exc=, error=) at mini-runtime.c:3217:12 [opt]
frame #14: 0x000000010a2234b8 xammac_tests`mono_runtime_invoke_checked [inlined] do_runtime_invoke(method=0x00007f92f88e7388, obj=0x000000010c806f48, params=0x0000700008379f58, exc=0x0000000000000000, error=0x0000700008379ef0) at object.c:3052:11 [opt]
frame #15: 0x000000010a223482 xammac_tests`mono_runtime_invoke_checked(method=0x00007f92f88e7388, obj=0x000000010c806f48, params=0x0000700008379f58, error=0x0000700008379ef0) at object.c:3220:9 [opt]
frame #16: 0x000000010a229efd xammac_tests`mono_runtime_delegate_try_invoke(delegate=0x000000010c806f48, params=0x0000700008379f58, exc=0x0000000000000000, error=0x0000700008379ef0) at object.c:4438:7 [opt]
frame #17: 0x000000010a27c1b7 xammac_tests`start_wrapper_internal(start_info=0x0000000000000000, stack_ptr=) at threads.c:1255:3 [opt]
frame #18: 0x000000010a27bf0e xammac_tests`start_wrapper(data=0x0000600003eda240) at threads.c:1308:8 [opt]
frame #19: 0x00007ff8075314e1 libsystem_pthread.dylib`_pthread_start + 125
frame #20: 0x00007ff80752cf6b libsystem_pthread.dylib`thread_start + 15
thread #47, name = 'tid_2970b'
frame #0: 0x00007ff8074f49b6 libsystem_kernel.dylib`semaphore_wait_trap + 10
frame #1: 0x000000010a2f7298 xammac_tests`mono_thread_info_wait_for_resume [inlined] mono_os_sem_wait(sem=, flags=MONO_SEM_FLAGS_NONE) at mono-os-semaphore.h:84:8 [opt]
frame #2: 0x000000010a2f7289 xammac_tests`mono_thread_info_wait_for_resume(info=0x00007f92fa8a5c00) at mono-threads.c:233:8 [opt]
frame #3: 0x000000010a2f4636 xammac_tests`mono_threads_enter_gc_unsafe_region_unbalanced_with_info(info=0x00007f92fa8a5c00, stackdata=0x000070000857c930) at mono-threads-coop.c:498:3 [opt]
frame #4: 0x000000010a222a6d xammac_tests`mono_gchandle_get_target(gchandle=551131) at external-only.c:88:2 [opt]
frame #5: 0x0000000109ff34bf xammac_tests`xamarin_gchandle_get_target(handle=2000-12-31 23:59:42 UTC) at runtime.m:2997:9
frame #6: 0x0000000109ff60b5 xammac_tests`xamarin_switch_gchandle(self=0x000060002e124800, to_weak=true) at runtime.m:1775:19
frame #7: 0x0000000109ff90b4 xammac_tests`xamarin_release_trampoline(self=0x000060002e124800, sel="release") at trampolines.m:727:3
frame #8: 0x000000010a3e444d xammac_tests`-[MonoTouchFixtures_ObjCRuntime_ToggleRefRetainDeadlockTest_CustomObject release] + 29
frame #9: 0x000000010e6d9856
frame #10: 0x00000001109cc87b
frame #11: 0x000000010a0eede3 xammac_tests`mono_jit_runtime_invoke(method=, obj=, params=0x000070000857cf58, exc=, error=) at mini-runtime.c:3217:12 [opt]
frame #12: 0x000000010a2234b8 xammac_tests`mono_runtime_invoke_checked [inlined] do_runtime_invoke(method=0x00007f92f88e7388, obj=0x000000010c807188, params=0x000070000857cf58, exc=0x0000000000000000, error=0x000070000857cef0) at object.c:3052:11 [opt]
frame #13: 0x000000010a223482 xammac_tests`mono_runtime_invoke_checked(method=0x00007f92f88e7388, obj=0x000000010c807188, params=0x000070000857cf58, error=0x000070000857cef0) at object.c:3220:9 [opt]
frame #14: 0x000000010a229efd xammac_tests`mono_runtime_delegate_try_invoke(delegate=0x000000010c807188, params=0x000070000857cf58, exc=0x0000000000000000, error=0x000070000857cef0) at object.c:4438:7 [opt]
frame #15: 0x000000010a27c1b7 xammac_tests`start_wrapper_internal(start_info=0x0000000000000000, stack_ptr=) at threads.c:1255:3 [opt]
frame #16: 0x000000010a27bf0e xammac_tests`start_wrapper(data=0x0000600003ec3580) at threads.c:1308:8 [opt]
frame #17: 0x00007ff8075314e1 libsystem_pthread.dylib`_pthread_start + 125
frame #18: 0x00007ff80752cf6b libsystem_pthread.dylib`thread_start + 15
thread #48, name = 'tid_29507'
frame #0: 0x00007ff8074f6bd2 libsystem_kernel.dylib`__psynch_mutexwait + 10
frame #1: 0x00007ff80752ee7e libsystem_pthread.dylib`_pthread_mutex_firstfit_lock_wait + 76
frame #2: 0x00007ff80752ccbb libsystem_pthread.dylib`_pthread_mutex_firstfit_lock_slow + 205
frame #3: 0x0000000109ff9070 xammac_tests`xamarin_release_trampoline(self=0x000060002ecea160, sel="release") at trampolines.m:712:2
frame #4: 0x000000010a3e444d xammac_tests`-[MonoTouchFixtures_ObjCRuntime_ToggleRefRetainDeadlockTest_CustomObject release] + 29
frame #5: 0x00007ff8073cb0da libobjc.A.dylib`AutoreleasePoolPage::releaseUntil(objc_object**) + 164
frame #6: 0x00007ff8073c7f5f libobjc.A.dylib`objc_autoreleasePoolPop + 168
frame #7: 0x00007ff8075b9b8a CoreFoundation`_CFAutoreleasePoolPop + 22
frame #8: 0x00007ff80842d4f0 Foundation`-[NSAutoreleasePool drain] + 133
frame #9: 0x000000010a000e07 xammac_tests`xamarin_thread_finish(user_data=0x0000000000000000) at monovm-bridge.m:281:3
frame #10: 0x000000010a0008d9 xammac_tests`thread_end(prof=0x000000010a5cac18, tid=123145444392960) at monovm-bridge.m:297:2
frame #11: 0x000000010a2387ad xammac_tests`mono_profiler_raise_thread_stopped(tid=123145444392960) at profiler-events.h:105:1 [opt]
frame #12: 0x000000010a273ceb xammac_tests`mono_thread_detach_internal(thread=0x0000000111022138) at threads.c:1047:2 [opt]
frame #13: 0x000000010a27c0cb xammac_tests`start_wrapper_internal(start_info=0x0000000000000000, stack_ptr=) at threads.c:1289:2 [opt]
frame #14: 0x000000010a27bf0e xammac_tests`start_wrapper(data=0x0000600003ed9fc0) at threads.c:1308:8 [opt]
frame #15: 0x00007ff8075314e1 libsystem_pthread.dylib`_pthread_start + 125
frame #16: 0x00007ff80752cf6b libsystem_pthread.dylib`thread_start + 15
```
* Thread 46 is waiting for the world to stop
* Thread 47 is stopped while calling xamarin_release_trampoline, holds a lock, and is waiting the world to resume
* Thread 48 is finishing, processing thread-end events, calling xamarin_release_trampoline, and trying to lock the lock held by thread 47 (and apparently this thread is not considered stopped).
Full output (from a test run - the MonoTouchFixtures.ObjCRuntime.ToggleRefRetainDeadlockTest test triggers the deadlock):
[execute-Mac_Modern-20220908_055653.txt](https://github.com/xamarin/xamarin-macios/files/9526630/execute-Mac_Modern-20220908_055653.txt)
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.