Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WINARM][Regression] Fail to run the command – & “C:\Program Files (x86)\dotnet\dotnet.exe" test --framework net7.0 --diag:loga.txt #71098

Closed
WenJunJi01 opened this issue Jun 15, 2022 · 21 comments
Assignees
Milestone

Comments

@WenJunJi01
Copy link
Member

Note:
1.It’s regression issue. It doesn’t repro on dotnet-sdk-7.0.100-preview.5.22225.1-win-arm64.
2. Repro VM: vsengarmsfx041

Builds info:
dotnet-runtime-3.1.26-win-x64
dotnet-sdk-6.0.400-preview.22314.17-win-x64
dotnet-sdk-7.0.100-preview.6.22314.18-win-arm64
dotnet-sdk-7.0.100-preview.6.22314.18-win-x64
dotnet-sdk-7.0.100-preview.6.22314.18-win-x86

Build Link:
https://aka.ms/dotnet/7.0.1xx/daily/dotnet-sdk-win-arm64.exe
https://aka.ms/dotnet/7.0.1xx/daily/dotnet-sdk-win-x64.exe
https://aka.ms/dotnet/7.0.1xx/daily/dotnet-sdk-win-x86.exe
https://aka.ms/dotnet/6.0.4xx/daily/dotnet-sdk-win-x64.exe
https://dotnet.microsoft.com/en-us/download/dotnet/thank-you/runtime-3.1.26-windows-x64-installer

Steps:
Execute the following commands by Powershell:

  1. $env:DOTNET_MULTILEVEL_LOOKUP=0
  2. ls env:
  3. dotnet new mstest
  4. Update file UnitTest1.cs with
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Collections;
using System.Diagnostics;
using System.Text;
 
namespace CreateScenarioForVendors
{
    [TestClass]
    public class UnitTest1
    {
        [TestMethod]
        public void TestMethod1()
        {
            StringBuilder builder = new StringBuilder();
 
            builder.AppendLine();
            builder.AppendLine();
            foreach (DictionaryEntry var in Environment.GetEnvironmentVariables())
            {
                if(var.Key.ToString().StartsWith("DOTNET_"))
                {
                    builder.AppendLine($"{var.Key.ToString()} {var.Value}");
                }
            }
            builder.AppendLine();
            builder.AppendLine();
            builder.AppendLine($"ProcessArchitecture {System.Runtime.InteropServices.RuntimeInformation.ProcessArchitecture.ToString()}");
            builder.AppendLine($"Location {typeof(object).Assembly.Location}");
            builder.AppendLine($"Process name {Process.GetCurrentProcess().Modules[0].FileName}");
 
            throw new Exception(builder.ToString());
        }
    }
}

Update the project file in in this way

<Project Sdk="Microsoft.NET.Sdk">
 
  <PropertyGroup>
    <TargetFrameworks>net7.0;netcoreapp3.1</TargetFrameworks>
    <IsPackable>false</IsPackable>
  <LangVersion>latest</LangVersion>
  </PropertyGroup>
 
  <ItemGroup>
    <PackageReference Include="Microsoft.NET.Test.Sdk" Version=" 17.1.0-preview-20211130-02" />
    <PackageReference Include="MSTest.TestAdapter" Version="2.2.7" />
    <PackageReference Include="MSTest.TestFramework" Version="2.2.7" />
    <PackageReference Include="coverlet.collector" Version="3.1.0" />
  </ItemGroup>
 
</Project>
  1. dotnet test --framework net7.0 --diag:loga.txt
  2. &"C:\Program Files (x86)\dotnet\dotnet.exe" test --framework net7.0 --diag:logna.txt

Expected Result:
The command should be run normally as following:
image

Actual Results:
Fail to run the command – & “C:\Program Files (x86)\dotnet\dotnet.exe" test --framework net7.0 --diag:logna.txt
image

--Log:

PS C:\Users\v-wenjj\Desktop\mstest> dotnet test --framework net7.0 --diag:loga.txt
  Determining projects to restore...
  All projects are up-to-date for restore.
C:\Program Files\dotnet\sdk\7.0.100-preview.6.22314.18\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.RuntimeIdentifierIn
ference.targets(219,5): message NETSDK1057: You are using a preview version of .NET. See: https://aka.ms/dotnet-support
-policy [C:\Users\v-wenjj\Desktop\mstest\mstest.csproj]
  mstest -> C:\Users\v-wenjj\Desktop\mstest\bin\Debug\net7.0\mstest.dll
Test run for C:\Users\v-wenjj\Desktop\mstest\bin\Debug\net7.0\mstest.dll (.NETCoreApp,Version=v7.0)
Microsoft (R) Test Execution Command Line Tool Version 17.3.0-preview-20220610-03 (arm64)
Copyright (c) Microsoft Corporation.  All rights reserved.

