Skip to content

Reachability helper feature hangs tests in some scenario #1044

@meziantou

Description

@meziantou

After updating to Coverlet 3.0.0, one of the test projects doesn't run anymore. The process is stuck at:

Test run for C:\Users\mezia\source\repos\Meziantou.Framework\tests\Meziantou.Framework.SingleInstance.Tests\bin\Debug\net461\Meziantou.Framework.SingleInstance.Tests.dll (.NETFramework,Version=v4.6.1)
Microsoft (R) Test Execution Command Line Tool Version 16.8.3
Copyright (c) Microsoft Corporation.  All rights reserved.

Starting test execution, please wait...

The CPU usage is 25% for the .NET process (I have a 4 cores CPU).

I've generated a dump file, and it seems to be stuck somewhere in Mono.Cecil:

System.Private.CoreLib.dll!System.SpanHelpers.SequenceEqual(ref byte first, ref byte second, nuint length) Line 1561
	at /_/src/libraries/System.Private.CoreLib/src/System/SpanHelpers.Byte.cs(1561)
Mono.Cecil.dll!Mono.Cecil.MetadataResolver.GetType(Mono.Cecil.ModuleDefinition module, Mono.Cecil.TypeReference reference)
Mono.Cecil.dll!Mono.Cecil.MetadataResolver.Resolve(Mono.Cecil.MethodReference method)
Mono.Cecil.dll!Mono.Cecil.ModuleDefinition.Resolve(Mono.Cecil.MethodReference method)
Mono.Cecil.dll!Mono.Cecil.MethodReference.Resolve()
coverlet.core.dll!Coverlet.Core.Instrumentation.Reachability.ReachabilityHelper.CreateForModule(Mono.Cecil.ModuleDefinition module, string[] doesNotReturnAttributes, Coverlet.Core.Abstractions.ILogger logger) Line 299
	at /_/src/coverlet.core/Instrumentation/ReachabilityHelper.cs(299)
coverlet.core.dll!Coverlet.Core.Instrumentation.Instrumenter.CreateReachabilityHelper() Line 210
	at /_/src/coverlet.core/Instrumentation/Instrumenter.cs(210)
coverlet.core.dll!Coverlet.Core.Instrumentation.Instrumenter.InstrumentModule() Line 219
	at /_/src/coverlet.core/Instrumentation/Instrumenter.cs(219)
coverlet.core.dll!Coverlet.Core.Instrumentation.Instrumenter.Instrument() Line 159
	at /_/src/coverlet.core/Instrumentation/Instrumenter.cs(159)
coverlet.core.dll!Coverlet.Core.Coverage.PrepareModules() Line 146
	at /_/src/coverlet.core/Coverage.cs(146)
coverlet.collector.dll!Coverlet.Collector.DataCollection.CoverageWrapper.PrepareModules(Coverlet.Core.Coverage coverage) Line 63
	at /_/src/coverlet.collector/DataCollection/CoverageWrapper.cs(63)
coverlet.collector.dll!Coverlet.Collector.DataCollection.CoverageManager.InstrumentModules() Line 65
	at /_/src/coverlet.collector/DataCollection/CoverageManager.cs(65)
coverlet.collector.dll!Coverlet.Collector.DataCollection.CoverletCoverageCollector.OnSessionStart(object sender, Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection.SessionStartEventArgs sessionStartEventArgs) Line 140
	at /_/src/coverlet.collector/DataCollection/CoverletCoverageCollector.cs(140)
[Native to Managed Transition]
[Managed to Native Transition]
System.Private.CoreLib.dll!System.Delegate.DynamicInvokeImpl(object[] args) Line 89
	at /_/src/coreclr/src/System.Private.CoreLib/src/System/Delegate.CoreCLR.cs(89)
System.Private.CoreLib.dll!System.Delegate.DynamicInvoke(object[] args) Line 64
	at /_/src/libraries/System.Private.CoreLib/src/System/Delegate.cs(64)
Microsoft.TestPlatform.CoreUtilities.dll!Microsoft.VisualStudio.TestPlatform.Utilities.MulticastDelegateUtilities.SafeInvoke(System.Delegate delegates, object sender, System.EventArgs args, string traceDisplayName)
Microsoft.VisualStudio.TestPlatform.Common.dll!Microsoft.VisualStudio.TestPlatform.Common.DataCollector.TestPlatformDataCollectionEvents.OnSessionStart(Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection.DataCollectionEventArgs e)
Microsoft.VisualStudio.TestPlatform.Common.dll!Microsoft.VisualStudio.TestPlatform.Common.DataCollector.TestPlatformDataCollectionEvents.RaiseEvent(Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection.DataCollectionEventArgs e)
Microsoft.VisualStudio.TestPlatform.Common.dll!Microsoft.VisualStudio.TestPlatform.Common.DataCollector.DataCollectionManager.SendEvent(Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection.DataCollectionEventArgs args)
Microsoft.VisualStudio.TestPlatform.Common.dll!Microsoft.VisualStudio.TestPlatform.Common.DataCollector.DataCollectionManager.SessionStarted(Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection.SessionStartEventArgs sessionStartEventArgs)
Microsoft.TestPlatform.CommunicationUtilities.dll!Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.DataCollection.DataCollectionRequestHandler.HandleBeforeTestRunStart(Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Message message)
Microsoft.TestPlatform.CommunicationUtilities.dll!Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.DataCollection.DataCollectionRequestHandler.ProcessRequests()
datacollector.dll!Microsoft.VisualStudio.TestPlatform.DataCollector.DataCollectorMain.StartProcessing()
datacollector.dll!Microsoft.VisualStudio.TestPlatform.DataCollector.DataCollectorMain.Run(string[] args)
datacollector.dll!Microsoft.VisualStudio.TestPlatform.DataCollector.Program.Main(string[] args)

Environment:

  • Windows 10
  • .NET SDK 5.0.102

Repro steps:

  • git clone https://github.com/meziantou/Meziantou.Framework.git
  • cd Meziantou.Framework
  • git checkout f96e0db0ab979a7d8344ec92391a1136b19a14fe
  • dotnet build Meziantou.Framework.sln --configuration Debug /bl
  • dotnet test .\tests\Meziantou.Framework.SingleInstance.Tests\Meziantou.Framework.SingleInstance.Tests.csproj --configuration Debug --no-build --logger trx --collect:"XPlat Code Coverage" -f net461

=> This is the only project of the solution that hangs, and it works with other target frameworks (-f net5.0)
=> It works with coverlet 1.3.0
=> It works without --collect:"XPlat Code Coverage"

Metadata

Metadata

Assignees

No one assigned

    Labels

    Priority:3Nice to havebugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions