question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

StackOverflow exception when resolving TypeReference SqlDbType

See original GitHub issue

Hello,

I’m attempting to use the global tool to add code coverage to our code base. It’s a mix of .NET Framework 4.6.1 and .NET Standard 2.0.0 as far as unit tests are concerned, and the .NET Framework projects are not SDK-style. For the purposes of this test I did move them to SDK-style projects for testing but I saw this issue both with and without SDK-style .NET Framework projects. Unfortunately I can’t share sample code because the libraries being used are proprietary and I’m not sure which part is failing to replicate it in a smaller solution.

We have a list of projects: .NET Framework Unit Test 1 .NET Framework Library 20 .NET Framework Library 21 .NET Standard Library 31 .NET Standard Library 32 .NET Standard Library 33

Reference tree that works:

  • NET Framework Unit Test 1
    • NET Framework Library 21

Reference tree that breaks and I’m trying to solve:

  • NET Framework Unit Test 1
    • NET Framework Library 20
      • NET Standard Library 31
        • NET Standard Library 33
      • NET Standard Library 32
      • NET Standard Library 33
    • NET Framework Library 21

When I build the solution I go to .NET Framework Unit Test 1’s output folder and I see all of the libraries DLLs and their PDBs. I check other output folders and the size of the PDBs match. When I run code coverage it seems to run into warnings and hangs.

coverlet C:\Software\Tests\UnitTests\CoverletTestingLibraryTests\bin\Debug\net461\CoverletTestingLibraryTests.dll --target "dotnet" --targetargs "vstest C:\Software\Tests\UnitTests\CoverletTestingLibraryTests\bin\Debug\net461\CoverletTestingLibraryTests.dll" --format cobertura --output "C:/Software"

The warning message I get is: “BadImageFormatException during MetadataReaderProvider.FromPortablePdbStream in InstrumentationHelper.PortablePdbHasLocalSource, unable to check if module has got local source.” but it is not clear to me which PDB it is complaining about. These PDBs also aren’t portable ones, they are specified as full PDBs in the csproj.

Here is the full log up to the hang:

Instrumented module:C:\Software\Tests\UnitTests\CoverletTestingLibraryTests\bin\Debug\net461\NetStandard.Library.31.dll

BadImageFormatException during MetadataReaderProvider.FromPortablePdbStream in InstrumentationHelper.PortablePdbHasLocalSource, unable to check if module has got local source.

Instrumented module:C:\Software\Tests\UnitTests\CoverletTestingLibraryTests\bin\Debug\net461\NetStandard.Library.32.dll

BadImageFormatException during MetadataReaderProvider.FromPortablePdbStream in InstrumentationHelper.PortablePdbHasLocalSource, unable to check if module has got local source.

If I run the same command again it will output the same messages but instead of hanging it will continue to completion. The unit tests succeed but it only outputs coverage for 4 of the 5 modules. I assume that is because the previous run attempted to alter the PDBs, somehow failed, and the altered PDBs are no longer valid for one of the projects. I believe that because it claims the PDB is a public PDB when it is not: “Unable to instrument module: C:\Software\Tests\UnitTests\CoverletTestingLibraryTests\bin\Debug\net461\NetFramework.Library.20.dll because : Could not find the ‘/NAMES’ stream: the PDB file may be a public symbol file instead of a private symbol file”.

Here is the full log of the second run:

PS C:\Users\cjewett> coverlet C:\Software\Tests\UnitTests\CoverletTestingLibraryTests\bin\Debug\net461\CoverletTestingLibraryTests.dll --target "dotnet" --targetargs "vstest C:\Software\Tests\UnitTests\CoverletTestingLibraryTests\bin\Debug\net461\CoverletTestingLibraryTests.dll" --format cobertura --output "C:/Software" --verbosity detailed

Instrumented module: 'C:\Software\Tests\UnitTests\CoverletTestingLibraryTests\bin\Debug\net461\NetStandard.Library.31.dll'

BadImageFormatException during MetadataReaderProvider.FromPortablePdbStream in InstrumentationHelper.PortablePdbHasLocalSource, unable to check if module has got local source.

