Pre-initialize InvariantCulture such that it can be safely used when creating stack traces#129189
Pre-initialize InvariantCulture such that it can be safely used when creating stack traces#129189eduardo-vp wants to merge 4 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR changes CoreCLR startup to proactively run System.Globalization.CultureInfo’s class initializer during AppDomain::SetupSharedStatics(), so CultureInfo.InvariantCulture is initialized before stack trace generation paths might try to use it under extreme memory pressure (avoiding the checked-build assert observed in #129159).
Changes:
- During default AppDomain startup, force
CultureInfoclass initialization viaCheckRunClassInitThrowing(). - Add a targeted comment documenting the motivation (stack trace creation under high memory pressure).
|
/azp list |
|
/azp run runtime-coreclr outerloop |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
/azp run runtime-coreclr outerloop |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
/azp run runtime-coreclr outerloop |
|
Azure Pipelines successfully started running 1 pipeline(s). |
| { | ||
| // Initialize the InvariantCulture such that it can be safely used when creating | ||
| // stack traces under high memory pressure. | ||
| GCX_COOP(); |
There was a problem hiding this comment.
| GCX_COOP(); |
Is GCX_COOP really needed here?
CheckRunClassInitThrowing seems to be MODE_ANY. It may be nice to add it to its contract to be make it explicit.
There was a problem hiding this comment.
Related nit: GCX_COOP in ResolveVirtualFunctionPointer around CheckRunClassInitThrowing looks unnecessary It can be deleted.
The following assert is being hit when creating the stack trace in the test.
runtime/src/libraries/System.Private.CoreLib/src/System/Globalization/CultureInfo.cs
Lines 444 to 451 in 89cd18a
Fixes #129159.