Skip to content

SIGBUS crash on ARMv7 in System.Collections.Frozen.Hashing.GetHashCodeOrdinal #127641

Closed

Description

@abogarsukov-braingames

Description

System.Collections.Frozen.Hashing.GetHashCodeOrdinal seems to do unaligned 32-bit reads via (uint*)char* casts. This crashes with SIGBUS on Android ARMv7 builds (Unity IL2CPP). In our case this happens in ToFrozenSet<string>(StringComparer.Ordinal) call.

Stack trace of the crash:

:
#00 pc 0x1b3a7d4 (Hashing_GetHashCodeOrdinal_m10B46F09EEFC7FCEC6779888F6A89E363A6DA273 [System.Collections.Immutable.cpp:3340]) (BuildId: d88546ca5f4a2da3ee2647b04239c9063c34b61d)
#01 pc 0x12f4084 (HashSet_1_InternalGetHashCode_m194DF48C3A8D04814AEF65F316DF262AA89DB68F_gshared [Generics__30.cpp:95]) (BuildId: d88546ca5f4a2da3ee2647b04239c9063c34b61d)
#02 pc 0x12f2824 (HashSet_1_AddIfNotPresent_mC04293BBDC3046C251D90104C942B4576676EF79_gshared [Generics__30.cpp:3560]) (BuildId: d88546ca5f4a2da3ee2647b04239c9063c34b61d)
#03 pc 0x1b3b588 (KeyAnalyzer_HasSufficientUniquenessFactor_mC35F629D3C59D7A1B98FC7B3371F5790C14E0611 [System.Collections.Immutable.cpp:1258]) (BuildId: d88546ca5f4a2da3ee2647b04239c9063c34b61d)
#04 pc 0x1b3b01c (KeyAnalyzer_TryUseSubstring_m9EF5936406D8741DC791AC6921082189DD488980 [System.Collections.Immutable.cpp:3959]) (BuildId: d88546ca5f4a2da3ee2647b04239c9063c34b61d)
#05 pc 0x1b3ada4 (KeyAnalyzer_Analyze_m62C1BD927802A6CD775C64B96B38FD5FDB10D380 [System.Collections.Immutable.cpp:3776]) (BuildId: d88546ca5f4a2da3ee2647b04239c9063c34b61d)
#06 pc 0xe6ec8c (FrozenSet_CreateFromSet_TisRuntimeObject_m7DC67826C6AAB96CF8C9EF2FD9C918E2C60560A8_gshared [GenericMethods__15.cpp:18881]) (BuildId: d88546ca5f4a2da3ee2647b04239c9063c34b61d)
#07 pc 0xb950cc (AnalyticsProvider__ctor_m03672B22DFC58D53D50543D23388A448E20E5D5C [BrainGames.Analytics.cpp:1463]) (BuildId: d88546ca5f4a2da3ee2647b04239c9063c34b61d)
#08 pc 0xb9ae78 (SingularAnalyticsProvider__ctor_m6BEC11DB2FA4245AFCE1C9BEBB0F71490B8C994A [BrainGames.Analytics.Singular.cpp:1212]) (BuildId: d88546ca5f4a2da3ee2647b04239c9063c34b61d)
#09 pc 0xb9c4cc (SingularAnalyticsProviderBuilder_CreateSingularAnalyticsProvider_m1A0718E3F7F965EA5B06E880881A91499180DFDD [BrainGames.Analytics.Singular.cpp:2346]) (BuildId: d88546ca5f4a2da3ee2647b04239c9063c34b61d)
#10 pc 0xc0a6c4 (SingletonFactoryCallSite_CreateInstance_mCC2192EB139F82864C580B12661255E58954AB1E [BrainGames.DependencyInjection.cpp:4548]) (BuildId: d88546ca5f4a2da3ee2647b04239c9063c34b61d)
#11 pc 0xc0a5c4 (SingletonFactoryCallSite_GetService_mCAA71C1B09D5C88C121A25B1CBF1AC0AE10A5386 [BrainGames.DependencyInjection.cpp:2335]) (BuildId: d88546ca5f4a2da3ee2647b04239c9063c34b61d)
#12 pc 0xc0cd6c (ServiceProvider_GetService_mA8F0286846AD4E8B7182B600D5B2F0E8149654A5_inline(ServiceProvider_t4AF6E77D692A9E29C782CCD1F37F58E4D53930D7*, Type_t*, Il2CppObject*, ServiceProviderScope_tA47CD109A3F3FA3FA8776FF92A530403C0BB050F*, MethodInfo const*) [BrainGames.DependencyInjection.cpp:26]) (BuildId: d88546ca5f4a2da3ee2647b04239c9063c34b61d)
#13 pc 0xc0ca94 (ServiceProviderScope_GetRequiredService_m7E5F4BE8F2C092C34DA69C4F6212845F6292C672 [BrainGames.DependencyInjection.cpp:4171]) (BuildId: d88546ca5f4a2da3ee2647b04239c9063c34b61d)
#14 pc 0xec7938 (ServiceProviderServiceExtensions_GetRequiredService_TisRuntimeObject_m6B9985B4A7BD311169F8AA28F1CF6AAAC50942F9_gshared [GenericMethods__17.cpp:21269]) (BuildId: d88546ca5f4a2da3ee2647b04239c9063c34b61d)
#15 pc 0xb9ccd0 (U3CU3Ec_U3CAddSingularAnalyticsProviderU3Eb__3_3_m2E8CB718E70AED01832F0B1CC84EDBD826C1645B [BrainGames.Analytics.Singular.cpp:1012]) (BuildId: d88546ca5f4a2da3ee2647b04239c9063c34b61d)
#16 pc 0xc27bd0 (DelegateInitializer_InitializeAsync_m20E7D970B3A0BCCD77CECFBBDD451D634EBEB39A [BrainGames.Hosting.cpp:2135]) (BuildId: d88546ca5f4a2da3ee2647b04239c9063c34b61d)
#17 pc 0xc291c4 (U3CInitializeServicesU3Ed__2_MoveNext_mCBD71813E92A56148451A0B574A546E2CEFD7771 [BrainGames.Hosting.Runtime.cpp:36]) (BuildId: d88546ca5f4a2da3ee2647b04239c9063c34b61d)
#18 pc 0x1a39f7c (ExecutionContext_RunInternal_mC37E85D6FC972DF219A00FE1EE34329D1D63CC94 [mscorlib__8.cpp:30609]) (BuildId: d88546ca5f4a2da3ee2647b04239c9063c34b61d)
#19 pc 0x1a39e0c (ExecutionContext_Run_m6E5E07E0131DA97C6BC235754A0682CFFACE7BF8 [mscorlib__8.cpp:24124]) (BuildId: d88546ca5f4a2da3ee2647b04239c9063c34b61d)
#20 pc 0x18b8c90 (MoveNextRunner_Run_m86395F123FB453F2B5FF89CE1E98532F7426F9DE [mscorlib__16.cpp:6688]) (BuildId: d88546ca5f4a2da3ee2647b04239c9063c34b61d)
#21 pc 0x2209834 (Awaitable_RaiseManagedCompletion_m07CF97F840485310EBDE6EF657FD2C3A5F145891_inline(Awaitable_t690337FEC1C411606E233EA36A41337B931C23CB*, MethodInfo const*) [UnityEngine.CoreModule__2.cpp:36443]) (BuildId: d88546ca5f4a2da3ee2647b04239c9063c34b61d)
#22 pc 0x21eb220 (DoubleBufferedAwaitableList_SwapAndComplete_m163E930B58D1D83FC9B8B3AEF021A4516091FCED [UnityEngine.CoreModule__2.cpp:12681]) (BuildId: d88546ca5f4a2da3ee2647b04239c9063c34b61d)
#23 pc 0x951058 (il2cpp::vm::Runtime::InvokeWithThrow(MethodInfo const*, void*, void**) [Runtime.cpp:624]) (BuildId: d88546ca5f4a2da3ee2647b04239c9063c34b61d)
#24 pc 0x950fa4 (il2cpp::vm::Runtime::Invoke(MethodInfo const*, void*, void**, Il2CppException**) [Runtime.cpp:610]) (BuildId: d88546ca5f4a2da3ee2647b04239c9063c34b61d)
#25 pc 0x310bfd (scripting_method_invoke(ScriptingMethodPtr, ScriptingObjectPtr, ScriptingArguments&, ScriptingExceptionPtr*, bool) [/data/app/~~kc6S2ylvno_ci3qAjPw94w==/com.braingames.blockpuzzle-DjEm38DAP9Eps84IWpYJEA==/lib/arm/libunity.so]) (BuildId: 9deeea88bb0b3485)
#26 pc 0x31f517 (ScriptingInvocation::Invoke(ScriptingExceptionPtr*, bool) [/data/app/~~kc6S2ylvno_ci3qAjPw94w==/com.braingames.blockpuzzle-DjEm38DAP9Eps84IWpYJEA==/lib/arm/libunity.so]) (BuildId: 9deeea88bb0b3485)
#27 pc 0x3aa949 (Scripting::UnityEngine::AwaitableProxy::OnUpdate(ScriptingExceptionPtr*) [/data/app/~~kc6S2ylvno_ci3qAjPw94w==/com.braingames.blockpuzzle-DjEm38DAP9Eps84IWpYJEA==/lib/arm/libunity.so]) (BuildId: 9deeea88bb0b3485)
#28 pc 0x324883 (Scripting::Awaitables::WireupNextFrameAndEndOfFrameCallbacks()::$_0::__invoke(Object*, void*) [/data/app/~~kc6S2ylvno_ci3qAjPw94w==/com.braingames.blockpuzzle-DjEm38DAP9Eps84IWpYJEA==/lib/arm/libunity.so]) (BuildId: 9deeea88bb0b3485)
#29 pc 0x1d2bd9 (DelayedCallManager::Update(int) [/data/app/~~kc6S2ylvno_ci3qAjPw94w==/com.braingames.blockpuzzle-DjEm38DAP9Eps84IWpYJEA==/lib/arm/libunity.so]) (BuildId: 9deeea88bb0b3485)
#30 pc 0x26d7bf (ExecutePlayerLoop(NativePlayerLoopSystem*) [/data/app/~~kc6S2ylvno_ci3qAjPw94w==/com.braingames.blockpuzzle-DjEm38DAP9Eps84IWpYJEA==/lib/arm/libunity.so]) (BuildId: 9deeea88bb0b3485)
#31 pc 0x26d7e3 (ExecutePlayerLoop(NativePlayerLoopSystem*) [/data/app/~~kc6S2ylvno_ci3qAjPw94w==/com.braingames.blockpuzzle-DjEm38DAP9Eps84IWpYJEA==/lib/arm/libunity.so]) (BuildId: 9deeea88bb0b3485)
#32 pc 0x26d9db (PlayerLoop() [/data/app/~~kc6S2ylvno_ci3qAjPw94w==/com.braingames.blockpuzzle-DjEm38DAP9Eps84IWpYJEA==/lib/arm/libunity.so]) (BuildId: 9deeea88bb0b3485)
#33 pc 0x38dcc1 (UnityPlayerLoop() [/data/app/~~kc6S2ylvno_ci3qAjPw94w==/com.braingames.blockpuzzle-DjEm38DAP9Eps84IWpYJEA==/lib/arm/libunity.so]) (BuildId: 9deeea88bb0b3485)
#34 pc 0x38e7d9 (nativeRender(_JNIEnv*, _jobject*) [/data/app/~~kc6S2ylvno_ci3qAjPw94w==/com.braingames.blockpuzzle-DjEm38DAP9Eps84IWpYJEA==/lib/arm/libunity.so]) (BuildId: 9deeea88bb0b3485)
#35 pc 0xd35de5 (art_jni_trampoline [/data/misc/apexdata/com.android.art/dalvik-cache/arm/boot.oat])
#36 pc 0xa467c (nterp_helper [/apex/com.android.art/lib/libart.so]) (BuildId: f74abfe0d8ee021d49aa641612003efc)
#37 pc 0x505fe4 (com.unity3d.player.E0.handleMessage [/data/app/~~kc6S2ylvno_ci3qAjPw94w==/com.braingames.blockpuzzle-DjEm38DAP9Eps84IWpYJEA==/base.apk])
#38 pc 0x8595eb (android.os.Handler.dispatchMessage [/data/misc/apexdata/com.android.art/dalvik-cache/arm/boot.oat])
#39 pc 0xa467c (nterp_helper [/apex/com.android.art/lib/libart.so]) (BuildId: f74abfe0d8ee021d49aa641612003efc)
#40 pc 0x4b32e6 (android.os.Looper.loopOnce [/system/framework/framework.jar])
#41 pc 0x85c783 (android.os.Looper.loop [/data/misc/apexdata/com.android.art/dalvik-cache/arm/boot.oat])
#42 pc 0xa3bcc (nterp_helper [/apex/com.android.art/lib/libart.so]) (BuildId: f74abfe0d8ee021d49aa641612003efc)
#43 pc 0x5068c4 (com.unity3d.player.G0.run [/data/app/~~kc6S2ylvno_ci3qAjPw94w==/com.braingames.blockpuzzle-DjEm38DAP9Eps84IWpYJEA==/base.apk])
#44 pc 0xa85c5 (art_quick_invoke_stub_internal [/apex/com.android.art/lib/libart.so]) (BuildId: f74abfe0d8ee021d49aa641612003efc)
#45 pc 0x5d8e99 (art_quick_invoke_stub [/apex/com.android.art/lib/libart.so]) (BuildId: f74abfe0d8ee021d49aa641612003efc)
#46 pc 0x1fa6c1 (art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*) [/apex/com.android.art/lib/libart.so]) (BuildId: f74abfe0d8ee021d49aa641612003efc)
#47 pc 0x5477d5 (art::Thread::CreateCallback(void*) [/apex/com.android.art/lib/libart.so]) (BuildId: f74abfe0d8ee021d49aa641612003efc)
#48 pc 0x5472eb (art::Thread::CreateCallbackWithUffdGc(void*) [/apex/com.android.art/lib/libart.so]) (BuildId: f74abfe0d8ee021d49aa641612003efc)
#49 pc 0x83993 (__pthread_start(void*) [/apex/com.android.runtime/lib/bionic/libc.so]) (BuildId: 996d72885770a3d7398568fb6ca0e9e1)
#50 pc 0x3aafd (__start_thread [/apex/com.android.runtime/lib/bionic/libc.so]) (BuildId: 996d72885770a3d7398568fb6ca0e9e1)

Reproduction Steps

Using Unity IL2CPP call ToFrozenSet on a set of strings with length >= 4.

Expected behavior

The app should not crash on ARMv7.

Actual behavior

The app crashes on ARMv7 with the above mentioned stack trace.

Regression?

We have the issue using System.Collection.Immutable NuGet v8.0.0.

Known Workarounds

Using non-default comparer seem to solve the issue but it also disables useful optimizations.

Configuration

This is Unity 6000.0.58 IL2CPP Android app. It uses .netstandard 2.1. The crash only happens on ARMv7 devices.

Other information

This type of crashes (unaligned reads on ARMv7) is known and seem to be treated as 'by design' behavior by Unity development team (issue).

Activity

  1. added
    untriaged
    on May 1, 2026
  2. EgorBo commented on May 1, 2026

    @EgorBo
    Member

    I already tried to replace that unsafe code with safe (and with explicit "unaligned" loads), but we agreed to wait for #77679 instead. cc @tannergooding

    I suspect we might have more examples like that as we generally do not support platforms where such loads/stores may lead to crashes (not fixed up by the OS), although, we try to keep that in mind.

  3. dotnet-policy-service commented on May 1, 2026

    @dotnet-policy-service
    Contributor

    Tagging subscribers to this area: @dotnet/area-system-collections
    See info in area-owners.md if you want to be subscribed.

  4. jkotas commented on May 1, 2026

    @jkotas
    Member

    I suspect we might have more examples like that as we generally do not support platforms where such loads/stores may lead to crashes (not fixed up by the OS), although, we try to keep that in mind.

    Misaligned access in arch-neutral nuget package is a bug that should be fixed. It does not need to wait for the new API. The fix is still going to be needed for down-level platforms, even with the new API.

  5. MichalPetryka commented on May 1, 2026

    @MichalPetryka
    Contributor

    explicit "unaligned" loads

    IIRC one issue is that CoreCLR ignores that for non FP today.

  6. EgorBo commented on May 1, 2026

    @EgorBo
    Member

    I suspect we might have more examples like that as we generally do not support platforms where such loads/stores may lead to crashes (not fixed up by the OS), although, we try to keep that in mind.

    Misaligned access in arch-neutral nuget package is a bug that should be fixed. It does not need to wait for the new API. The fix is still going to be needed for down-level platforms, even with the new API.

    Just for the reference, I did mention the unaligned store in my PR, but we decided to give up on that change because of perf impact on .NET Framework (it was indeed regressing)

  7. jkotas commented on May 1, 2026

    @jkotas
    Member

    IIRC one issue is that CoreCLR ignores that for non FP today.

    That's ok since (1) the platforms where CoreCLR is supported currently fixup misaligned access and (2) the JIT avoids optimizations that produce code where this fixup does not kick in.

    My guess is that LLVM optimized the two reads into a single LDM instruction. Unlike regular reads, LDM requires aligned address and misaligned access is not fixed up for it. .NET JIT does not have this optimization for Arm32.

  8. added a commit that references this issue on May 1, 2026
    13b9f37
  9. removed
    untriaged
    on May 1, 2026
  10. locked and limited conversation to collaborators on Jun 1, 2026
  11. added a commit that references this issue on Jul 15, 2026
    c5300ec
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions