Open mjsabby opened 4 years ago
@jkotas @MichalStrehovsky do you know much about this?
My guess would be that accessing Thread.CurrentThread as part of the class constructor runner triggers a class constructor check.
Seems like internal static readonly int OptimalMaxSpinWaitsPerSpinIteration = 64;
is the only thing the cctor initializes. This should really be a const. Submitted a pull request.
@MichalStrehovsky change may help with this crash.
There is still a potential more fundamental problem: The regular Lock can end up using wait method overriden via synchronization context. The class constructor runner (and other similar places) should be better using LowLevelLock.
DeviceDetection.Native!S_P_CoreLib_System_Threading_Lock__TryAcquireContended DeviceDetection.Native!S_P_CoreLib_System_Runtime_CompilerServices_ClassConstructorRunner__DeadlockAwareAcquire DeviceDetection.Native!S_P_CoreLib_System_Runtime_CompilerServices_ClassConstructorRunner__EnsureClassConstructorRun DeviceDetection.Native!S_P_CoreLib_System_Runtime_CompilerServices_ClassConstructorRunner__CheckStaticClassConstructionReturnThreadStaticBase DeviceDetection.Native!S_P_CoreLib_System_Threading_WaitHandle__WaitOneNoCheck DeviceDetection.Native!S_P_CoreLib_System_Threading_Lock__TryAcquireContended DeviceDetection.Native!S_P_CoreLib_System_Runtime_CompilerServices_ClassConstructorRunner__DeadlockAwareAcquire DeviceDetection.Native!S_P_CoreLib_System_Runtime_CompilerServices_ClassConstructorRunner__EnsureClassConstructorRun DeviceDetection.Native!S_P_CoreLib_System_Runtime_CompilerServices_ClassConstructorRunner__CheckStaticClassConstructionReturnThreadStaticBase DeviceDetection.Native!S_P_CoreLib_System_Threading_WaitHandle__WaitOneNoCheck DeviceDetection.Native!S_P_CoreLib_System_Threading_Lock__TryAcquireContended DeviceDetection.Native!S_P_CoreLib_System_Runtime_CompilerServices_ClassConstructorRunner__DeadlockAwareAcquire DeviceDetection.Native!S_P_CoreLib_System_Runtime_CompilerServices_ClassConstructorRunner__EnsureClassConstructorRun DeviceDetection.Native!S_P_CoreLib_System_Runtime_CompilerServices_ClassConstructorRunner__CheckStaticClassConstructionReturnThreadStaticBase DeviceDetection.Native!S_P_CoreLib_System_Threading_WaitHandle__WaitOneNoCheck