Starting test execution, please wait...
Logging Vstest Diagnostics in file: C:\Users\v-wenjj\Desktop\mstest\loga.txt
A total of 1 test files matched the specified pattern.
  Failed TestMethod1 [36 ms]
  Error Message:
   Test method CreateScenarioForVendors.UnitTest1.TestMethod1 threw exception:
System.Exception:

DOTNET_HOST_PATH C:\Program Files\dotnet\dotnet.exe
DOTNET_MULTILEVEL_LOOKUP 0


ProcessArchitecture Arm64
Location C:\Program Files\dotnet\shared\Microsoft.NETCore.App\7.0.0-preview.6.22312.1\System.Private.CoreLib.dll
Process name C:\Program Files\dotnet\dotnet.exe

  Stack Trace:
      at CreateScenarioForVendors.UnitTest1.TestMethod1() in C:\Users\v-wenjj\Desktop\mstest\UnitTest1.cs:line 32
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
   at System.Reflection.MethodInvoker.Invoke(Object obj, IntPtr* args, BindingFlags invokeAttr)


Failed!  - Failed:     1, Passed:     0, Skipped:     0, Total:     1, Duration: 58 ms - mstest.dll (net7.0)
PS C:\Users\v-wenjj\Desktop\mstest> &"C:\Program Files (x86)\dotnet\dotnet.exe" test --framework net7.0 --diag:logna.txt
  Determining projects to restore...
C:\Program Files (x86)\dotnet\sdk\7.0.100-preview.6.22314.18\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.TargetFramewo
rkInference.targets(54,5): "[MSBuild]::GetTargetFrameworkIdentifier(netcoreapp3.1)" canno
t be evaluated. Exception has been thrown by the target of an invocation. [C:\Users\v-wenjj\Desktop\mstest\mstest.cspro
j]
@Evangelink Evangelink self-assigned this Jun 15, 2022
@Evangelink
Copy link
Member

Evangelink commented Jun 15, 2022

Looks like an MSBuild issue based on output: "[MSBuild]::GetTargetFrameworkIdentifier(netcoreapp3.1)".
cc @dsplaisted @marcpopMSFT @rainersigwald Do you know who to root this issue to?

@baronfel baronfel transferred this issue from dotnet/sdk Jun 15, 2022
@baronfel baronfel assigned benvillalobos and unassigned Evangelink Jun 15, 2022
@baronfel
Copy link
Member

@benvillalobos can you check this since it's ARM related? It looks like the property function is blowing up?

@sebastienros
Copy link
Member

I have the same error with SDK 7.0.100-preview.6.22306.1 but not with SDK 7.0.100-preview.6.22302.2

@benvillalobos
Copy link
Member

This is high pri on my radar. Looks like it should be an easy repro

@benvillalobos
Copy link
Member

Note to self: Maybe we can improve logging here.

@benvillalobos
Copy link
Member

Notes from investigating

This is a heck of a bug. There's something going on with that x86 dotnet install. I could repro this issue, and discovered a fatal error in the process. Both issues only repro in that x86 dotnet install.

Here's a stack trace I got from the repro:

PS D:\src\mstest> & “C:\Program Files (x86)\dotnet\dotnet.exe" test --framework net7.0 --diag:logna.txt
  Determining projects to restore...
C:\Program Files (x86)\dotnet\sdk\7.0.100-preview.6.22315.18\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.TargetFramewo
rkInference.targets(55,5): error MSB4184: The expression "[MSBuild]::GetTargetFrameworkVersion(net7.0, 2)" cannot be ev
aluated. Exception has been thrown by the target of an invocation. [D:\src\mstest\mstest.csproj]
C:\Program Files (x86)\dotnet\sdk\7.0.100-preview.6.22315.18\NuGet.targets(1026,7): error MSB4018: The "MSBuild" task f
ailed unexpectedly. [D:\src\mstest\mstest.csproj]
C:\Program Files (x86)\dotnet\sdk\7.0.100-preview.6.22315.18\NuGet.targets(1026,7): error MSB4018: System.NullReference
Exception: Object reference not set to an instance of an object. [D:\src\mstest\mstest.csproj]
C:\Program Files (x86)\dotnet\sdk\7.0.100-preview.6.22315.18\NuGet.targets(1026,7): error MSB4018:    at InvokeStub_MSB
uild.get_TargetOutputs(Object, Object, IntPtr*) [D:\src\mstest\mstest.csproj]
C:\Program Files (x86)\dotnet\sdk\7.0.100-preview.6.22315.18\NuGet.targets(1026,7): error MSB4018:    at System.Reflect
ion.MethodInvoker.Invoke(Object obj, IntPtr* args, BindingFlags invokeAttr) [D:\src\mstest\mstest.csproj]
C:\Program Files (x86)\dotnet\sdk\7.0.100-preview.6.22315.18\NuGet.targets(1026,7): error MSB4028: The "MSBuild" task's
 outputs could not be retrieved from the "TargetOutputs" parameter. Object reference not set to an instance of an objec
