Runtime: a call to `string.Replace` does not return on linux.

Created on 13 May 2020  路  6Comments  路  Source: dotnet/runtime

Build and run the following code on Linux + .net core 2.1 or 2.2 SDK.

using System;
class Program
{
    static void Main(string[] args)
    {
        "abc".Replace("\0", "", StringComparison.InvariantCulture);
    }
}

The code results an infinity loop (high cpu usage) and never returns.

Remark:
The code works fine on windows.
The code works fine on .net core 3.1.

area-System.Globalization bug

Most helpful comment

@Kagamia-MS

the original issue https://github.com/dotnet/runtime/issues/1060.
Fixed by the PR https://github.com/dotnet/runtime/pull/31946 for 5.0 release.
Ported the fix to 3.1 by the PR https://github.com/dotnet/coreclr/pull/28014
Ported the fix to UWP by the PR https://github.com/dotnet/coreclr/pull/28015

Thanks for considering the workaround using Ordinal operation. Can we close this issue now? or is there anything else blocking you?

All 6 comments

Tagging subscribers to this area: @tarekgh, @safern, @krwq
Notify danmosemsft if you want to be subscribed.

cc: @GrabYourPitchforks

@Kagamia-MS 2.2 is out of support which means we'll not fix it there. 2.1 still supported but I am wondering, can you move to 3.1 instead? yes we had this problem and we have fixed it but not in 2.1.

@tarekgh I've tried to move to 3.1 months ago but meet the IHostEnvironment breaking change, since our dependencies only targeting 2.x.

For the edge case, I can use StringComparison.Ordinal instead.

Is it a known issue for just only 2.x? Could you help to share the issue or PR link or help docs?

@Kagamia-MS

the original issue https://github.com/dotnet/runtime/issues/1060.
Fixed by the PR https://github.com/dotnet/runtime/pull/31946 for 5.0 release.
Ported the fix to 3.1 by the PR https://github.com/dotnet/coreclr/pull/28014
Ported the fix to UWP by the PR https://github.com/dotnet/coreclr/pull/28015

Thanks for considering the workaround using Ordinal operation. Can we close this issue now? or is there anything else blocking you?

@tarekgh
Thank for your kind help, the issue could be closed.

Was this page helpful?
0 / 5 - 0 ratings