Skip to content

Fix mono_class_setup_interfaces race-condition on ARM64#2220

Open
nulldatamap wants to merge 7 commits into
unity-mainfrom
fix-setup-interfaces-arm64
Open

Fix mono_class_setup_interfaces race-condition on ARM64#2220
nulldatamap wants to merge 7 commits into
unity-mainfrom
fix-setup-interfaces-arm64

Conversation

@nulldatamap

Copy link
Copy Markdown

Summary

On ARM64 the weak memory ordering model makes the mono_class_setup_interfaces code racy, causing segfaults.
The fix is to use a load-acquire when reading klass->interfaces_inited.

Fixes UUM-144819.

The Problem

I have a detailed explanation of the problem in the comment included with the fix.

Testing

I've tested that solution works against a repro and I had a general sanity assert to ensure the bitfield offset was correct (see commit 6b098b5)

  • 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

Reviewers: please consider these questions as well! ❤️

Release notes

Fixed UUM-144819 @nulldatamap:
Mono: Fix race condition during interface initialization on ARM64.

Backports
6000.0, 6000.3, 6000.5, 6000.6

@cla-assistant-unity

cla-assistant-unity Bot commented Jul 14, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@nulldatamap
nulldatamap requested a review from UnityAlex July 14, 2026 13:13
Comment thread mono/metadata/class-init.c
@nulldatamap

Copy link
Copy Markdown
Author

I ran the Windows ARM64 build with b15853c and it succeeded: https://yamato.ds.unity3d.com/job/71688177. Normally it would crash on the assert because the build runs the editor.
But just to be 100% sure, I'll also trying to do the same thing with the assert, but with a bogus byte/bit offset, just to confirm the check works.

@nulldatamap

Copy link
Copy Markdown
Author

Alright I have proof of the old offsets failing on WinARM64: https://yamato.ds.unity3d.com/job/71759109
And proof of them succeeding with the ones your Claude instance suggested: https://yamato.ds.unity3d.com/job/71818332
So I'll remove the debug check and land with the fixed offsets.

@nulldatamap
nulldatamap force-pushed the fix-setup-interfaces-arm64 branch from e19fa21 to eb1b8e4 Compare July 17, 2026 11:45
@nulldatamap
nulldatamap force-pushed the fix-setup-interfaces-arm64 branch from eb1b8e4 to 06c860d Compare July 17, 2026 11:46
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