Skip to content

Code coverage: crash when instrumenting CoreLib with Coverlet #26913

@pjanotti

Description

@pjanotti

The instrumentation added by coverlet adds a reference to "coverlet.tracker", however, this reference is causing a crash in coreclr when trying to jit the instrumented System.Private.CoreLib. At this stage I'm not sure yet about the best way to handle the issue, for now opening it on CoreFx repo where we collect coverage numbers for System.Private.CoreLib.

Basically when jitting a instrumented method from System.Private.CoreLib (coverage runs by default use the IL version of CoreLib) reference to "coverlet.tracker" causes a null reference exception because the call:

https://github.com/dotnet/coreclr/blob/1f28125ad1f9975fbe68dd6839908aa6e63fc43b/src/vm/coreassemblyspec.cpp#L135-136

return null so later the code hits the null exception at:

https://github.com/dotnet/coreclr/blob/1f28125ad1f9975fbe68dd6839908aa6e63fc43b/src/vm/coreassemblyspec.cpp#L171

In debug builds it a, corresponding, earlier assert checking for pBinder null:

  Assert failure(PID 591480 [0x00090678], Thread: 575160 [0x8c6b8]): pBinder != NULL

  CORECLR! AssemblySpec::Bind + 0x6D9 (0x00007ffb`9e7b3059)
  CORECLR! AppDomain::BindAssemblySpec + 0xCFE (0x00007ffb`9e68d9de)
  CORECLR! PEFile::LoadAssembly + 0x611 (0x00007ffb`9e514581)
  CORECLR! Module::LoadAssembly + 0x776 (0x00007ffb`9e63aa56)
  CORECLR! Assembly::FindModuleByTypeRef + 0xEE4 (0x00007ffb`9e4183a4)
  CORECLR! ClassLoader::LoadTypeDefOrRefThrowing + 0xA06 (0x00007ffb`9e554d86)
  CORECLR! MemberLoader::GetDescFromMemberRef + 0xDB3 (0x00007ffb`9e7d9d63)
  CORECLR! CEEInfo::resolveToken + 0xD24 (0x00007ffb`9e5e5b54)
  CLRJIT! Compiler::impResolveToken + 0xA4 (0x00007ffb`a177cee4)
  CLRJIT! Compiler::impImportBlockCode + 0x9E4D (0x00007ffb`a17643dd)
      File: c:\s\github\pjanotti\coreclr\src\vm\coreassemblyspec.cpp Line: 142
      Image: C:\s\github\pjanotti\corefx\bin\testhost\netcoreapp-Windows_NT-Debug-x64\dotnet.exe

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions