BadImageFormatException crash after tests complete with --coverage on .NET 10 + NUnit
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 45/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Quiet
- Tech stack
- csharp
- Domain
- devtools, testing-qa
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.
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"
- Dominant language
- C#
- Stars
- 125
- Forks
- 17
- Avg merge
- 1h 17m
- Merged PRs (30d)
- 2
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.
More from microsoft/codecoverage
-
Difficulty 4/5 3-5 days Newbie friendliness 52/100
microsoft/codecoverage#246 · 6 comments ·
-
Difficulty 4/5 3-5 days Newbie friendliness 55/100
microsoft/codecoverage#237 · 1 comment ·
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
microsoft/codecoverage#234 · 1 comment · 2 reactions ·
-
Difficulty 4/5 3-5 days Newbie friendliness 52/100
microsoft/codecoverage#233 · 2 reactions ·
-
Difficulty 5/5 Over a week Newbie friendliness 28/100
microsoft/codecoverage#232 · 6 comments ·
All issues in microsoft/codecoverage
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
nightscout/nocturne#1379 ·
-
priority-0
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
Difficulty 1/5 Under an hour Newbie friendliness 78/100
StackExchange/StackExchange.Redis#3249 ·
-
[Feat] 조합 영역 구분선 개선 Open
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
documentation
Difficulty 2/5 1-3 hours Newbie friendliness 72/100