ForNeVeR / Cesium

C compiler for the CLI platform
MIT License
381 stars 42 forks source link

Memory access violation in `FuncPtrInterop` #674

Open ForNeVeR opened 1 month ago

ForNeVeR commented 1 month ago

An occasional error from our CI:

16:52:36 [INF] > "C:\Program Files\dotnet\dotnet.exe" test D:\a\Cesium\Cesium\Cesium.CodeGen.Tests\Cesium.CodeGen.Tests.csproj --configuration Debug
  16:52:37 [DBG]   Determining projects to restore...
  16:52:38 [DBG]   All projects are up-to-date for restore.
  16:52:39 [DBG]   Cesium.Core -> D:\a\Cesium\Cesium\artifacts\bin\Cesium.Core\debug\Cesium.Core.dll
  16:52:39 [DBG]   Cesium.Ast -> D:\a\Cesium\Cesium\artifacts\bin\Cesium.Ast\debug\Cesium.Ast.dll
  16:52:39 [DBG]   Cesium.Solution.Metadata -> D:\a\Cesium\Cesium\artifacts\bin\Cesium.Solution.Metadata\debug\Cesium.Solution.Metadata.dll
  16:52:39 [DBG]   Cesium.Preprocessor -> D:\a\Cesium\Cesium\artifacts\bin\Cesium.Preprocessor\debug\Cesium.Preprocessor.dll
  16:52:39 [DBG]   Cesium.Parser -> D:\a\Cesium\Cesium\artifacts\bin\Cesium.Parser\debug\Cesium.Parser.dll
  16:52:39 [DBG]   Cesium.CodeGen -> D:\a\Cesium\Cesium\artifacts\bin\Cesium.CodeGen\debug\Cesium.CodeGen.dll
  16:52:39 [DBG]   Cesium.Runtime -> D:\a\Cesium\Cesium\artifacts\bin\Cesium.Runtime\debug_net6.0\Cesium.Runtime.dll
  16:52:39 [DBG]   Cesium.TestFramework -> D:\a\Cesium\Cesium\artifacts\bin\Cesium.TestFramework\debug\Cesium.TestFramework.dll
  16:52:39 [DBG]   Cesium.Compiler -> D:\a\Cesium\Cesium\artifacts\bin\Cesium.Compiler\debug\Cesium.Compiler.dll
  16:52:40 [DBG]   Cesium.CodeGen.Tests -> D:\a\Cesium\Cesium\artifacts\bin\Cesium.CodeGen.Tests\debug\Cesium.CodeGen.Tests.dll
  16:52:40 [DBG] Test run for D:\a\Cesium\Cesium\artifacts\bin\Cesium.CodeGen.Tests\debug\Cesium.CodeGen.Tests.dll (.NETCoreApp,Version=v8.0)
  16:52:40 [DBG] VSTest version 17.11.1 (x64)
  16:52:40 [DBG] 
  16:52:40 [DBG] Starting test execution, please wait...
  16:52:40 [DBG] A total of 1 test files matched the specified pattern.
  16:52:41 [DBG] [xUnit.net 00:00:00.95]     Cesium.CodeGen.Tests.CodeGenTypeTests.LocalStructTest [SKIP]
  16:52:41 [DBG]   Skipped Cesium.CodeGen.Tests.CodeGenTypeTests.LocalStructTest [1 ms]
  Error: [xUnit.net 00:00:42.26]     Cesium.CodeGen.Tests.CodeGenNetInteropTests.FuncPtrInterop(architecture: Wide) [FAIL]
  16:53:23 [ERR] [xUnit.net 00:00:42.26]     Cesium.CodeGen.Tests.CodeGenNetInteropTests.FuncPtrInterop(architecture: Wide) [FAIL]
  16:53:23 [DBG]   Failed Cesium.CodeGen.Tests.CodeGenNetInteropTests.FuncPtrInterop(architecture: Wide) [3 s]
  16:53:23 [DBG]   Error Message:
  16:53:23 [DBG]    Assert.True() Failure
  16:53:23 [DBG] Expected: True
  16:53:23 [DBG] Actual:   False
  16:53:23 [DBG]   Stack Trace:
  16:53:23 [DBG]      at Cesium.TestFramework.ExecUtil.RunToSuccess(ITestOutputHelper output, String executable, String workingDirectory, String[] args, IReadOnlyDictionary`2 additionalEnvironment) in D:\a\Cesium\Cesium\Cesium.TestFramework\ExecUtil.cs:line 16
  16:53:23 [DBG]    at Cesium.TestFramework.CSharpCompilationUtil.CreateCSharpProject(ITestOutputHelper output, String directory) in D:\a\Cesium\Cesium\Cesium.TestFramework\CSharpCompilationUtil.cs:line 43
  16:53:23 [DBG]    at Cesium.TestFramework.CSharpCompilationUtil.CompileCSharpAssembly(ITestOutputHelper output, TargetRuntimeDescriptor runtime, String cSharpSource) in D:\a\Cesium\Cesium\Cesium.TestFramework\CSharpCompilationUtil.cs:line 34
  16:53:23 [DBG]    at Cesium.CodeGen.Tests.CodeGenNetInteropTests.DoTest(TargetArchitectureSet architecture, String cSharpCode, String cCode) in D:\a\Cesium\Cesium\Cesium.CodeGen.Tests\CodeGenNetInteropTests.cs:line 22
  16:53:23 [DBG] --- End of stack trace from previous location ---
  16:53:23 [DBG]   Standard Output Messages:
  16:53:23 [DBG]  $ dotnet new classlib --framework net8.0 --output TestProject
  16:53:23 [DBG]  The template "Class Library" was created successfully.
  16:53:23 [DBG]  
  16:53:23 [DBG]  Processing post-creation actions...
  16:53:23 [DBG]  Restoring C:\Users\runneradmin\AppData\Local\Temp\tmp1dz33d.tmp\TestProject\TestProject.csproj:
  16:53:23 [DBG]    Determining projects to restore...
  16:53:23 [DBG]  
  16:53:23 [DBG]  [ERR] Fatal error. System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
  16:53:23 [DBG]  [ERR] Repeat 2 times:
  16:53:23 [DBG]  [ERR] --------------------------------
  16:53:23 [DBG]  [ERR]    at Microsoft.VisualStudio.Setup.Configuration.IEnumSetupInstances.Next(Int32, Microsoft.VisualStudio.Setup.Configuration.ISetupInstance[], Int32 ByRef)
  16:53:23 [DBG]  [ERR] --------------------------------
  16:53:23 [DBG]  [ERR]    at Microsoft.DotNet.Workloads.Workload.VisualStudioWorkloads.GetVisualStudioInstances()
  16:53:23 [DBG]  [ERR]    at Microsoft.DotNet.Workloads.Workload.VisualStudioWorkloads.GetInstalledWorkloads(Microsoft.NET.Sdk.WorkloadManifestReader.IWorkloadResolver, Microsoft.DotNet.Workloads.Workload.List.InstalledWorkloadsCollection, System.Nullable`1<Microsoft.NET.Sdk.WorkloadManifestReader.SdkFeatureBand>)
  16:53:23 [DBG]  [ERR]    at Microsoft.DotNet.Workloads.Workload.List.WorkloadInfoHelper.AddInstalledVsWorkloads(System.Collections.Generic.IEnumerable`1<Microsoft.NET.Sdk.WorkloadManifestReader.WorkloadId>)
  16:53:23 [DBG]  [ERR]    at Microsoft.DotNet.Workloads.Workload.List.WorkloadInfoHelper.get_InstalledAndExtendedWorkloads()
  16:53:23 [DBG]  [ERR]    at Microsoft.DotNet.Tools.New.WorkloadsInfoProvider.GetInstalledWorkloadsAsync(System.Threading.CancellationToken)
  16:53:23 [DBG]  [ERR]    at Microsoft.TemplateEngine.Edge.Constraints.WorkloadConstraintFactory+WorkloadConstraint+<ExtractWorkloadInfoAsync>d__9.MoveNext()
  16:53:23 [DBG]  [ERR]    at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[[Microsoft.TemplateEngine.Edge.Constraints.WorkloadConstraintFactory+WorkloadConstraint+<ExtractWorkloadInfoAsync>d__9, Microsoft.TemplateEngine.Edge, Version=8.0.403.0, Culture=neutral, PublicKeyToken=adb9793829ddae60]](<ExtractWorkloadInfoAsync>d__9 ByRef)
  16:53:23 [DBG]  [ERR]    at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1[[System.ValueTuple`2[[System.__Canon, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.__Canon, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]], System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].Start[[Microsoft.TemplateEngine.Edge.Constraints.WorkloadConstraintFactory+WorkloadConstraint+<ExtractWorkloadInfoAsync>d__9, Microsoft.TemplateEngine.Edge, Version=8.0.403.0, Culture=neutral, PublicKeyToken=adb9793829ddae60]](<ExtractWorkloadInfoAsync>d__9 ByRef)
  16:53:23 [DBG]  [ERR]    at Microsoft.TemplateEngine.Edge.Constraints.WorkloadConstraintFactory+WorkloadConstraint.ExtractWorkloadInfoAsync(System.Collections.Generic.IEnumerable`1<Microsoft.TemplateEngine.Abstractions.Components.IWorkloadsInfoProvider>, Microsoft.Extensions.Logging.ILogger, System.Threading.CancellationToken)
  16:53:23 [DBG]  [ERR]    at Microsoft.TemplateEngine.Edge.Constraints.WorkloadConstraintFactory+WorkloadConstraint+<CreateAsync>d__6.MoveNext()
  16:53:23 [DBG]  [ERR]    at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[[Microsoft.TemplateEngine.Edge.Constraints.WorkloadConstraintFactory+WorkloadConstraint+<CreateAsync>d__6, Microsoft.TemplateEngine.Edge, Version=8.0.403.0, Culture=neutral, PublicKeyToken=adb9793829ddae60]](<CreateAsync>d__6 ByRef)
  16:53:23 [DBG]  [ERR]    at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1[[System.__Canon, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].Start[[Microsoft.TemplateEngine.Edge.Constraints.WorkloadConstraintFactory+WorkloadConstraint+<CreateAsync>d__6, Microsoft.TemplateEngine.Edge, Version=8.0.403.0, Culture=neutral, PublicKeyToken=adb9793829ddae60]](<CreateAsync>d__6 ByRef)
  16:53:23 [DBG]  [ERR]    at Microsoft.TemplateEngine.Edge.Constraints.WorkloadConstraintFactory+WorkloadConstraint.CreateAsync(Microsoft.TemplateEngine.Abstractions.IEngineEnvironmentSettings, Microsoft.TemplateEngine.Abstractions.Constraints.ITemplateConstraintFactory, System.Threading.CancellationToken)
  16:53:23 [DBG]  [ERR]    at Microsoft.TemplateEngine.Edge.Constraints.WorkloadConstraintFactory+<Microsoft-TemplateEngine-Abstractions-Constraints-ITemplateConstraintFactory-CreateTemplateConstraintAsync>d__5.MoveNext()
  16:53:23 [DBG]  [ERR]    at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[[Microsoft.TemplateEngine.Edge.Constraints.WorkloadConstraintFactory+<Microsoft-TemplateEngine-Abstractions-Constraints-ITemplateConstraintFactory-CreateTemplateConstraintAsync>d__5, Microsoft.TemplateEngine.Edge, Version=8.0.403.0, Culture=neutral, PublicKeyToken=adb9793829ddae60]](<Microsoft-TemplateEngine-Abstractions-Constraints-ITemplateConstraintFactory-CreateTemplateConstraintAsync>d__5 ByRef)
  16:53:23 [DBG]  [ERR]    at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1[[System.__Canon, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].Start[[Microsoft.TemplateEngine.Edge.Constraints.WorkloadConstraintFactory+<Microsoft-TemplateEngine-Abstractions-Constraints-ITemplateConstraintFactory-CreateTemplateConstraintAsync>d__5, Microsoft.TemplateEngine.Edge, Version=8.0.403.0, Culture=neutral, PublicKeyToken=adb9793829ddae60]](<Microsoft-TemplateEngine-Abstractions-Constraints-ITemplateConstraintFactory-CreateTemplateConstraintAsync>d__5 ByRef)
  16:53:23 [DBG]  [ERR]    at Microsoft.TemplateEngine.Edge.Constraints.WorkloadConstraintFactory.Microsoft.TemplateEngine.Abstractions.Constraints.ITemplateConstraintFactory.CreateTemplateConstraintAsync(Microsoft.TemplateEngine.Abstractions.IEngineEnvironmentSettings, System.Threading.CancellationToken)
  16:53:23 [DBG]  [ERR]    at System.Threading.Tasks.Task`1[[System.__Canon, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].InnerInvoke()
  16:53:23 [DBG]  [ERR]    at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(System.Threading.Thread, System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
  16:53:23 [DBG]  [ERR]    at System.Threading.Tasks.Task.ExecuteWithThreadLocal(System.Threading.Tasks.Task ByRef, System.Threading.Thread)
  16:53:23 [DBG]  [ERR]    at System.Threading.ThreadPoolWorkQueue.Dispatch()
  16:53:23 [DBG]  [ERR]    at System.Threading.PortableThreadPool+WorkerThread.WorkerThreadStart()
  16:53:23 [DBG]  [ERR] 
  16:53:23 [DBG]  Command exit code: -107374[181](https://github.com/ForNeVeR/Cesium/actions/runs/11370159460/job/31629277865#step:7:192)9
  16:53:23 [DBG] 
  16:53:23 [DBG] 
  16:53:25 [DBG] 
  16:53:25 [DBG] Failed!  - Failed:     1, Passed:   330, Skipped:     1, Total:   332, Duration: 43 s - Cesium.CodeGen.Tests.dll (net8.0)
  16:53:25 [DBG] 
  16:53:25 [DBG] Workload updates are available. Run `dotnet workload list` for more information.
  Error: Target "TestCodeGen" has thrown an exception
  16:53:25 [ERR] Target TestCodeGen has thrown an exception
  Nuke.Common.Tooling.ProcessException: Process 'dotnet.exe' exited with code 1.
kant2002 commented 2 weeks ago

Seems to be this is it https://developercommunity.visualstudio.com/t/Parallelly-invoking-MicrosoftVisualStud/10752944?sort=active&topics=enterprise-2017