aspnetcore
aspnetcore copied to clipboard
ArgumentOutOfRangeException in ValueTaskSourceAsTask
Failing Test(s)
- Templates.Test.BlazorWasmTemplateTest.BlazorWasmHostedTemplate_AzureActiveDirectoryTemplate_Works
I have not quarantined this test because the error so strange that I can't tell if it's related to a specific test.
Error Message
StdErr: Unhandled exception. System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values. (Parameter 'state')
Stacktrace
at System.Threading.Tasks.ValueTask`1.ValueTaskSourceAsTask.<>c.<.cctor>b__4_0(Object state)
at System.Threading.ThreadPoolWorkQueue.Dispatch()
at System.Threading.PortableThreadPool.WorkerThread.WorkerThreadStart()
at System.Threading.Thread.StartCallback()
Logs
[0.004s] [TestLifetime] [Information] Starting test BlazorWasmHostedTemplate_AzureActiveDirectoryTemplate_Works-Templates.Test.BlazorWasmTemplateTest+TemplateInstance at 2021-10-01T12:50:11
[0.686s] [Templates.Test.BlazorWasmTemplateTest] [Information] Acquired DotNetNewLock
[0.686s] [Templates.Test.BlazorWasmTemplateTest] [Information] Released DotNetNewLock
[0.686s] [Templates.Test.BlazorWasmTemplateTest] [Information] Acquired DotNetNewLock
[0.688s] [Templates.Test.BlazorWasmTemplateTest] [Information] ==> D:\h\w\A550096E\p\dotnet-cli\dotnet.exe new blazorwasm --debug:disable-sdk-templates --debug:custom-hive "D:\h\w\A550096E\w\A599095C\e\Hives\.templateEngine" -ho -au SingleOrg --calls-graph --domain my-domain --tenant-id tenantId --client-id clientId --default-scope full --app-id-uri ApiUri --api-client-id 1234123413241324 -o D:\h\w\A550096E\w\A599095C\e\Templates\BaseFolder\AspNet.r24o0bqicpa [D:\h\w\A550096E\w\A599095C\e\]
[3.479s] [Templates.Test.BlazorWasmTemplateTest] [Information] The template "Blazor WebAssembly App" was created successfully.
[3.479s] [Templates.Test.BlazorWasmTemplateTest] [Information] This template contains technologies from parties other than Microsoft, see https://aka.ms/aspnetcore/6.0-third-party-notices for details.
[3.479s] [Templates.Test.BlazorWasmTemplateTest] [Information]
[3.480s] [Templates.Test.BlazorWasmTemplateTest] [Information] Processing post-creation actions...
[3.480s] [Templates.Test.BlazorWasmTemplateTest] [Information] Running 'dotnet restore' on D:\h\w\A550096E\w\A599095C\e\Templates\BaseFolder\AspNet.r24o0bqicpa\AspNet.r24o0bqicpa.sln...
[4.568s] [Templates.Test.BlazorWasmTemplateTest] [Information] Determining projects to restore...
[5.312s] [Templates.Test.BlazorWasmTemplateTest] [Information] Restored D:\h\w\A550096E\w\A599095C\e\Templates\BaseFolder\AspNet.r24o0bqicpa\Shared\AspNet.r24o0bqicpa.Shared.csproj (in 246 ms).
[5.675s] [Templates.Test.BlazorWasmTemplateTest] [Information] Restored D:\h\w\A550096E\w\A599095C\e\Templates\BaseFolder\AspNet.r24o0bqicpa\Client\AspNet.r24o0bqicpa.Client.csproj (in 651 ms).
[10.510s] [Templates.Test.BlazorWasmTemplateTest] [Information] Restored D:\h\w\A550096E\w\A599095C\e\Templates\BaseFolder\AspNet.r24o0bqicpa\Server\AspNet.r24o0bqicpa.Server.csproj (in 5.47 sec).
[10.541s] [Templates.Test.BlazorWasmTemplateTest] [Information] Restore succeeded.
[10.542s] [Templates.Test.BlazorWasmTemplateTest] [Information]
[10.604s] [Templates.Test.BlazorWasmTemplateTest] [Information] Process exited.
[10.604s] [Templates.Test.BlazorWasmTemplateTest] [Information] Released DotNetNewLock
[10.604s] [Templates.Test.BlazorWasmTemplateTest] [Information] Publishing ASP.NET Core application...
[10.605s] [Templates.Test.BlazorWasmTemplateTest] [Information] ==> D:\h\w\A550096E\p\dotnet-cli\dotnet.exe publish -c Release /bl [D:\h\w\A550096E\w\A599095C\e\Templates\BaseFolder\AspNet.r24o0bqicpa]
[10.919s] [Templates.Test.BlazorWasmTemplateTest] [Information] Microsoft (R) Build Engine version 17.0.0-preview-21427-02+414393fc1 for .NET
[10.919s] [Templates.Test.BlazorWasmTemplateTest] [Information] Copyright (C) Microsoft Corporation. All rights reserved.
[10.919s] [Templates.Test.BlazorWasmTemplateTest] [Information]
[10.929s] [Templates.Test.BlazorWasmTemplateTest] [Information] D:\h\w\A550096E\p\dotnet-cli\sdk\7.0.100-alpha.1.21474.3\MSBuild.dll -maxcpucount -property:Configuration=Release -restore -target:Publish -verbosity:m /bl .\AspNet.r24o0bqicpa.sln
[12.115s] [Templates.Test.BlazorWasmTemplateTest] [Information] Determining projects to restore...
[12.864s] [Templates.Test.BlazorWasmTemplateTest] [Information] All projects are up-to-date for restore.
[13.047s] [Templates.Test.BlazorWasmTemplateTest] [Information] You are using a preview version of .NET. See: https://aka.ms/dotnet-core-preview
[13.055s] [Templates.Test.BlazorWasmTemplateTest] [Information] You are using a preview version of .NET. See: https://aka.ms/dotnet-core-preview
[13.323s] [Templates.Test.BlazorWasmTemplateTest] [Information] You are using a preview version of .NET. See: https://aka.ms/dotnet-core-preview
[15.344s] [Templates.Test.BlazorWasmTemplateTest] [Information] AspNet.r24o0bqicpa.Shared -> D:\h\w\A550096E\w\A599095C\e\Templates\BaseFolder\AspNet.r24o0bqicpa\Shared\bin\Release\net7.0\AspNet.r24o0bqicpa.Shared.dll
[15.369s] [Templates.Test.BlazorWasmTemplateTest] [Information] AspNet.r24o0bqicpa.Shared -> D:\h\w\A550096E\w\A599095C\e\Templates\BaseFolder\AspNet.r24o0bqicpa\Shared\bin\Release\net7.0\publish\
[15.554s] [Templates.Test.BlazorWasmTemplateTest] [Information] [ERROR] Unhandled exception. System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values. (Parameter 'state')
[15.554s] [Templates.Test.BlazorWasmTemplateTest] [Information] [ERROR] at System.Threading.Tasks.ValueTask`1.ValueTaskSourceAsTask.<>c.<.cctor>b__4_0(Object state)
[15.554s] [Templates.Test.BlazorWasmTemplateTest] [Information] [ERROR] at System.Threading.ThreadPoolWorkQueue.Dispatch()
[15.554s] [Templates.Test.BlazorWasmTemplateTest] [Information] [ERROR] at System.Threading.PortableThreadPool.WorkerThread.WorkerThreadStart()
[15.554s] [Templates.Test.BlazorWasmTemplateTest] [Information] [ERROR] at System.Threading.Thread.StartCallback()
[17.749s] [Templates.Test.BlazorWasmTemplateTest] [Information] Process exited.
[17.840s] [Templates.Test.BlazorWasmTemplateTest] [Error] Test threw an exception.
Xunit.Sdk.TrueException: Project new blazorwasm -ho -au SingleOrg --calls-graph --domain my-domain --tenant-id tenantId --client-id clientId --default-scope full --app-id-uri ApiUri --api-client-id 1234123413241324 failed to publish. Exit code -532462766.
D:\h\w\A550096E\p\dotnet-cli\dotnet.exe publish -c Release /bl \nStdErr: Unhandled exception. System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values. (Parameter 'state')
at System.Threading.Tasks.ValueTask`1.ValueTaskSourceAsTask.<>c.<.cctor>b__4_0(Object state)
at System.Threading.ThreadPoolWorkQueue.Dispatch()
at System.Threading.PortableThreadPool.WorkerThread.WorkerThreadStart()
at System.Threading.Thread.StartCallback()
\nStdOut: Microsoft (R) Build Engine version 17.0.0-preview-21427-02+414393fc1 for .NET
Copyright (C) Microsoft Corporation. All rights reserved.
D:\h\w\A550096E\p\dotnet-cli\sdk\7.0.100-alpha.1.21474.3\MSBuild.dll -maxcpucount -property:Configuration=Release -restore -target:Publish -verbosity:m /bl .\AspNet.r24o0bqicpa.sln
Determining projects to restore...
All projects are up-to-date for restore.
You are using a preview version of .NET. See: https://aka.ms/dotnet-core-preview
You are using a preview version of .NET. See: https://aka.ms/dotnet-core-preview
You are using a preview version of .NET. See: https://aka.ms/dotnet-core-preview
AspNet.r24o0bqicpa.Shared -> D:\h\w\A550096E\w\A599095C\e\Templates\BaseFolder\AspNet.r24o0bqicpa\Shared\bin\Release\net7.0\AspNet.r24o0bqicpa.Shared.dll
AspNet.r24o0bqicpa.Shared -> D:\h\w\A550096E\w\A599095C\e\Templates\BaseFolder\AspNet.r24o0bqicpa\Shared\bin\Release\net7.0\publish\
Expected: True
Actual: False
at Xunit.Assert.True(Nullable`1 condition, String userMessage) in C:\Dev\xunit\xunit\src\xunit.assert\Asserts\BooleanAsserts.cs:line 95
at Templates.Test.BlazorTemplateTest.CreateBuildPublishAsync(String projectName, String auth, String[] args, String targetFramework, Boolean serverProject, Boolean onlyCreate) in /_/src/ProjectTemplates/test/BlazorTemplateTest.cs:line 67
at Xunit.Sdk.TestInvoker`1.<>c__DisplayClass48_1.<<InvokeTestMethodAsync>b__1>d.MoveNext() in C:\Dev\xunit\xunit\src\xunit.execution\Sdk\Frameworks\Runners\TestInvoker.cs:line 273
--- End of stack trace from previous location ---
at Xunit.Sdk.ExecutionTimer.AggregateAsync(Func`1 asyncAction) in C:\Dev\xunit\xunit\src\xunit.execution\Sdk\Frameworks\ExecutionTimer.cs:line 54
at Xunit.Sdk.ExceptionAggregator.RunAsync(Func`1 code) in C:\Dev\xunit\xunit\src\xunit.core\Sdk\ExceptionAggregator.cs:line 96
[17.840s] [TestLifetime] [Information] Finished test BlazorWasmHostedTemplate_AzureActiveDirectoryTemplate_Works-Templates.Test.BlazorWasmTemplateTest+TemplateInstance in 17.8368448s
Build
https://dev.azure.com/dnceng/public/_build/results?buildId=1397715
Does this mean we're doing something really bad?
cc @stephentoub
Yes. That error comes from here: https://github.com/dotnet/runtime/blob/main/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/ValueTask.cs#L237-L245
But how do we find it? The stack trace won't help here.
Maybe the analyzer, this is likely a double await of a ValueTask
But how do we find it? The stack trace won't help here.
We can see from the logs that the error is coming from dotnet publish, so we can start with the dotnet CLI and NuGet?
Maybe the analyzer
And maybe try to enforce the usage of the analyzer across our repos.
I did a search for uses of ValueTask in
- SDK: https://github.com/dotnet/sdk/search?p=2&q=ValueTask - All of these are in dotnet-watch, one of which trips the code analysis rule
- NuGet: No instances of it in https://github.com/NuGet/NuGet.Client/tree/dev/src/NuGet.Core
- MSBuild: https://github.com/dotnet/msbuild/search?p=2&q=ValueTask
- Trimmer: https://github.com/dotnet/linker/search?q=ValueTask
- And Xunit: https://github.com/dotnet/linker/search?q=ValueTask
Razor's compiler should be covered by this repo (and also doesn't use ValueTasks). Any guesses what else could be contributing to this?
Another hit: https://dev.azure.com/dnceng/public/_build/results?buildId=1457287 Templates.Test.BlazorWasmTemplateTest.BlazorWasmHostedPwaTemplateCanCreateBuildPublish
Project failed to publish. Exit code -532462766.
D:hwA9820950pdotnet-clidotnet.exe publish -c Release /bl
StdErr: Unhandled exception. System.ArgumentOutOfRangeExceptio
[Templates.Test.BlazorWasmTemplateTest_BlazorWasmHostedPwaTemplateCanCreateBuildPublish.log](https://github.com/dotnet/aspnetcore/files/7498654/Templates.Test.BlazorWasmTemplateTest_BlazorWasmHostedPwaTemplateCanCreateBuildPublish.log)
n: Specified argument was out of the range of valid values. (Parameter 'state')
at System.Threading.Tasks.ValueTask`1.ValueTaskSourceAsTask.<>c.<.cctor>b__4_0(Object state)
at System.Threading.ThreadPoolWorkQueue.Dispatch()
at System.Threading.PortableThreadPool.WorkerThread.WorkerThreadStart()
StdOut: Microsoft (R) Build Engine version 17.1.0-preview-21551-01+15da3c475 for .NET
Copyright (C) Microsoft Corporation. All rights reserved.
D:hwA9820950pdotnet-clisdk7.0.100-alpha.1.21551.3MSBuild.dll -maxcpucount -property:Configuration=Release -restore -target:Publish -verbosity:m /bl .AspNet.uvsozotlhpk.Server.csproj
Determining projects to restore...
All projects are up-to-date for restore.
You are using a preview version of .NET. See: https://aka.ms/dotnet-core-preview
You are using a preview version of .NET. See: https://aka.ms/dotnet-core-preview
AspNet.uvsozotlhpk.Shared -> D:hwA9820950wAF730958eTemplatesBaseFolderAspNet.uvsozotlhpkSharedinRelease
et7.0AspNet.uvsozotlhpk.Shared.dll
AspNet.uvsozotlhpk.Client -> D:hwA9820950wAF730958eTemplatesBaseFolderAspNet.uvsozotlhpkClientinRelease
et7.0AspNet.uvsozotlhpk.Client.dll
AspNet.uvsozotlhpk.Client (Blazor output) -> D:hwA9820950wAF730958eTemplatesBaseFolderAspNet.uvsozotlhpkClientinRelease
et7.0wwwroot
AspNet.uvsozotlhpk.Server -> D:hwA9820950wAF730958eTemplatesBaseFolderAspNet.uvsozotlhpkServerinRelease
et7.0AspNet.uvsozotlhpk.Server.dll
Expected: True
Actual: False
@stephentoub both of these failures occurred on ARM64. Does that ring a bell in any form, particularly around launching processes? I was planning to set up a ARM VM and see if I'm able to reproduce this issue because I'm having a hard time finding of ValueTask at all, let alone uses that would trigger the analyzer.
both of these failures occurred on ARM64. Does that ring a bell in any form
It doesn't, but there are differences between the architectures that are much more common to manifest when it comes to synchronization due to it having a weaker memory model. For example, since volatile evaporates in the JIT when building for x86 but results in memory barriers on ARM, a missing necessary volatile would be more likely to result in problems on ARM.
Thanks for contacting us.
We're moving this issue to the .NET 7 Planning milestone for future evaluation / consideration. We would like to keep this around to collect more feedback, which can help us with prioritizing this work. We will re-evaluate this issue, during our next planning meeting(s).
If we later determine, that the issue has no community involvement, or it's very rare and low-impact issue, we will close it - so that the team can focus on more important and high impact issues.
To learn more about what to expect next and how this issue will be handled you can read more about our triage process here.
I have been looking at our test code, and unfortunately this was happening inside the process that we launched, so I do not think we can take any action here. If we see newer instances of this issue, we will reopen.