Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

System.AccessViolationException when using current version (68.2.0.9) of Microsoft.ICU.ICU4C.Runtime with .NET SDK v6.0.402 #77045

Closed
ThomasSkyldahl opened this issue Oct 14, 2022 · 10 comments
Assignees
Milestone

Comments

@ThomasSkyldahl
Copy link

Description

Hi we are having issues with ICU after installing the new .NET 6 SDK v6.0.402
using specific Compare options fails with System.AccessValidationException

We are using up to date versions of Windows 10 and Windows 11 and the same error happens on both with the latest .NET SDK updates.

If ICU settings are disabled everything behaves as normal

Reproduction Steps

Setup a new .NET 6 console project with the following files

Repro.csproj

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net6.0</TargetFramework>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.ICU.ICU4C.Runtime" Version="68.2.0.9" />
    <RuntimeHostConfigurationOption Include="System.Globalization.AppLocalIcu" Value="68.2.0.9" />
  </ItemGroup>
</Project>

Program.cs

using System.Globalization;
CultureInfo.GetCultureInfo("en-US").CompareInfo.Compare("sample", "Sample", CompareOptions.IgnoreSymbols);

Expected behavior

No System.AccessViolationException are thrown and the program exists with status code 0

Actual behavior

System.AccessViolationException is thrown or Windows Security Exploit Protection kills the program if Control flow guard (CFG) is enabled

Regression?

With the previous version of the SDK everything worked as espected

Known Workarounds

Remove ICU settings
<RuntimeHostConfigurationOption Include="System.Globalization.AppLocalIcu" Value="68.2.0.9" />

Configuration

.NET SDK v6.0.402
.NET Runtime v6.0.10
Architecture: x64
Windows 10 and 11 both fully updated
Specific on my machine: Version 21H2 (OS Build 190444.2130)

Other information

No response

@ghost ghost added the untriaged New issue has not been triaged by the area owner label Oct 14, 2022
@ghost
Copy link

ghost commented Oct 14, 2022

Tagging subscribers to this area: @dotnet/area-system-globalization
See info in area-owners.md if you want to be subscribed.

Issue Details

Description

Hi we are having issues with ICU after installing the new .NET 6 SDK v6.0.402
using specific Compare options fails with System.AccessValidationException

We are using up to date versions of Windows 10 and Windows 11 and the same error happens on both with the latest .NET SDK updates.

If ICU settings are disabled everything behaves as normal

Reproduction Steps

Setup a new .NET 6 console project with the following files

Repro.csproj

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net6.0</TargetFramework>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.ICU.ICU4C.Runtime" Version="68.2.0.9" />
    <RuntimeHostConfigurationOption Include="System.Globalization.AppLocalIcu" Value="68.2.0.9" />
  </ItemGroup>
</Project>

Program.cs

using System.Globalization;
CultureInfo.GetCultureInfo("en-US").CompareInfo.Compare("sample", "Sample", CompareOptions.IgnoreSymbols);

Expected behavior

No System.AccessViolationException are thrown and the program exists with status code 0

Actual behavior

System.AccessViolationException is thrown or Windows Security Exploit Protection kills the program if Control flow guard (CFG) is enabled

Regression?

With the previous version of the SDK everything worked as espected

Known Workarounds

Remove ICU settings
<RuntimeHostConfigurationOption Include="System.Globalization.AppLocalIcu" Value="68.2.0.9" />

Configuration

.NET SDK v6.0.402
.NET Runtime v6.0.10
Architecture: x64
Windows 10 and 11 both fully updated
Specific on my machine: Version 21H2 (OS Build 190444.2130)

Other information

No response

Author: ThomasSkyldahl
Assignees: -
Labels:

area-System.Globalization, untriaged

Milestone: -

@tarekgh tarekgh added this to the 6.0.x milestone Oct 14, 2022
@ghost ghost removed the untriaged New issue has not been triaged by the area owner label Oct 14, 2022
@tarekgh
Copy link
Member

tarekgh commented Oct 14, 2022

Thanks @ThomasSkyldahl for reporting it. I'll work on fixing it.

@tarekgh
Copy link
Member

tarekgh commented Oct 18, 2022

@ThomasSkyldahl I already have the PRs out for the fix but I want to learn more about your scenario. Didn't you discover this issue from already deployed app? or you are building a new app/service and run into the issue? Also, are you willing to upgrade to .NET 7.0? My question mostly to understand the timing till we release the fix.

@ThomasSkyldahl
Copy link
Author

We are in the process of upgrading a .NET Framework Umbraco 8 installation to .NET 6 + Umbraco 10.

My guess is that Umbraco adds ICU with AppLocal to get consistant CultureInfo naming cross platform as they use CultureInfo.GetCultures()

And in our case we use it with Hangfire and inside hangfire they use Dapper and it uses Microsoft.Data.SqlClient or the old one and its inside their data mapping the Comparer failed

For us it shouldn't be a problem to wait for a .NET 6 release alongside the .NET 7 release

@tarekgh
Copy link
Member

tarekgh commented Oct 18, 2022

Thanks for the info @ThomasSkyldahl. As a workaround for now, you may downgrade to .NET 6.0.9 till we release the fix.

@cmeeren
Copy link

cmeeren commented Oct 18, 2022

For clarity, is this issue dependent on the version of the .NET SDK used to build the code, or the version of the .NET runtime used to run the code?

Asking because I'm running stuff in Azure App Service, which doesn't seem to have fine-grained control over the .NET runtime version. Is there a workaround in that case, if I want to stick to app-local ICU?

@tarekgh
Copy link
Member

tarekgh commented Oct 18, 2022

@cmeeren It will depend on the installed .NET runtime. You have the option to publish your service/app with the runtime included https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-publish with --self-contained option.

@tarekgh
Copy link
Member

tarekgh commented Oct 18, 2022

We have merged all servicing PRs. Closing the issue.

@tarekgh tarekgh closed this as completed Oct 18, 2022
@nul800sebastiaan
Copy link

@tarekgh Just as some feedback on timing: this was introduced in production apps, the platform upgraded the .net version and downgrading is not possible. So we're relying on a new .net 6 version to be released to get the platform upgraded again.

Thanks for your consideration!

@tarekgh
Copy link
Member

tarekgh commented Oct 19, 2022

@nul800sebastiaan thanks for the feedback. The fix will be in the next .NET 6.0 service release.

@ghost ghost locked as resolved and limited conversation to collaborators Nov 18, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants