From f0e64f5f0166da5a66c931ad0b2210b3e3cf51a3 Mon Sep 17 00:00:00 2001 From: Elinor Fung Date: Thu, 12 Dec 2024 13:58:03 -0800 Subject: [PATCH] [cdac] Always re-read global pointers in GetUsefulGlobals (#110633) `GetUsefulGlobals` can be called before the runtime is actually initialized, so we need to re-read the global pointers instead of storing any of them. --- src/native/managed/cdacreader/src/Legacy/SOSDacImpl.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/native/managed/cdacreader/src/Legacy/SOSDacImpl.cs b/src/native/managed/cdacreader/src/Legacy/SOSDacImpl.cs index fbd747b3df172..7fef6b111de27 100644 --- a/src/native/managed/cdacreader/src/Legacy/SOSDacImpl.cs +++ b/src/native/managed/cdacreader/src/Legacy/SOSDacImpl.cs @@ -32,7 +32,8 @@ internal sealed unsafe partial class SOSDacImpl private readonly Target _target; // When this class is created, the runtime may not have loaded the string and object method tables and set the global pointers. - // They should be set when actually requested via a DAC API, so we lazily read the global pointers. + // This is also the case for the GetUsefulGlobals API, which can be called as part of load notifications before runtime start. + // They should be set when actually requested via other DAC APIs, so we lazily read the global pointers. private readonly Lazy _stringMethodTable; private readonly Lazy _objectMethodTable; @@ -1243,8 +1244,10 @@ int ISOSDacInterface.GetUsefulGlobals(DacpUsefulGlobalsData* data) { data->ArrayMethodTable = _target.ReadPointer( _target.ReadGlobalPointer(Constants.Globals.ObjectArrayMethodTable)); - data->StringMethodTable = _stringMethodTable.Value; - data->ObjectMethodTable = _objectMethodTable.Value; + data->StringMethodTable = _target.ReadPointer( + _target.ReadGlobalPointer(Constants.Globals.StringMethodTable)); + data->ObjectMethodTable = _target.ReadPointer( + _target.ReadGlobalPointer(Constants.Globals.ObjectMethodTable)); data->ExceptionMethodTable = _target.ReadPointer( _target.ReadGlobalPointer(Constants.Globals.ExceptionMethodTable)); data->FreeMethodTable = _target.ReadPointer(