Skip to content

Stack overflow from static constructors taking locks on Native AOT #113949

@Sergio0694

Description

@Sergio0694

Description

We're seeing quite a few hits across multiple WER buckets in the Microsoft Store, with similar stacktraces:

00 <MICROSOFT_STORE>!S_P_CoreLib_System_Threading_Lock__TryEnterSlow_0+0xb 
01 <MICROSOFT_STORE>!S_P_CoreLib_System_Threading_Lock__TryEnter_Outlined+0x72 
02 <MICROSOFT_STORE>!S_P_CoreLib_System_Threading_Lock__TryEnter_0+0xe 
03 <MICROSOFT_STORE>!S_P_CoreLib_System_Runtime_CompilerServices_ClassConstructorRunner__DeadlockAwareAcquire+0x65 
04 <MICROSOFT_STORE>!S_P_CoreLib_System_Runtime_CompilerServices_ClassConstructorRunner__EnsureClassConstructorRun+0x77 
05 <MICROSOFT_STORE>!S_P_CoreLib_System_Runtime_CompilerServices_ClassConstructorRunner__CheckStaticClassConstructionReturnGCStaticBase+0xd 
06 <MICROSOFT_STORE>!S_P_CoreLib_System_Threading_WaitHandle__WaitForMultipleObjectsIgnoringSyncContext+0x23c 
07 <MICROSOFT_STORE>!S_P_CoreLib_System_Threading_WaitHandle__WaitOneNoCheck+0x126 
08 <MICROSOFT_STORE>!S_P_CoreLib_System_Threading_Lock__TryEnterSlow_0+0x517 
09 <MICROSOFT_STORE>!S_P_CoreLib_System_Threading_Lock__TryEnter_Outlined+0x72 
0a <MICROSOFT_STORE>!S_P_CoreLib_System_Threading_Lock__TryEnter_0+0xe 
0b <MICROSOFT_STORE>!S_P_CoreLib_System_Runtime_CompilerServices_ClassConstructorRunner__DeadlockAwareAcquire+0x65 
0c <MICROSOFT_STORE>!S_P_CoreLib_System_Runtime_CompilerServices_ClassConstructorRunner__EnsureClassConstructorRun+0x77 
0d <MICROSOFT_STORE>!S_P_CoreLib_System_Runtime_CompilerServices_ClassConstructorRunner__CheckStaticClassConstructionReturnGCStaticBase+0xd 
0e <MICROSOFT_STORE>!S_P_CoreLib_System_Threading_WaitHandle__WaitForMultipleObjectsIgnoringSyncContext+0x23c 
0f <MICROSOFT_STORE>!S_P_CoreLib_System_Threading_WaitHandle__WaitOneNoCheck+0x126 
10 <MICROSOFT_STORE>!S_P_CoreLib_System_Threading_Lock__TryEnterSlow_0+0x517 
11 <MICROSOFT_STORE>!S_P_CoreLib_System_Threading_Lock__TryEnter_Outlined+0x72 
12 <MICROSOFT_STORE>!S_P_CoreLib_System_Threading_Lock__TryEnter_0+0xe 
13 <MICROSOFT_STORE>!S_P_CoreLib_System_Runtime_CompilerServices_ClassConstructorRunner__DeadlockAwareAcquire+0x65 
14 <MICROSOFT_STORE>!S_P_CoreLib_System_Runtime_CompilerServices_ClassConstructorRunner__EnsureClassConstructorRun+0x77 
15 <MICROSOFT_STORE>!S_P_CoreLib_System_Runtime_CompilerServices_ClassConstructorRunner__CheckStaticClassConstructionReturnGCStaticBase+0xd 
16 <MICROSOFT_STORE>!S_P_CoreLib_System_Threading_WaitHandle__WaitForMultipleObjectsIgnoringSyncContext+0x23c 
17 <MICROSOFT_STORE>!S_P_CoreLib_System_Threading_WaitHandle__WaitOneNoCheck+0x126 
18 <MICROSOFT_STORE>!S_P_CoreLib_System_Threading_Lock__TryEnterSlow_0+0x517 
[...]

Here's a bunch of buckets with the same issue:

  • a9dc9e76-1a0a-2469-8b52-3dd7697aceb2
  • f687741f-21c4-c75d-7e19-6db18f7622d0
  • 09ea45c6-7f69-9ef2-d3fa-b613a502a0d1
  • efc37b69-f121-2ab5-f95a-db9c03a28093
  • ede6abc4-1fa5-1b0a-b3fc-02f82e69cb65
  • 64a1f0fd-9cae-2f64-30c4-a86282ce4c37

Opening this for tracking. @MichalStrehovsky and other folks are already looking into this internally (let me know if you'd like me to add you).

Configuration

  • .NET SDK 9.0.3
  • Native AOT, x64

Metadata

Metadata

Assignees

Labels

Type

Projects

Status

No status

Relationships

None yet

Development

No branches or pull requests

Issue actions