runtime: Calling `DateTime.Now` causes memory corruption when machine has many language packs installed

Change in initialization code of TimeZoneInfo introduced by #52992 leads to AV or native heap corruption on Windows.

Original issue description

Repro steps: Install .NET 6 prevew 6 SDK-6.0.100-preview.6.21327.1(runtime-6.0.0-preview.6.21325.7) from https://github.com/dotnet/installer from Main branch

In CLI, execute below command. mkdir ProC# cd ProC# dotnet new sln -o CSCLI cd CSCLI dotnet new console -o CSNC21App dotnet new classlib -o CSNS20Lib dotnet sln add CSNC21App\CSNC21App.csproj dotnet sln add CSNS20Lib\CSNS20Lib.csproj

Expected Result: No any errors

Actual Result: .NET Host stop working. Fatal error. System.AccessViolationException: Attempted to read or write protect ed memory. This is often an indication that other memory is corrupt. at Interop+Kernel32.GetFileMUIPath(UInt32, System.String, Char*, UInt32 ByRef , Char*, UInt32 ByRef, UInt64 ByRef) at System.TimeZoneInfo.GetFileMuiPath(System.String, System.Globalization.Cul tureInfo) at System.TimeZoneInfo.GetCachedFileMuiPath(System.String, System.Globalizati on.CultureInfo) at System.TimeZoneInfo.GetLocalizedNameByMuiNativeResource(System.String, Sys tem.Globalization.CultureInfo) at System.TimeZoneInfo.GetLocalizedNamesByRegistryKey(Internal.Win32.Registry Key, System.String ByRef, System.String ByRef, System.String ByRef) at System.TimeZoneInfo.TryGetTimeZoneFromLocalMachine(System.String, System.T imeZoneInfo ByRef, System.Exception ByRef) at System.TimeZoneInfo.TryGetTimeZoneFromLocalMachine(System.String, Boolean, System.TimeZoneInfo ByRef, System.Exception ByRef, CachedData) at System.TimeZoneInfo.TryGetTimeZoneUsingId(System.String, Boolean, System.T imeZoneInfo ByRef, System.Exception ByRef, CachedData, Boolean) at System.TimeZoneInfo.TryGetTimeZone(System.String, Boolean, System.TimeZone Info ByRef, System.Exception ByRef, CachedData, Boolean) at System.TimeZoneInfo.GetLocalTimeZone(CachedData) at System.TimeZoneInfo+CachedData.CreateLocal() at System.TimeZoneInfo.GetDateTimeNowUtcOffsetFromUtc(System.DateTime, Boolea n ByRef) at System.DateTime.get_Now() at Microsoft.DotNet.Cli.Program.Main(System.String[])

image Problem signature: Problem Event Name: APPCRASH Application Name: dotnet.exe Application Version: 6.0.21.32507 Application Timestamp: 60d615d4 Fault Module Name: coreclr.dll Fault Module Version: 6.0.21.32507 Fault Module Timestamp: 60d60cb9 Exception Code: c0000005 Exception Offset: 00000000001cb469 OS Version: 6.1.7601.2.1.0.256.27 Locale ID: 1033 Additional Information 1: ee7a Additional Information 2: ee7aebb493adcdf2891586b392e6e5a5 Additional Information 3: c638 Additional Information 4: c638660efa7b5668612ea728d2ef2abb

Read our privacy statement online: http://go.microsoft.com/fwlink/?linkid=104288&clcid=0x0409

If the online privacy statement is not available, please read our privacy statement offline: C:\Windows\system32\en-US\erofflps.txt

Note: It’s a inconsistent issue. dotnet --info image

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 20 (19 by maintainers)

Most upvoted comments

@vdanche I’m not sure it’s the same issue, the callstack is different.

Thanks davidfowl, we file a new bug to track #55900 .

@tarekgh I have sent you OS bug number on email.