From bd0d278b5ccfbd7a6b50f6d462d838d6eaeaa00f Mon Sep 17 00:00:00 2001 From: "Tomas Rylek (from Dev Box)" Date: Fri, 4 Aug 2023 02:23:25 +0200 Subject: [PATCH 1/4] Remove spurious assertion check causing .NET Core crashes I started this investigation based on heads-up from Rich Lander who hit the issue in a PR run. Thanks to help from Jan Vorlicek I have been able to repro the issue and I discussed it with Tanner Gooding who proposed this fix - removing the superfluous assertion check duplicating an upfront check in the method NarrowUtf16ToAscii before calling into the intrinsified version. I sincerely admit I'm not an expert in the field of instruction set extensions and I have driven this investigation mostly because David Wrighton is OOF on parental leave for the entire month of August so I'm trying to make sure we ship .NET 8 in the best possible quality; I'll be more than happy for any suggestions for improvements or any other feedback. Thanks Tomas --- .../System.Private.CoreLib/src/System/Text/Ascii.Utility.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/libraries/System.Private.CoreLib/src/System/Text/Ascii.Utility.cs b/src/libraries/System.Private.CoreLib/src/System/Text/Ascii.Utility.cs index 45b73be6a618d2..fc3aaa2b6b27e2 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Text/Ascii.Utility.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Text/Ascii.Utility.cs @@ -2142,7 +2142,6 @@ private static unsafe nuint NarrowUtf16ToAscii_Intrinsified_256(char* pUtf16Buff // jumps as much as possible in the optimistic case of "all ASCII". If we see non-ASCII // data, we jump out of the hot paths to targets at the end of the method. - Debug.Assert(Vector256.IsHardwareAccelerated, "Vector256 is required."); Debug.Assert(BitConverter.IsLittleEndian, "This implementation assumes little-endian."); Debug.Assert(elementCount >= 2 * Vector256.Size); From 471781e21a6bfc6df0a605b30a5481ec46ac0b63 Mon Sep 17 00:00:00 2001 From: Aaron Robinson Date: Wed, 9 Aug 2023 11:36:50 -0700 Subject: [PATCH 2/4] Update src/libraries/System.Private.CoreLib/src/System/Text/Ascii.Utility.cs --- .../System.Private.CoreLib/src/System/Text/Ascii.Utility.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libraries/System.Private.CoreLib/src/System/Text/Ascii.Utility.cs b/src/libraries/System.Private.CoreLib/src/System/Text/Ascii.Utility.cs index fc3aaa2b6b27e2..64554fc3bc2017 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Text/Ascii.Utility.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Text/Ascii.Utility.cs @@ -2142,6 +2142,7 @@ private static unsafe nuint NarrowUtf16ToAscii_Intrinsified_256(char* pUtf16Buff // jumps as much as possible in the optimistic case of "all ASCII". If we see non-ASCII // data, we jump out of the hot paths to targets at the end of the method. + // Debug.Assert(Vector256.IsHardwareAccelerated, "Vector256 is required."); Debug.Assert(BitConverter.IsLittleEndian, "This implementation assumes little-endian."); Debug.Assert(elementCount >= 2 * Vector256.Size); From 52ecaf2e61759a99cd25546aaa8306641882dea8 Mon Sep 17 00:00:00 2001 From: Aaron Robinson Date: Wed, 9 Aug 2023 11:37:38 -0700 Subject: [PATCH 3/4] Update src/libraries/System.Private.CoreLib/src/System/Text/Ascii.Utility.cs --- .../System.Private.CoreLib/src/System/Text/Ascii.Utility.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libraries/System.Private.CoreLib/src/System/Text/Ascii.Utility.cs b/src/libraries/System.Private.CoreLib/src/System/Text/Ascii.Utility.cs index 64554fc3bc2017..bb62909b1fc7d8 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Text/Ascii.Utility.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Text/Ascii.Utility.cs @@ -2142,7 +2142,7 @@ private static unsafe nuint NarrowUtf16ToAscii_Intrinsified_256(char* pUtf16Buff // jumps as much as possible in the optimistic case of "all ASCII". If we see non-ASCII // data, we jump out of the hot paths to targets at the end of the method. - // Debug.Assert(Vector256.IsHardwareAccelerated, "Vector256 is required."); + // Debug.Assert(Vector256.IsHardwareAccelerated, "Vector256 is required."); Debug.Assert(BitConverter.IsLittleEndian, "This implementation assumes little-endian."); Debug.Assert(elementCount >= 2 * Vector256.Size); From 8b0781743961d2b87ba858e80bfad0924fb947bd Mon Sep 17 00:00:00 2001 From: Aaron Robinson Date: Wed, 9 Aug 2023 11:50:19 -0700 Subject: [PATCH 4/4] Update src/libraries/System.Private.CoreLib/src/System/Text/Ascii.Utility.cs Co-authored-by: Jan Kotas --- .../System.Private.CoreLib/src/System/Text/Ascii.Utility.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libraries/System.Private.CoreLib/src/System/Text/Ascii.Utility.cs b/src/libraries/System.Private.CoreLib/src/System/Text/Ascii.Utility.cs index bb62909b1fc7d8..56c8ead9081409 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Text/Ascii.Utility.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Text/Ascii.Utility.cs @@ -2142,6 +2142,7 @@ private static unsafe nuint NarrowUtf16ToAscii_Intrinsified_256(char* pUtf16Buff // jumps as much as possible in the optimistic case of "all ASCII". If we see non-ASCII // data, we jump out of the hot paths to targets at the end of the method. + // Commented out to workaround https://github.com/dotnet/runtime/issues/90265 // Debug.Assert(Vector256.IsHardwareAccelerated, "Vector256 is required."); Debug.Assert(BitConverter.IsLittleEndian, "This implementation assumes little-endian."); Debug.Assert(elementCount >= 2 * Vector256.Size);