Skip to content

Protect calls to fork with a gc_lock on MacOS #2125

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 25, 2025

Conversation

bholmes
Copy link
Member

@bholmes bholmes commented Apr 15, 2025

On MacOS running under Rosetta there is a hang if you are calling fork from one thread and thread_suspend from another. (I believe the suspend call is attempting to suspend the forking thread)

We call thread_suspend on all managed threads when doing a GC. We can avoid the collision of calls if we use mono_gc_invoke_with_gc_lock to protect the fork call.

I do not believe this is needed on other platforms or chips. I suspect this is a Rosetta problem that we need to work around.

This is a backport of #2124

  • Should this pull request have release notes?
    • Yes
    • No
  • Do these changes need to be back ported?
    • Yes
    • No
  • Do these changes need to be upstreamed to mono/mono or dotnet/runtime repositories?
    • Yes
    • No

Release notes

Fixed UUM-101541 @bill-holmes:
Mono: Fix Process.Start hangs on intel mac editors running on apple silicon

On MacOS running under Rosetta there is a hang if you are calling fork
from one thread and thread_suspend from another. (I believe the suspend
call is attempting to suspend the forking thread)

We call thread_suspend on all managed threads when doing a GC. We can
avoid the collision of calls if we use mono_gc_invoke_with_gc_lock
to protect the fork call.

I do not believe this is needed on other platforms or chips. I suspect
this is a Rosetta problem that we need to work around.
@bholmes bholmes requested a review from UnityAlex April 15, 2025 16:09
@bholmes bholmes merged commit 327211d into unity-2021.3-mbe Apr 25, 2025
8 of 9 checks passed
@bholmes bholmes deleted the bugfix/2021.3-uum-101541 branch April 25, 2025 12:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants