Brendan Shanks (@bshanks) commented about dlls/ntdll/unix/virtual.c:
+ if (!pthread_get_register_pointer_values) + return 0; + + kret = task_threads( mach_task_self(), &threads, &count ); + if (kret) + return 0; + + for (i = 0; i < count; i++) + { + uintptr_t reg_values[128]; + size_t reg_count = ARRAY_SIZE( reg_values ); + uintptr_t sp; + + kret = pthread_get_register_pointer_values( threads[i], &sp, ®_count, reg_values ); + if (kret) + goto fail; I tried this on macOS Monterey, both Intel and Apple Silicon (under Rosetta). It works correctly on Intel, but on Apple Silicon under Rosetta `thread_get_register_pointer_values` always fails with 0x10000003 (MACH_SEND_INVALID_DESTINATION) when querying Rosetta's exception handling thread, leading to the whole function failing.
The .NET code ignores errors from `thread_get_register_pointer_values` (other than `KERN_INSUFFICIENT_BUFFER_SIZE`) which allows this case to succeed, I think that would be the easiest fix. (Rosetta's exception handling thread has the name 'com.apple.rosetta.exceptionserver' and is somewhat-hidden, for example it doesn't show up if you attach lldb to the process) -- https://gitlab.winehq.org/wine/wine/-/merge_requests/741#note_11578