Skip to content

Unskip NestedCatch_DuplicateLocal_NoAwaitInNestedCatch #132017

Description

@JoeRobich

In the move from running against .NET 10 to .NET 11 preview, the following async runtime test failure was encountered:

CodeGenAsyncEHTests.NestedCatch_DuplicateLocal_NoAwaitInNestedCatch(awaitInTry2: True)

Expected:
F: M1-catch1
F: M1-catch2
M2: M1-catch2-catch M1
--- catch first ---
F: M1-catch1
M2: M1-catch1 M1
Actual:
F: M1-catch1
F: M1-catch2
--- catch first ---
F: M1-catch1
M2: M1-catch1 M1



Stack trace
   at Roslyn.Test.Utilities.AssertEx.Equal(String expected, String actual) in /_/src/Compilers/Test/Core/Assert/AssertEx.cs:line 219
   at Microsoft.CodeAnalysis.Test.Utilities.CompilationVerifier.EmitAndVerify(String expectedOutput, Boolean trimOutput, Nullable`1 expectedReturnCode, String[] args, IEnumerable`1 manifestResources, EmitOptions emitOptions, Verification peVerify, SignatureDescription[] expectedSignatures) in /_/src/Compilers/Test/Core/CompilationVerifier.cs:line 400
   at Microsoft.CodeAnalysis.Test.Utilities.CommonTestBase.Emit(Compilation compilation, IEnumerable`1 dependencies, IEnumerable`1 manifestResources, SignatureDescription[] expectedSignatures, String expectedOutput, Boolean trimOutput, Nullable`1 expectedReturnCode, String[] args, Action`1 assemblyValidator, Action`1 symbolValidator, EmitOptions emitOptions, Verification verify) in /_/src/Compilers/Test/Core/CommonTestBase.cs:line 190
   at Microsoft.CodeAnalysis.Test.Utilities.CommonTestBase.CompileAndVerifyCommon(Compilation compilation, IEnumerable`1 manifestResources, IEnumerable`1 dependencies, Action`1 sourceSymbolValidator, Action`1 assemblyValidator, Action`1 symbolValidator, SignatureDescription[] expectedSignatures, String expectedOutput, Boolean trimOutput, Nullable`1 expectedReturnCode, String[] args, EmitOptions emitOptions, Verification verify) in /_/src/Compilers/Test/Core/CommonTestBase.cs:line 101
   at Microsoft.CodeAnalysis.CSharp.Test.Utilities.CSharpTestBase.CompileAndVerify(Compilation compilation, IEnumerable`1 manifestResources, IEnumerable`1 dependencies, Action`1 sourceSymbolValidator, Action`1 validator, Action`1 symbolValidator, SignatureDescription[] expectedSignatures, String expectedOutput, Boolean trimOutput, Nullable`1 expectedReturnCode, String[] args, EmitOptions emitOptions, Verification verify) in /_/src/Compilers/Test/Utilities/CSharp/CSharpTestBase.cs:line 1634
   at Microsoft.CodeAnalysis.CSharp.UnitTests.CodeGen.CodeGenAsyncEHTests.NestedCatch_DuplicateLocal_NoAwaitInNestedCatch(Boolean awaitInTry2) in /_/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenAsyncEHTests.cs:line 3856
   at System.RuntimeMethodHandle.InvokeMethod(ObjectHandleOnStack target, Void** arguments, ObjectHandleOnStack sig, BOOL isConstructor, ObjectHandleOnStack result)
   at System.Reflection.MethodBaseInvoker.InvokeDirectByRefWithFewArgs(Object obj, Span`1 copyOfArgs, BindingFlags invokeAttr)

Activity

  1. added theissue type on Aug 7, 2026
  2. 333fred commented on Aug 7, 2026

    @333fred
    Member

    This appears to be a runtime-async bug in .NET 11 Preview 6. I reduced the test to the following file-based app:

    #:property Features=runtime-async=on
    #:property LangVersion=preview
    #:property Optimize=true
    #:property NoWarn=SYSLIB5007;CA2252
    
    using System;
    using System.Threading.Tasks;
    
    Test.Run();
    
    class Test
    {
        static int calls;
    
        public static void Run()
        {
            var test = new Test();
            test.M(false).GetAwaiter().GetResult();
            test.M(true).GetAwaiter().GetResult();
    
            if (calls != 2)
                throw new Exception($"Expected 2 calls, got {calls}");
        }
    
        static bool Filter(bool result)
        {
            Console.WriteLine("filter");
            return result;
        }
    
        async Task M(bool first)
        {
            try
            {
                throw new Exception("outer");
            }
            catch (Exception ex) when (Filter(first))
            {
                await Print(ex);
            }
            catch (Exception ex) when (Filter(true))
            {
                try
                {
                    await Task.Yield();
                    throw new Exception();
                }
                catch
                {
                    _ = Print(ex);
                }
            }
        }
    
        static async Task Print(Exception ex)
        {
            var message = ex.Message;
            Console.WriteLine(message);
            await Task.Yield();
            calls++;
        }
    }

    With global.json pinned to SDK 10.0.301, this exits successfully:

    $ DOTNET_RuntimeAsync=1 dotnet run 84787.cs
    filter
    filter
    outer
    filter
    outer

    With global.json pinned to SDK 11.0.100-preview.6.26359.118, the same command fails because only one Print continuation completes:

    $ dotnet run 84787.cs
    filter
    filter
    filter
    outer
    Unhandled exception. System.Exception: Expected 2 calls, got 1

    This comment was generated by AI.

  3. transferred this issue fromdotnet/roslynon Aug 7, 2026
  4. added
    area-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI
    on Aug 7, 2026
  5. dotnet-policy-service commented on Aug 7, 2026

    @dotnet-policy-service
    Contributor

    Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch
    See info in area-owners.md if you want to be subscribed.

  6. removed
    untriagedNew issue has not been triaged by the area owner
    on Aug 10, 2026
  7. added this to the 11.0.0 milestone on Aug 10, 2026
  8. locked and limited conversation to collaborators on Sep 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions