From 92edcbb8a32a1daeb7b167cd5aaf0ea0d259b633 Mon Sep 17 00:00:00 2001 From: Larry Ewing Date: Sat, 28 Feb 2026 20:36:04 -0600 Subject: [PATCH] Skip NonBacktracking deep nesting test on browser-wasm The CharClassSubtraction_DeepNesting_DoesNotStackOverflow test with the NonBacktracking engine hits threading APIs (Task.InternalWaitCore) that are not supported on single-threaded browser-wasm, causing PlatformNotSupportedException. Other engines work fine on browser-wasm. Use an in-test guard to skip only the NonBacktracking engine variant on Browser, keeping Interpreter and Compiled coverage. Fixes #125020 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../tests/FunctionalTests/Regex.Match.Tests.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/libraries/System.Text.RegularExpressions/tests/FunctionalTests/Regex.Match.Tests.cs b/src/libraries/System.Text.RegularExpressions/tests/FunctionalTests/Regex.Match.Tests.cs index 19b3bfb4249ad8..c168ed04c54396 100644 --- a/src/libraries/System.Text.RegularExpressions/tests/FunctionalTests/Regex.Match.Tests.cs +++ b/src/libraries/System.Text.RegularExpressions/tests/FunctionalTests/Regex.Match.Tests.cs @@ -2637,11 +2637,16 @@ public async Task StressTestDeepNestingOfLoops(RegexEngine engine, string begin, } } - [Theory] + [ConditionalTheory] [SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework, "Fix is not available on .NET Framework")] [MemberData(nameof(RegexHelpers.AvailableEngines_MemberData), MemberType = typeof(RegexHelpers))] public async Task CharClassSubtraction_DeepNesting_DoesNotStackOverflow(RegexEngine engine) { + if (RegexHelpers.IsNonBacktracking(engine) && !PlatformDetection.IsMultithreadingSupported) + { + throw new SkipTestException("Deep nesting with NonBacktracking hits threading APIs not supported on single-threaded WASM."); + } + // Build a pattern with deeply nested character class subtractions: [a-[a-[a-[...[a]...]]]] // This previously caused a StackOverflowException due to unbounded recursion in the parser. // Use a reduced depth for SourceGenerated to avoid overwhelming Roslyn compilation.