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>).

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 3.1.x milestone Feb 12, 2020
@wtgodbe
Copy link
Member

wtgodbe commented Feb 18, 2020

@GrabYourPitchforks is this for 3.1.3? If so please merge by EOD today (with green CI). CC @danmosemsft

@wtgodbe
Copy link
Member

wtgodbe commented Feb 18, 2020

Also CC @jeffschwMSFT

@leecow leecow added Servicing-approved Approved for servicing release and removed Servicing-consider Issue for next servicing release review labels Feb 18, 2020
@leecow leecow modified the milestones: 3.1.x, 3.1.3 Feb 18, 2020
@danmoseley
Copy link
Member

Yes, it should go into 3.1.3 today.

@danmoseley
Copy link
Member

@GrabYourPitchforks I didn't find a matching corefx PR porting the tests. Please can you throw up a PR today for those - you can mark it with the same labels/milestone as this one and @Anipik can merge it.

@danmoseley
Copy link
Member

If so please merge by EOD today (with green CI).

@wtgodbe generally @Anipik has done all the merges for us -- it's more efficient as that way nobody has to ask when the branch is open. In this case, it is open though :)

@GrabYourPitchforks
Copy link
Member Author

Unit tests at dotnet/corefx#42862

@GrabYourPitchforks
Copy link
Member Author

Looks like there are some R2R test failures. I don't believe they're related to this PR since I'm not touching any JIT code paths.

@Anipik
Copy link

Anipik commented Feb 18, 2020

Merging this change as failures are unrelated to this.

@Anipik Anipik merged commit b4b4098 into dotnet:release/3.1 Feb 18, 2020
wtgodbe pushed a commit to dotnet/corefx that referenced this pull request Feb 19, 2020
@GrabYourPitchforks GrabYourPitchforks deleted the str_replace_31 branch February 21, 2020 05:05
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-System.Runtime Servicing-approved Approved for servicing release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants