ConcurrentDictionary TryAdd crash on Unity 2021.3.21

Hi! We are migrating from Unity 2020.3.34 to Unity 2021.3.21. We made a build with Unity 2021.3.17, had this crash , then moved to 2021.3.21 to resolve said crash. But right now we having a new crash that only happens on Android. The full name we are seeing in Crashlytics is:

ConcurrentDictionary<>.TryAdd

Here’s the stacktrace:

Crashed: Thread: SIGSEGV  0x0000000000000060
#00 pc 0x336aee0 libil2cpp.so (ConcurrentDictionary<>.TryAdd) (BuildId: 7e2440ba070709bd7a5b7ee712d3afd887d6b15f)
#01 pc 0x874402 libil2cpp.so (il2cpp::vm::Class::Init(Il2CppClass*)) (BuildId: 7e2440ba070709bd7a5b7ee712d3afd887d6b15f)
#02 pc 0x1258842 libil2cpp.so (D:eyes:nNext_mDEFA0E5316A015ECFC512188188BB1F7B84D06CB_gshared) (BuildId: 7e2440ba070709bd7a5b7ee712d3afd887d6b15f)
#03 pc 0xa861b6 libil2cpp.so (<>c__DisplayClass10<>.<ProcessNext>b__0) (BuildId: 7e2440ba070709bd7a5b7ee712d3afd887d6b15f)
#04 pc 0x205c062 libil2cpp.so (ExecutionContext.RunInternal) (BuildId: 7e2440ba070709bd7a5b7ee712d3afd887d6b15f)
#05 pc 0x41a5d59 libil2cpp.so (<>c.<GetState>b__0_0) (BuildId: 7e2440ba070709bd7a5b7ee712d3afd887d6b15f)
#06 pc 0x205be16 libil2cpp.so (ExecutionContext.Run) (BuildId: 7e2440ba070709bd7a5b7ee712d3afd887d6b15f)
#07 pc 0x419dbbe libil2cpp.so (<>c.<GetState>b__0_0) (BuildId: 7e2440ba070709bd7a5b7ee712d3afd887d6b15f)
#08 pc 0x1fd861a libil2cpp.so (QueueUserWorkItemCallback.System_Threading_IThreadPoolWorkItem_ExecuteWorkItem) (BuildId: 7e2440ba070709bd7a5b7ee712d3afd887d6b15f)
#09 pc 0x4129c5a libil2cpp.so (<>c.<GetState>b__0_0) (BuildId: 7e2440ba070709bd7a5b7ee712d3afd887d6b15f)
#10 pc 0x2061902 libil2cpp.so (ThreadPoolWorkQueue.Dispatch) (BuildId: 7e2440ba070709bd7a5b7ee712d3afd887d6b15f)
#11 pc 0x6fe6f6 libil2cpp.so (RuntimeInvoker_FalseBigInteger(void (*)(), MethodInfo const*, void*, void**, void*)) (BuildId: 7e2440ba070709bd7a5b7ee712d3afd887d6b15f)
#12 pc 0xb625e libc.so (BuildId: af31ec96b35fedca378e07659b30896c)
#13 pc 0x6fe706 libil2cpp.so (RuntimeInvoker_FalseByte(void (*)(), MethodInfo const*, void*, void**, void*)) (BuildId: 7e2440ba070709bd7a5b7ee712d3afd887d6b15f)
#14 pc 0x85378a libil2cpp.so (il2cpp::vm::Runtime::InvokeWithThrow(MethodInfo const*, void*, void**)) (BuildId: 7e2440ba070709bd7a5b7ee712d3afd887d6b15f)
#15 pc 0x853756 libil2cpp.so (il2cpp::vm::Runtime::InvokeWithThrow(MethodInfo const*, void*, void**)) (BuildId: 7e2440ba070709bd7a5b7ee712d3afd887d6b15f)
#16 pc 0x855f06 libil2cpp.so (worker_thread(void*)) (BuildId: 7e2440ba070709bd7a5b7ee712d3afd887d6b15f)
#17 pc 0x820fe6 libil2cpp.so (il2cpp::vm::Thread::AdjustStaticData()) (BuildId: 7e2440ba070709bd7a5b7ee712d3afd887d6b15f)
#18 pc 0x82319a libil2cpp.so (il2cpp::vm::ThreadStart(void*)) (BuildId: 7e2440ba070709bd7a5b7ee712d3afd887d6b15f)
#19 pc 0x82314e libil2cpp.so (il2cpp::vm::Thread::CreateInternal(void (*)(void*), void*, bool, unsigned int)) (BuildId: 7e2440ba070709bd7a5b7ee712d3afd887d6b15f)
#20 pc 0x8fe8a2 libil2cpp.so (il2cpp::os::Thread::RunWrapper(void*)) (BuildId: 7e2440ba070709bd7a5b7ee712d3afd887d6b15f)
#21 pc 0x8fc386 libil2cpp.so (il2cpp::os::ThreadImpl::ThreadStartWrapper(void*)) (BuildId: 7e2440ba070709bd7a5b7ee712d3afd887d6b15f)
#22 pc 0xa6293 libc.so (BuildId: af31ec96b35fedca378e07659b30896c)
#23 pc 0xa627d libc.so (BuildId: af31ec96b35fedca378e07659b30896c)
#24 pc 0x60803 libc.so (BuildId: af31ec96b35fedca378e07659b30896c)
#25 pc 0xa627d libc.so (BuildId: af31ec96b35fedca378e07659b30896c)
#26 pc 0x8fc356 libil2cpp.so (il2cpp::os::ThreadImpl::Run(void (*)(void*), void*, long long)) (BuildId: 7e2440ba070709bd7a5b7ee712d3afd887d6b15f)

As you can see, it’s not exactly a critical bug as it doesn’t happen frecuently and it’s only on Android, but this happened in a “test project” we use to test migrations and it started happening on Unity 2021.3.21 and we wouldn’t want it to “spread” to more relevant games.

Have you seen any bug or crash related to this? Do you need more information about it? Did I put something wrong?

Please let know!

Thank you in advance!

I’m not quite sure what is happening here, and I don’t recall seeing similar crashes. The call stack might not be completely correct, as I don’t think that the Class::Init method in frame 1 can call ConcurrentDictionary<>.TryAdd in frame 0.

What does the C# code in the Do::Next method (frame 3) look like?

Mmm… help me understand how to read this. There should be a class named “Do” with a method called “OnNext”? We’re using the Unirx plugin which might be related to this.

Yes, that is what the mangled name D:eyes:nNext_mDEFA0E5316A015ECFC512188188BB1F7B84D06CB_gshared means. This is a method named Next on a type named Do. It is a generic method, where the implementation is shared for any generic argument type.

1 Like