t. [D:\src\mstest\mstest.csproj]
C:\Program Files (x86)\dotnet\sdk\7.0.100-preview.6.22315.18\NuGet.targets(1123,7): error MSB4018: The "MSBuild" task f
ailed unexpectedly. [D:\src\mstest\mstest.csproj]
C:\Program Files (x86)\dotnet\sdk\7.0.100-preview.6.22315.18\NuGet.targets(1123,7): error MSB4018: System.NullReference
Exception: Object reference not set to an instance of an object. [D:\src\mstest\mstest.csproj]
C:\Program Files (x86)\dotnet\sdk\7.0.100-preview.6.22315.18\NuGet.targets(1123,7): error MSB4018:    at InvokeStub_MSB
uild.get_TargetOutputs(Object, Object, IntPtr*) [D:\src\mstest\mstest.csproj]
C:\Program Files (x86)\dotnet\sdk\7.0.100-preview.6.22315.18\NuGet.targets(1123,7): error MSB4018:    at System.Reflect
ion.MethodInvoker.Invoke(Object obj, IntPtr* args, BindingFlags invokeAttr) [D:\src\mstest\mstest.csproj]
C:\Program Files (x86)\dotnet\sdk\7.0.100-preview.6.22315.18\NuGet.targets(1123,7): error MSB4028: The "MSBuild" task's
 outputs could not be retrieved from the "TargetOutputs" parameter. Object reference not set to an instance of an objec
t. [D:\src\mstest\mstest.csproj]

I think there's a larger issue here WRT x86 dotnet on arm64 machines. I haven't tested this on a non-arm64 machine yet. You can easily repro it (only on x86) with an empty project:

<Project Sdk="Microsoft.NET.Sdk">
    <PropertyGroup>
        <TargetFramework>net7.0</TargetFramework>
    </PropertyGroup>
</Project>

Here's the fatal error:

