Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Conversation

@GrabYourPitchforks
Copy link
Member

Issue dotnet/runtime#1060 reports that in a linguistic (non-ordinal) call to string.Replace, if the target string contains code points with zero collation weight, the string.Replace logic can enter an infinite loop.

This has already been fixed in .NET 5 (see dotnet/runtime#31946). This PR ports that fix down to release/3.1.

Customer Impact

Infinite loop if calling string.Replace("<something-with-zero-collation-weight>", "...", StringComparison.<any-non-ordinal-comparison>). This has already impacted at least one first-party application, and they are requesting a backported fix for UWP.

Regression?

Not a regression. This overload of string.Replace is the only one affected, and it wasn't introduced until .NET Core 2.0. It appears to have very little usage outside of domain-specific scenarios, like text editors.

Testing

The .NET 5 fix at dotnet/runtime#31946 includes tests for the fix.

Risk

Low. A code path which previously went into an infinite loop now terminates successfully.

Code Reviewer

@tarekgh

When string.Replace is given a target string with zero collation weight, it would enter an infinite loop. It is now changed so that the call to Replace terminates when such a condition is encountered.
@GrabYourPitchforks GrabYourPitchforks added area-System.Runtime Servicing-consider Issue for next servicing release review labels Feb 12, 2020
@GrabYourPitchforks GrabYourPitchforks added this to the UWP 6.1.x milestone Feb 12, 2020
@MichalStrehovsky
Copy link
Member

Let me know if you need help with checking this into ProjectN TFS. I have an enlistment of the release branch.

@danmoseley
Copy link
Member

does this affect StringBuilder.Replace(..) btw?

@tarekgh
Copy link
Member

tarekgh commented Feb 18, 2020

does this affect StringBuilder.Replace(..) btw?

It shouldn't.

@GrabYourPitchforks
Copy link
Member Author

@MichalStrehovsky I'm not familiar with the process of porting changes in these branches. Do commits to this branch not automatically flow to ProjectN?

@MichalStrehovsky
Copy link
Member

@MichalStrehovsky I'm not familiar with the process of porting changes in these branches. Do commits to this branch not automatically flow to ProjectN?

Commits to this branch only affect CoreCLR. This would fix it for UWP in Debug builds (because that one uses CoreCLR), but Release/Store builds would stay broken.

There used to be a mirror for the master branch that went CoreCLR master -> CoreRT master that we then manually moved to CoreRT nmirror branch from which another mirror picked it up and placed it into Project N master in TFS, but all these mirrors are dead. This needs a direct checkin into TFS ProjectN release branch. I can help with that when it's ready.

@leecow leecow removed the Servicing-consider Issue for next servicing release review label Feb 25, 2020
@jashook
Copy link

jashook commented Mar 31, 2020

@GrabYourPitchforks what is the status of this?

@GrabYourPitchforks
Copy link
Member Author

@jashook The fix is already in .NET 5.0.

@asklar
Copy link

asklar commented Mar 31, 2020

@jashook The fix is already in .NET 5.0.

@jashook @GrabYourPitchforks we need this fix serviced to existing .net native framework packages

@GrabYourPitchforks
Copy link
Member Author

Sorry, misunderstood. I have some other servicing work I need to get to first, but I should be able to pick this up again next week.

@jashook
Copy link

jashook commented Apr 3, 2020

@asklar what versions are you referring to /cc @tommcdon

@asklar
Copy link

asklar commented Apr 3, 2020

@jashook @tommcdon I'll add you to the email thread

@jashook jashook merged commit 13e71f5 into dotnet:release/uwp6.2 Apr 17, 2020
@jashook
Copy link

jashook commented Apr 17, 2020

@GrabYourPitchforks merged, kicking off a build.

tommcdon added a commit to dotnet/corefx that referenced this pull request Aug 25, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants