dotnet / runtime

.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
https://docs.microsoft.com/dotnet/core/
MIT License
15.06k stars 4.69k forks source link

Crash in mono_arch_patch_callsite on Rosetta under heavy jitting #79557

Open UnityAlex opened 1 year ago

UnityAlex commented 1 year ago

Description

Filing bug as per request of @vargaz.

I was unable to recreate a similar project outside Unity that reproduces the kind of heavy threaded jitting that reproduces this. We see this primarily on domain reload or on program startup. The code looks unchanged between mono/mono and dotnet/runtime so it is likely that the bug exists upstream as well. Only impacts Rosetta, native arm64 runtime is fine.

Reproduction Steps

No reproduction available outside Unity unfortunately. I can most likely provide a Unity project upon request.

Expected behavior

No crash.

Actual behavior

Crash with the following callstack:

Obtained 23 stack frames.
#0  0x00000181e58e2e in mono_atomic_xchg_ptr
#1  0x00000181e58901 in mono_arch_patch_callsite
#2  0x00000181d2b59e in common_call_trampoline
#3  0x00000181d2a46e in mono_magic_trampoline
#4  0x0000017c3c9393 in (Unknown)
#5  0x000001af3b1943 in  System.Threading.ExecutionContext:SetExecutionContext (System.Threading.ExecutionContext,bool) {0x7fc0d637b868} + 0x623 (0x1af3b1320 0x1af3b19df) [0x181542960 - Unity Child Domain]
#6  0x0000018cce617b in  System.Threading.ExecutionContext:RunInternal (System.Threading.ExecutionContext,System.Threading.ContextCallback,object,bool) {0x7fc0d637b510} + 0x5ab (0x18cce5bd0 0x18cce6309) [0x181542960 - Unity Child Domain]
#7  0x0000018cce5b83 in  System.Threading.ExecutionContext:Run (System.Threading.ExecutionContext,System.Threading.ContextCallback,object,bool) {0x7fc0d637b4b8} + 0x93 (0x18cce5af0 0x18cce5bc1) [0x181542960 - Unity Child Domain]
#8  0x000001af3b0e07 in  System.Threading.Tasks.AwaitTaskContinuation:System.Threading.IThreadPoolWorkItem.ExecuteWorkItem () {0x7fc0c66da128} + 0x97 (0x1af3b0d70 0x1af3b0ea8) [0x181542960 - Unity Child Domain]
#9  0x0000018cca5dbb in  System.Threading._ThreadPoolWaitCallback:PerformWaitCallback () {0x7fc0d49ba6b0} + 0xab (0x18cca5d10 0x18cca5e4f) [0x181542960 - Unity Child Domain]
#10 0x00000181c0de7d in mono_jit_runtime_invoke
#11 0x00000181f6cc32 in do_runtime_invoke
#12 0x00000181f671b8 in mono_runtime_try_invoke
#13 0x00000181fa2666 in try_invoke_perform_wait_callback
#14 0x00000181fa1f04 in worker_callback
#15 0x00000181e8f512 in worker_thread
#16 0x00000181f9d5ff in start_wrapper_internal
#17 0x00000181f9d219 in start_wrapper
#18 0x00000182069b37 in GC_inner_start_routine
#19 0x000001820667e8 in GC_call_with_stack_base
#20 0x00000182069abc in GC_start_routine
#21 0x007ff8138b3259 in _pthread_start
#22 0x007ff8138aec7b in thread_start

Regression?

This is not a regression.

Known Workarounds

No response

Configuration

MacOS Ventura 13.0.1 mono 6.12.0.122 System Architecture: arm64 Application architecture: x64

Other information

No response

dotnet-issue-labeler[bot] commented 1 year ago

I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.