Fatal error. 0xC0000005
   at DynamicClass.Regex1_Scan(System.Text.RegularExpressions.RegexRunner, System.ReadOnlySpan`1<Char>)
   at System.Text.RegularExpressions.Regex.RunAllMatchesWithCallback[[System.ValueTuple`5[[System.Text.SegmentStringBuilder, System.Text.RegularExpressions, Version=7.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a],[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.Int32, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.Int32, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]], System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]](System.String, Int32, System.ValueTuple`5<System.Text.SegmentStringBuilder,System.__Canon,Int32,System.__Canon,Int32> ByRef, System.Text.RegularExpressions.MatchCallback`1<System.ValueTuple`5<System.Text.SegmentStringBuilder,System.__Canon,Int32,System.__Canon,Int32>>, System.Text.RegularExpressions.RegexRunnerMode, Boolean)
   at System.Text.RegularExpressions.Regex.Replace(System.Text.RegularExpressions.MatchEvaluator, System.Text.RegularExpressions.Regex, System.String, Int32, Int32)
   at System.Text.RegularExpressions.Regex.Replace(System.String, System.Text.RegularExpressions.MatchEvaluator)
   at Microsoft.Build.Evaluation.Expander`2+MetadataExpander[[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].ExpandMetadataLeaveEscaped(System.String, Microsoft.Build.Evaluation.IMetadataTable, Microsoft.Build.Evaluation.ExpanderOptions, Microsoft.Build.Shared.IElementLocation)
   at Microsoft.Build.Evaluation.Expander`2[[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].ExpandIntoStringLeaveEscaped(System.String, Microsoft.Build.Evaluation.ExpanderOptions, Microsoft.Build.Shared.IElementLocation)
   at Microsoft.Build.Evaluation.ConditionEvaluator+ConditionEvaluationState`2[[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].ExpandIntoStringBreakEarly(System.String)
   at Microsoft.Build.Evaluation.StringExpressionNode.EvaluatesToEmpty(IConditi
onEvaluationState)
   at Microsoft.Build.Evaluation.MultipleComparisonNode.BoolEvaluate(IConditionEvaluationState)
   at Microsoft.Build.Evaluation.OperatorExpressionNode.TryBoolEvaluate(IConditionEvaluationState, Boolean ByRef)
   at Microsoft.Build.Evaluation.AndExpressionNode.BoolEvaluate(IConditionEvaluationState)
   at Microsoft.Build.Evaluation.OperatorExpressionNode.TryBoolEvaluate(IConditionEvaluationState, Boolean ByRef)
   at Microsoft.Build.Evaluation.AndExpressionNode.BoolEvaluate(IConditionEvaluationState)
   at Microsoft.Build.Evaluation.OperatorExpressionNode.TryBoolEvaluate(IConditionEvaluationState, Boolean ByRef)
   at Microsoft.Build.Evaluation.AndExpressionNode.BoolEvaluate(IConditionEvaluationState)
   at Microsoft.Build.Evaluation.OperatorExpressionNode.TryBoolEvaluate(IConditionEvaluationState, Boolean ByRef)
   at Microsoft.Build.Evaluation.GenericExpressionNode.Evaluate(IConditionEvaluationState)
   at Microsoft.Build.Evaluation.ConditionEvaluator.EvaluateConditionCollectingConditionedProperties[[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]](System.String, Microsoft.Build.Evaluation.ParserOptions, Microsoft.Build.Evaluation.Expander`2<System.__Canon,System.__Canon>, Microsoft.Build.Evaluation.ExpanderOptions, System.Collections.Generic.Dictionary`2<System.String,System.Collections.Generic.List`1<System.String>>, System.String, Microsoft.Build.Construction.ElementLocation, Microsoft.Build.BackEnd.Logging.ILoggingService, Microsoft.Build.Framework.BuildEventContext, Microsoft.Build.Shared.FileSystem.IFileSystem, Microsoft.Build.Evaluation.ProjectRootElementCacheBase)
   at Microsoft.Build.BackEnd.ItemGroupIntrinsicTask.ExecuteTask(Microsoft.Build.BackEnd.Lookup)
   at Microsoft.Build.BackEnd.TaskBuilder.ExecuteIntrinsicTask(Microsoft.Build.BackEnd.ItemBucket)
   at Microsoft.Build.BackEnd.TaskBuilder+<ExecuteBucket>d__19.MoveNext()
   at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[[Microsoft.Build.BackEnd.TaskBuilder+<ExecuteBucket>d__19, Microsoft.Build, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]](<ExecuteBucket>d__19 ByRef)
   at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1[[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].Start[[Microsoft.Build.BackEnd.TaskBuilder+<ExecuteBucket>d__19, Microsoft.Build, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]](<ExecuteBucket>d__19 ByRef)
   at Microsoft.Build.BackEnd.TaskBuilder.ExecuteBucket(Microsoft.Build.BackEnd.TaskHost, Microsoft.Build.BackEnd.ItemBucket, Microsoft.Build.BackEnd.TaskExecutionMode, System.Collections.Generic.Dictionary`2<System.String,System.String>)
   at Microsoft.Build.BackEnd.TaskBuilder+<ExecuteTask>d__18.MoveNext()
   at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[[Microsoft.Build.BackEnd.TaskBuilder+<ExecuteTask>d__18, Microsoft.Build, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]](<ExecuteTask>d__18 ByRef)
   at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1[[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].Start[[Microsoft.Build.BackEnd.TaskBuilder+<ExecuteTask>d__18, Microsoft.Build, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]](<ExecuteTask>d__18 ByRef)
   at Microsoft.Build.BackEnd.TaskBuilder.ExecuteTask(Microsoft.Build.BackEnd.TaskExecutionMode, Microsoft.Build.BackEnd.Lookup)
   at Microsoft.Build.BackEnd.TaskBuilder+<ExecuteTask>d__13.MoveNext()
   at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[[Microsoft.Build.BackEnd.TaskBuilder+<ExecuteTask>d__13, Microsoft.Build, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]](<ExecuteTask>d__13 ByRef)
   at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1[[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].Start[[Microsoft.Build.BackEnd.TaskBuilder+<ExecuteTask>d__13, Microsoft.Build, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]](<ExecuteTask>d__13 ByRef)
   at Microsoft.Build.BackEnd.TaskBuilder.ExecuteTask(Microsoft.Build.BackEnd.Logging.TargetLoggingContext, Microsoft.Build.BackEnd.BuildRequestEntry, Microsoft.Build.BackEnd.ITargetBuilderCallback, Microsoft.Build.Execution.ProjectTargetInstanceChild, Microsoft.Build.BackEnd.TaskExecutionMode, Microsoft.Build.BackEnd.Lookup, Microsoft.Build.BackEnd.Lookup, System.Threading.CancellationToken)
   at Microsoft.Build.BackEnd.TargetEntry+<ProcessBucket>d__51.MoveNext()
   at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[[Microsoft.Build.BackEnd.TargetEntry+<ProcessBucket>d__51, Microsoft.Build, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]](<ProcessBucket>d__51 ByRef)
   at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1[[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].Start[[Microsoft.Build.BackEnd.TargetEntry+<ProcessBucket>d__51, Microsoft.Build, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]](<ProcessBucket>d__51 ByRef)
   at Microsoft.Build.BackEnd.TargetEntry.ProcessBucket(Microsoft.Build.BackEnd.ITaskBuilder, Microsoft.Build.BackEnd.Logging.TargetLoggingContext, Microsoft.Build.BackEnd.TaskExecutionMode, Microsoft.Build.BackEnd.Lookup, Microsoft.Build.BackEnd.Lookup)
   at Microsoft.Build.BackEnd.TargetEntry+<ExecuteTarget>d__44.MoveNext()
   at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[[Microsoft.Build.BackEnd.TargetEntry+<ExecuteTarget>d__44, Microsoft.Build, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]](<ExecuteTarget>d__44 ByRef)
   at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[[Microsoft.Build.BackEnd.TargetEntry+<ExecuteTarget>d__44, Microsoft.Build, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]](<ExecuteTarget>d__44 ByRef)
   at Microsoft.Build.BackEnd.TargetEntry.ExecuteTarget(Microsoft.Build.BackEnd.ITaskBuilder, Microsoft.Build.BackEnd.BuildRequestEntry, Microsoft.Build.BackEnd.Logging.ProjectLoggingContext, System.Threading.CancellationToken)
   at Microsoft.Build.BackEnd.TargetBuilder+<ProcessTargetStack>d__23.MoveNext()
   at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[[Microsoft.Build.BackEnd.TargetBuilder+<ProcessTargetStack>d__23, Microsoft.Build, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]](<ProcessTargetStack>d__23 ByRef)
   at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[[Microsoft.Build.BackEnd.TargetBuilder+<ProcessTargetStack>d__23, Microsoft.Build, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]](<ProcessTargetStack>d__23 ByRef)
   at Microsoft.Build.BackEnd.TargetBuilder.ProcessTargetStack(Microsoft.Build.BackEnd.ITaskBuilder)
   at Microsoft.Build.BackEnd.TargetBuilder+<BuildTargets>d__10.MoveNext()
   at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[[Microsoft.Build.BackEnd.TargetBuilder+<BuildTargets>d__10, Microsoft.Build, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]](<BuildTargets>d__10 ByRef)
   at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1[[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].Start[[Microsoft.Build.BackEnd.TargetBuilder+<BuildTargets>d__10, Microsoft.Build, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]](<BuildTargets>d__10 ByRef)
   at Microsoft.Build.BackEnd.TargetBuilder.BuildTargets(Microsoft.Build.BackEnd.Logging.ProjectLoggingContext, Microsoft.Build.BackEnd.BuildRequestEntry, Microsoft.Build.BackEnd.IRequestBuilderCallback, System.String[], Microsoft.Build.BackEnd.Lookup, System.Threading.CancellationToken)
   at Microsoft.Build.BackEnd.RequestBuilder+<BuildProject>d__68.MoveNext()
   at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[[Microsoft.Build.BackEnd.RequestBuilder+<BuildProject>d__68, Microsoft.Build, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]](<BuildProject>d__68 ByRef)
   at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1[[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].Start[[Microsoft.Build.BackEnd.RequestBuilder+<BuildProject>d__68, Microsoft.Build, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]](<BuildProject>d__68 ByRef)
   at Microsoft.Build.BackEnd.RequestBuilder.BuildProject()
   at Microsoft.Build.BackEnd.RequestBuilder+<BuildAndReport>d__59.MoveNext()
   at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[[Microsoft.Build.BackEnd.RequestBuilder+<BuildAndReport>d__59, Microsoft.Build, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]](<BuildAndReport>d__59 ByRef)
   at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[[Microsoft.Build.BackEnd.RequestBuilder+<BuildAndReport>d__59, Microsoft.Build, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]](<BuildAndReport>d__59 ByRef)
   at Microsoft.Build.BackEnd.RequestBuilder.BuildAndReport()
   at Microsoft.Build.BackEnd.RequestBuilder+<RequestThreadProc>d__58.MoveNext()
   at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[[Microsoft.Build.BackEnd.RequestBuilder+<RequestThreadProc>d__58, Microsoft.Build, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]](<RequestThreadProc>d__58 ByRef)
   at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[[Microsoft.Build.BackEnd.RequestBuilder+<RequestThreadProc>d__58, Microsoft.Build, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]](<RequestThreadProc>d__58 ByRef)
   at Microsoft.Build.BackEnd.RequestBuilder.RequestThreadProc(Boolean)
   at Microsoft.Build.BackEnd.RequestBuilder.<StartBuilderThread>b__53_2()
   at System.Threading.Tasks.Task`1[[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].InnerInvoke()
   at System.Threading.Tasks.Task+<>c.<.cctor>b__273_0(System.Object)
   at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
   at System.Threading.Tasks.Task.ExecuteWithThreadLocal(System.Threading.Tasks.Task ByRef, System.Threading.Thread)
   at System.Threading.Tasks.Task.ExecuteEntry()
   at System.Threading.Tasks.TaskScheduler.TryExecuteTask(System.Threading.Tasks.Task)
   at Microsoft.Build.BackEnd.RequestBuilder+DedicatedThreadsTaskScheduler.<InjectThread>b__6_0()
   at System.Threading.Thread+StartHelper.Callback(System.Object)
   at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
   at System.Threading.Thread.StartCallback()

I captured a log (and removed env vars), it should be attached. It ends abruptly and there's no obvious sign at first glance at what's going on. Will get back to this tomorrow

@rainersigwald
Copy link
Member

@benvillalobos drive-by question: have you tried with a 6.0.400-preview SDK that has the latest MSBuild bits in it? some of that looks like it might be a runtime problem.

@benvillalobos
Copy link
Member

benvillalobos commented Jun 16, 2022

drive-by question: have you tried with a 6.0.400-preview SDK that has the latest MSBuild bits in it? some of that looks like it might be a runtime problem.

After installing 6.0.400-preview.22316.6 the fatal error issue...disappeared 😐

Scratch that. (had to re-include the .net sdk into the project).

The fatal error does not come up in 6.0.400-preview.22316.6 and does come up in 7.0.100-preview.5.22307.18 (global jsoning the project between versions)

6.0.400-preview.22316.6 MSBuild Version: 1c045cf

D:\src\temp\repro-tfi>"C:\Program Files (x86)\dotnet\dotnet.exe" build /flp:v=diag
MSBuild version 17.3.0-preview-22306-01+1c045cf58 for .NET
  Determining projects to restore...
C:\Program Files (x86)\dotnet\sdk\6.0.400-preview.22316.6\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.TargetFrameworkI
nference.targets(144,5): error NETSDK1045: The current .NET SDK does not support targeting .NET 7.0.  Either target .NE
T 6.0 or lower, or use a version of the .NET SDK that supports .NET 7.0. [D:\src\temp\repro-tfi\proj.csproj]

Build FAILED.

C:\Program Files (x86)\dotnet\sdk\6.0.400-preview.22316.6\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.TargetFrameworkI
nference.targets(144,5): error NETSDK1045: The current .NET SDK does not support targeting .NET 7.0.  Either target .NE
T 6.0 or lower, or use a version of the .NET SDK that supports .NET 7.0. [D:\src\temp\repro-tfi\proj.csproj]
    0 Warning(s)
    1 Error(s)

Time Elapsed 00:00:06.88

7.0.100-preview.5.22307.18 MSBuild Version: 1c045cf

D:\src\temp\repro-tfi>"C:\Program Files (x86)\dotnet\dotnet.exe" build /flp:v=diag
MSBuild version 17.3.0-preview-22306-01+1c045cf58 for .NET
Fatal error. 0xC0000005
   at DynamicClass.Regex1_Scan(System.Text.RegularExpressions.RegexRunner, System.ReadOnlySpan`1<Char>)
   at System.Text.RegularExpressions.Regex.RunAllMatchesWithCallback[[System.ValueTuple`5[[System.Text.SegmentStringBuilder, System.Text.RegularExpressions, Version=7.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a],[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.Int32, System.Privat
...
...

6.0.400 successfully repro's this issue, so I can continue the investigation tomorrow. The 7.0.100 looks to have a bigger issue in there.

@benvillalobos
Copy link
Member

Currently discussing this internally, but it looks like an issue with the runtime.

@benvillalobos
Copy link
Member

Transferring to runtime for triage.

@dotnet-issue-labeler
Copy link

I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.

@ghost ghost added the untriaged New issue has not been triaged by the area owner label Jun 21, 2022
@benvillalobos benvillalobos transferred this issue from dotnet/msbuild Jun 21, 2022
@danmoseley
Copy link
Member

As the stack suggests, it's executing ref-emitted code here. The regex is either NonTransformItemMetadataPattern or ItemMetadataPattern. So main possibilities are - a bug introduced into the compiled regex engine or a bug in the runtime. Either way, that's showing up only when in 32 bit x86 running on Windows Arm64.

@benvillalobos since you have a machine set up that repros this, is it possible to dump (out of the debugger) both the regex pattern, regex options, and the string it's running on? Then paste those into a Hello World app to see whether just running that pattern against that string triggers it. If so -- we've substantially narrowed this down.

@mangod9 mangod9 removed the untriaged New issue has not been triaged by the area owner label Jul 7, 2022
@mangod9 mangod9 added this to the 7.0.0 milestone Jul 7, 2022
@v-hozha1
Copy link

This issue also repro on dotnet-sdk-7.0.100-preview.7.22358.13.
Command:
& “C:\Program Files (x86)\dotnet\dotnet.exe" test --framework net7.0 --diag:logna.txt
& "C:\Program Files (x86)\dotnet\dotnet.exe" test --framework net7.0 --arch x64 --diag:logz2.txt
& "C:\Program Files (x86)\dotnet\dotnet.exe" test --framework net7.0 --arch arm64 --diag:logz2.txt

image

PS C:\tmp\mstest> & "C:\Program Files (x86)\dotnet\dotnet.exe" test --framework net7.0 --arch x64 --diag:logz2.txt
Determining projects to restore...
C:\Program Files (x86)\dotnet\sdk\7.0.100-preview.7.22358.13\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.TargetFrameworkInference.targets(55,5): error MSB4184: The expres
sion "[MSBuild]::GetTargetFrameworkVersion(net7.0, 2)" cannot be evaluated. Exception has been thrown by the target of an invocation. [C:\tmp\mstest\mstest.csproj]
C:\Program Files (x86)\dotnet\sdk\7.0.100-preview.7.22358.13\NuGet.targets(1111,7): error MSB4018: The "MSBuild" task failed unexpectedly. [C:\tmp\mstest\mstest.csproj]
C:\Program Files (x86)\dotnet\sdk\7.0.100-preview.7.22358.13\NuGet.targets(1111,7): error MSB4018: System.NullReferenceException: Object reference not set to an instance o
f an object. [C:\tmp\mstest\mstest.csproj]
C:\Program Files (x86)\dotnet\sdk\7.0.100-preview.7.22358.13\NuGet.targets(1111,7): error MSB4018: at InvokeStub_MSBuild.get_TargetOutputs(Object, Object, IntPtr*) [C:
tmp\mstest\mstest.csproj]
C:\Program Files (x86)\dotnet\sdk\7.0.100-preview.7.22358.13\NuGet.targets(1111,7): error MSB4018: at System.Reflection.MethodInvoker.Invoke(Object obj, IntPtr* args, B
indingFlags invokeAttr) [C:\tmp\mstest\mstest.csproj]
C:\Program Files (x86)\dotnet\sdk\7.0.100-preview.7.22358.13\NuGet.targets(1111,7): error MSB4028: The "MSBuild" task's outputs could not be retrieved from the "TargetOutp
uts" parameter. Object reference not set to an instance of an object. [C:\tmp\mstest\mstest.csproj]
C:\Program Files (x86)\dotnet\sdk\7.0.100-preview.7.22358.13\NuGet.targets(1208,7): error MSB4018: The "MSBuild" task failed unexpectedly. [C:\tmp\mstest\mstest.csproj]
C:\Program Files (x86)\dotnet\sdk\7.0.100-preview.7.22358.13\NuGet.targets(1208,7): error MSB4018: System.NullReferenceException: Object reference not set to an instance o
f an object. [C:\tmp\mstest\mstest.csproj]
C:\Program Files (x86)\dotnet\sdk\7.0.100-preview.7.22358.13\NuGet.targets(1208,7): error MSB4018: at InvokeStub_MSBuild.get_TargetOutputs(Object, Object, IntPtr*) [C:
tmp\mstest\mstest.csproj]
C:\Program Files (x86)\dotnet\sdk\7.0.100-preview.7.22358.13\NuGet.targets(1208,7): error MSB4018: at System.Reflection.MethodInvoker.Invoke(Object obj, IntPtr* args, B
indingFlags invokeAttr) [C:\tmp\mstest\mstest.csproj]
C:\Program Files (x86)\dotnet\sdk\7.0.100-preview.7.22358.13\NuGet.targets(1208,7): error MSB4028: The "MSBuild" task's outputs could not be retrieved from the "TargetOutp
uts" parameter. Object reference not set to an instance of an object. [C:\tmp\mstest\mstest.csproj]
PS C:\tmp\mstest> & "C:\Program Files (x86)\dotnet\dotnet.exe" test --framework net7.0 --arch arm64 --diag:logz2.txt
Determining projects to restore...
C:\Program Files (x86)\dotnet\sdk\7.0.100-preview.7.22358.13\NuGet.targets(1111,7): error MSB4018: The "MSBuild" task failed unexpectedly. [C:\tmp\mstest\mstest.csproj]
C:\Program Files (x86)\dotnet\sdk\7.0.100-preview.7.22358.13\NuGet.targets(1111,7): error MSB4018: System.NullReferenceException: Object reference not set to an instance o
f an object. [C:\tmp\mstest\mstest.csproj]
C:\Program Files (x86)\dotnet\sdk\7.0.100-preview.7.22358.13\NuGet.targets(1111,7): error MSB4018: at InvokeStub_MSBuild.get_TargetOutputs(Object, Object, IntPtr*) [C:
tmp\mstest\mstest.csproj]
C:\Program Files (x86)\dotnet\sdk\7.0.100-preview.7.22358.13\NuGet.targets(1111,7): error MSB4018: at System.Reflection.MethodInvoker.Invoke(Object obj, IntPtr* args, B
indingFlags invokeAttr) [C:\tmp\mstest\mstest.csproj]
C:\Program Files (x86)\dotnet\sdk\7.0.100-preview.7.22358.13\NuGet.targets(1111,7): error MSB4028: The "MSBuild" task's outputs could not be retrieved from the "TargetOutp
uts" parameter. Object reference not set to an instance of an object. [C:\tmp\mstest\mstest.csproj]
C:\Program Files (x86)\dotnet\sdk\7.0.100-preview.7.22358.13\NuGet.targets(1208,7): error MSB4018: The "MSBuild" task failed unexpectedly. [C:\tmp\mstest\mstest.csproj]
C:\Program Files (x86)\dotnet\sdk\7.0.100-preview.7.22358.13\NuGet.targets(1208,7): error MSB4018: System.NullReferenceException: Object reference not set to an instance o
f an object. [C:\tmp\mstest\mstest.csproj]
C:\Program Files (x86)\dotnet\sdk\7.0.100-preview.7.22358.13\NuGet.targets(1208,7): error MSB4018: at InvokeStub_MSBuild.get_TargetOutputs(Object, Object, IntPtr*) [C:
tmp\mstest\mstest.csproj]
C:\Program Files (x86)\dotnet\sdk\7.0.100-preview.7.22358.13\NuGet.targets(1208,7): error MSB4018: at System.Reflection.MethodInvoker.Invoke(Object obj, IntPtr* args, B
indingFlags invokeAttr) [C:\tmp\mstest\mstest.csproj]
C:\Program Files (x86)\dotnet\sdk\7.0.100-preview.7.22358.13\NuGet.targets(1208,7): error MSB4028: The "MSBuild" task's outputs could not be retrieved from the "TargetOutp
uts" parameter. Object reference not set to an instance of an object. [C:\tmp\mstest\mstest.csproj]
PS C:\tmp\mstest>

@mangod9
Copy link
Member

mangod9 commented Jul 27, 2022

Does this only repro with x86 emulation on arm64? There was a recent fix which was made recently for that.

@v-hozha1
Copy link

This issue still repro on today's dotnet-sdk-7.0.100-rc.1.22377.7.

Does this only repro with x86 emulation on arm64?
--Yes. For the x64 emulation on arm64, there's another issue dotnet/msbuild#7721 to track.

@mangod9
Copy link
Member

mangod9 commented Jul 28, 2022

If this is emulation only then its most likely a dupe of #71856.

@mangod9
Copy link
Member

mangod9 commented Aug 3, 2022

A similar issue is closed: #71856, Please validate that this is now fixed.

@v-hozha1
Copy link

v-hozha1 commented Aug 4, 2022

This issue still repro on today's build dotnet-sdk-7.0.100-rc.1.22403.8. Here is the repro VM: 172.20.30.177

Please refer to the project & dump file from: \mlangfs1\public\v-hozha1\20220804-71098\

PS C:\tmp\mstest> &"C:\Program Files (x86)\dotnet\dotnet.exe" test --framework net7.0 --diag:log1.txt
Determining projects to restore...
C:\Program Files (x86)\dotnet\sdk\7.0.100-rc.1.22403.8\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.TargetFrameworkInference.targets(55,5): error MSB4184: The expression "[MSBuild]::GetTargetFrameworkVersion(net7.0, 2)" cannot be evalua
ted. Exception has been thrown by the target of an invocation. [C:\tmp\mstest\mstest.csproj]
PS C:\tmp\mstest> &"C:\Program Files (x86)\dotnet\dotnet.exe" test --framework net7.0 --arch x64 --diag:log2.txt
Determining projects to restore...
Unhandled exception. System.NullReferenceException: Object reference not set to an instance of an object.
at InvokeStub_IntrinsicFunctions.IsOSPlatform(Object, Object, IntPtr*)
PS C:\tmp\mstest> &"C:\Program Files (x86)\dotnet\dotnet.exe" test --framework net7.0 --arch arm64 --diag:log3.txt
Determining projects to restore...
Unhandled exception. System.NullReferenceException: Object reference not set to an instance of an object.
at InvokeStub_CheckIfPackageReferenceShouldBeFrameworkReference.get_ShouldRemovePackageReference(Object, Object, IntPtr*)
PS C:\tmp\mstest>

image

@mangod9
Copy link
Member

mangod9 commented Aug 5, 2022

the fix should be in runtime 7.0.0-rc.1.22403.8 and sdk 7.0.100-rc.1.22404.5

@mangod9
Copy link
Member

mangod9 commented Aug 9, 2022

Closing since this should be fixed.

@mangod9 mangod9 closed this as completed Aug 9, 2022
@v-hozha1
Copy link

This issue has been fixed on dotnet-sdk-7.0.100-rc.1.22414.7. Details please refer to below:
image

image
image
image

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

10 participants