-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Async iterator tests hang xunit on CoreCLR #29735
Copy link
Copy link
Closed
Labels
Description
I've temporarily marked the affected async-iterator tests as conditional (windows/desktop-only).
Below is one example, which involves exceptions being thrown. The strange thing is that adding a simple Console.Write("CAUGHT") call makes the problem go away.
Other than that, many (if not all) async iterators also hang on CoreCLR, despite not involving exceptions.
[Fact]
public void TestThrownException_WhilePromiseActive()
{
string source = @"
using static System.Console;
class C
{
public static async System.Threading.Tasks.Task Main()
{
var enumerator = new C().M().GetAsyncEnumerator();
await enumerator.WaitForNextAsync();
var value = enumerator.TryGetNext(out bool success);
Assert(success);
Assert(value == 42);
enumerator.TryGetNext(out success);
Assert(!success);
try
{
await enumerator.WaitForNextAsync();
Write(""UNREACHABLE"");
}
catch (System.Exception e)
{
Assert(e.Message == ""message"");
//Write($""CAUGHT""); // crash only happens if this line is commented out
}
Write(""Done"");
}
async System.Collections.Generic.IAsyncEnumerable<int> M()
{
yield return 42;
await new System.Threading.Tasks.ValueTask(System.Threading.Tasks.Task.Delay(100));
bool b = true;
if (b) throw new System.Exception(""message"");
Write(""UNREACHABLE2"");
}
static void Assert(bool b)
{
if (!b) throw null;
}
}";
var comp = CreateCompilationWithTasksExtensions(new[] { source, s_common }, options: TestOptions.DebugExe);
comp.VerifyDiagnostics();
CompileAndVerify(comp, expectedOutput: "Done");
}To run this test on CoreCLR:
"C:\Program Files\dotnet\dotnet.exe" exec --depsfile c:\repos\roslyn\Binaries\Debug\UnitTests\Microsoft.CodeAnalysis.CSharp.Emit.UnitTests\netcoreapp2.0\Microsoft.CodeAnalysis.CSharp.Emit.UnitTests.deps.json --runtimeconfig c:\repos\roslyn\Binaries\Debug\UnitTests\Microsoft.CodeAnalysis.CSharp.Emit.UnitTests\netcoreapp2.0\Microsoft.CodeAnalysis.CSharp.Emit.UnitTests.runtimeconfig.json C:\Users\dumky\.nuget\packages\xunit.runner.console\2.3.1\tools\netcoreapp2.0\xunit.console.dll c:\repos\roslyn\Binaries\Debug\UnitTests\Microsoft.CodeAnalysis.CSharp.Emit.UnitTests\netcoreapp2.0\Microsoft.CodeAnalysis.CSharp.Emit.UnitTests.dll -xml c:\repos\roslyn\Binaries\Debug\UnitTests\xUnitResults\Microsoft.CodeAnalysis.CSharp.Emit.UnitTests.xml -parallel none -method Microsoft.CodeAnalysis.CSharp.UnitTests.CodeGen.CodeGenAsyncIteratorTests.TestThrownException_WhilePromiseActive
Relates to PR #28218
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Type
Fields
Give feedbackNo fields configured for issues without a type.