Instrumented module: 'C:\Software\Tests\UnitTests\CoverletTestingLibraryTests\bin\Debug\net461\NetStandard.Library.32.dll'

BadImageFormatException during MetadataReaderProvider.FromPortablePdbStream in InstrumentationHelper.PortablePdbHasLocalSource, unable to check if module has got local source.

Unable to instrument module: C:\Software\Tests\UnitTests\CoverletTestingLibraryTests\bin\Debug\net461\NetFramework.Library.20.dll because : Could not find the '/NAMES' stream: the PDB file may be a public symbol file instead of a private symbol file

BadImageFormatException during MetadataReaderProvider.FromPortablePdbStream in InstrumentationHelper.PortablePdbHasLocalSource, unable to check if module has got local source.

Instrumented module: 'C:\Software\Tests\UnitTests\CoverletTestingLibraryTests\bin\Debug\net461\NetStandard.Library.33.dll'

BadImageFormatException during MetadataReaderProvider.FromPortablePdbStream in InstrumentationHelper.PortablePdbHasLocalSource, unable to check if module has got local source.

Instrumented module: 'C:\Software\Tests\UnitTests\CoverletTestingLibraryTests\bin\Debug\net461\NetFramework.Library.21.dll'

Unable to instrument module: C:\Software\Tests\UnitTests\CoverletTestingLibraryTests\bin\Debug\net461\Microsoft.SqlServer.Types.dll because : No symbol found for file: C:\Software\Tests\UnitTests\CoverletTestingLibraryTests\bin\Debug\net461\Microsoft.SqlServer.Types.dll

Unable to instrument module: C:\Software\Tests\UnitTests\CoverletTestingLibraryTests\bin\Debug\net461\protobuf-net.dll, embedded pdb without local source files, [C:\code\protobuf-net\src\protobuf-net\obj\Release\net40\protobuf-net.Version.cs]

Microsoft (R) Test Execution Command Line Tool Version 16.6.0
Copyright (c) Microsoft Corporation.  All rights reserved.
Starting test execution, please wait...
A total of 1 test files matched the specified pattern.
Test Run Successful.
Total tests: 2
     Passed: 2
 Total time: 1.6138 Seconds

Calculating coverage result...

Calculating the results worked. I just omitted here.

The assembly missing code coverage is .NET Framework 20 which is also the one it complains about having a public PDB instead of a private PDB. The reason that happens though is because the previous run froze. Any ideas what might be going on here? Also, what steps can I take to debug this locally and confirm why this happens so I can see if it is possible to replicate easily?

Thanks for taking a look!

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:14

github_iconTop GitHub Comments

1reaction
Cjewettcommented, Jul 24, 2020

@MarcoRossignoli Thanks for continuing this conversation. I’ve updated https://github.com/Cjewett/CoverletIssue with net48 reproduce steps. SqlDbType seems to resolve correctly now but SqlBulkCopyOptions does not and results in an endless loop. I’m going to mess around with Mono.Cecil and try to figure out how the NET_CORE symbol is set.

0reactions
MarcoRossignolicommented, Jan 3, 2021

close for stale conversation, feel free to reopen if needed.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot instantiate the type in Generics - java
You have to use a generic type parameter instead of ? : public <T> List<T> runQuerySQLToGetList(String SQL, Object[] params, Class<T> clazz) ...
Read more >
Handling Stack Overflow exceptions that arise from using a ...
From my understanding, you cannot actually catch a stackoverflow exception which is understandable but I would really like a way for the ...
Read more >
StackOverflowException Class (System)
The exception that is thrown when the execution stack exceeds the stack size. This class cannot be inherited.
Read more >
IIS 6 + ASP.NET web service - DW20 and stackoverflow ...
The processes that hit the CPU hard are dw20.exe . I am unsure why Dr Watson is involved here. Event Log shows an...
Read more >
How to troubleshoot StackOverflow exceptions
Click on Exceptions. DebugDiag 2 Collection Step 4 7. Click on Add Exception 8. On the left select Stack Overflow or manually type...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found