microsoft / microsoft/codecoverage
BadImageFormatException crash after tests complete with --coverage on .NET 10 + NUnit
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 125
- Forks
- 17
- Avg merge
- 1h 17m
- Merged PRs (30d)
- 2
Description
Description
When running tests with --coverage flag using Microsoft Testing Platform (MTP) on .NET 10 with NUnit, tests pass successfully and the coverage file is generated, but the process crashes during async cleanup with BadImageFormatException: Index not found.
Environment
- OS: Ubuntu Linux (GitHub Actions runner) and macOS ARM64
- .NET SDK: 10.0.101
- Test Framework: NUnit 4.4.0
- Test Adapter: NUnit3TestAdapter 6.1.0
- MTP Packages:
- Microsoft.Testing.Platform.MSBuild 2.0.2
- Microsoft.Testing.Extensions.Telemetry 2.0.2
- Microsoft.Testing.Extensions.CodeCoverage 18.3.1 and 18.3.2 (both crash)
Reproduction
- Create a .NET 10 test project with NUnit and MTP enabled
- Configure
global.jsonwith"test": { "runner": "Microsoft.Testing.Platform" } - Run:
dotnet test --coverage --coverage-output-format cobertura
Expected Behavior
Tests complete and process exits with code 0.
Actual Behavior
Tests pass (762 passed in our case), coverage file IS generated, but then:
NUnit Adapter 6.1.0.0: Test execution complete
Error output: Unhandled exception. System.BadImageFormatException: Index not found. (0x80131124)
at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1.AsyncStateMachineBox`1.MoveNext(Thread threadPoolThread)
at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1.AsyncStateMachineBox`1.MoveNext()
at System.Threading.Tasks.AwaitTaskContinuation.RunOrScheduleAction(IAsyncStateMachineBox box, Boolean allowInlining)
--- End of stack trace from previous location ---
at System.Threading.Tasks.Task.<>c.<ThrowAsync>b__124_1(Object state)
at System.Threading.ThreadPoolWorkQueue.Dispatch()
at System.Threading.PortableThreadPool.WorkerThread.WorkerThreadStart()
at System.Threading.Thread.StartCallback()
In process file artifacts produced:
- /path/to/TestResults/<guid>.cobertura.xml
Test run summary: Failed!
error: 1
total: 764
failed: 0
succeeded: 762
skipped: 2
Exit code: 134 (SIGABRT)
Workaround
Running without --coverage flag works fine:
dotnet test # Works, exit code 0
dotnet test --coverage # Crashes with exit code 134
Notes
- The crash occurs AFTER tests complete and coverage file is written
- The exception is in async cleanup/finalization phase
- Tested with both CodeCoverage 18.3.1 and 18.3.2 - same crash
dotnet-coverage collectCLI tool also shows "Profiler was not initialized"
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the failure with the .NET 10 project described in global.json using dotnet test --coverage --coverage-output-format cobertura, then compare it with dotnet test without coverage. Trace the Microsoft Testing Platform and CodeCoverage cleanup path, including the dotnet-coverage collect entry point. Done means coverage is generated, cleanup completes without BadImageFormatException, and the process exits with code 0.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- devtools, testing-qa
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100