corert icon indicating copy to clipboard operation
corert copied to clipboard

Stackoverflow doing WaitOneNoCheck

Open mjsabby opened this issue 5 years ago • 3 comments

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

mjsabby avatar Feb 10 '20 22:02 mjsabby

@jkotas @MichalStrehovsky do you know much about this?

mjsabby avatar Feb 27 '20 20:02 mjsabby

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 avatar Feb 27 '20 20:02 MichalStrehovsky

@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.

jkotas avatar Feb 27 '20 21:02 jkotas