Description
Inspecting the value of a thread static field of the generic class is failing with the following AV (which is then swallowed and show nothing)
00 0000001d`ff0fb4e0 00007fff`5710e41d mscordaccore!__TPtrBase::GetAddr+0xb [C:\Dev\runtime\src\coreclr\src\inc\daccess.h @ 882]
01 0000001d`ff0fb4f0 00007fff`5716c465 mscordaccore!__DPtr<Object>::__DPtr<Object>+0x2d [C:\Dev\runtime\src\coreclr\src\inc\daccess.h @ 1158]
02 0000001d`ff0fb520 00007fff`571acc34 mscordaccore!ObjectFromHandle+0x75 [C:\Dev\runtime\src\coreclr\src\vm\gchandleutilities.h @ 49]
03 0000001d`ff0fb560 00007fff`571b021d mscordaccore!ThreadLocalModule::GetPrecomputedGCStaticsBasePointer+0x74 [C:\Dev\runtime\src\coreclr\src\vm\threadstatics.h @ 176]
04 0000001d`ff0fb5b0 00007fff`6eb42e10 mscordaccore!ClrDataAccess::GetThreadLocalModuleData+0x1ad [C:\Dev\runtime\src\coreclr\src\debug\daccess\request.cpp @ 3240]
05 0000001d`ff0fb7d0 00007fff`6eb424c4 sos!DisplayThreadStatic+0x200 [C:\Dev\diagnostics\src\SOS\Strike\util.cpp @ 730]
06 0000001d`ff0fb970 00007fff`6eb20a13 sos!DisplayFields+0x604 [C:\Dev\diagnostics\src\SOS\Strike\util.cpp @ 984]
07 0000001d`ff0fc530 00007fff`6cdb47b3 sos!DumpClass+0x7c3 [C:\Dev\diagnostics\src\SOS\Strike\strike.cpp @ 1257]
Here is the call to GetPrecomputedGCStaticsBasePointer
This is a wrong call because it would fail if the m_pGCStatics
is null
, the code would dereferencing null
. In my scenario, at runtime, the field is indeed null
.
Commenting out that line (wrongly, it should be done conditionally) just sadly leads me to:
diagnostics/src/SOS/Strike/util.cpp
Line 590 in 6b66e69
This feels like #50
This is blocking me from making progress for dotnet/runtime#31940
I am trying to nail a race condition between a managed thread and the finalizer thread. I can capture the time travel trace, but without thread static inspection support for generic class, I can't track down what is wrong with the data structure.
Here is a very simple repro:
using System;
namespace ThreadStaticInspectionRepro
{
class ThreadStaticHolder<T>
{
[ThreadStatic]
public static T ThreadStaticValue;
}
class Program
{
static void Main(string[] args)
{
ThreadStaticHolder<int>.ThreadStaticValue = 12;
Console.ReadLine();
}
}
}
Launch it under WInDBG, break-in at the ReadLine
, and inspect the ThreadStaticHolder
class will lead to the failure