Skip to content

Commit f0e64f5

Browse files
authored
[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.
1 parent 4951e38 commit f0e64f5

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/native/managed/cdacreader/src/Legacy/SOSDacImpl.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ internal sealed unsafe partial class SOSDacImpl
3232
private readonly Target _target;
3333

3434
// When this class is created, the runtime may not have loaded the string and object method tables and set the global pointers.
35-
// They should be set when actually requested via a DAC API, so we lazily read the global pointers.
35+
// This is also the case for the GetUsefulGlobals API, which can be called as part of load notifications before runtime start.
36+
// They should be set when actually requested via other DAC APIs, so we lazily read the global pointers.
3637
private readonly Lazy<TargetPointer> _stringMethodTable;
3738
private readonly Lazy<TargetPointer> _objectMethodTable;
3839

@@ -1243,8 +1244,10 @@ int ISOSDacInterface.GetUsefulGlobals(DacpUsefulGlobalsData* data)
12431244
{
12441245
data->ArrayMethodTable = _target.ReadPointer(
12451246
_target.ReadGlobalPointer(Constants.Globals.ObjectArrayMethodTable));
1246-
data->StringMethodTable = _stringMethodTable.Value;
1247-
data->ObjectMethodTable = _objectMethodTable.Value;
1247+
data->StringMethodTable = _target.ReadPointer(
1248+
_target.ReadGlobalPointer(Constants.Globals.StringMethodTable));
1249+
data->ObjectMethodTable = _target.ReadPointer(
1250+
_target.ReadGlobalPointer(Constants.Globals.ObjectMethodTable));
12481251
data->ExceptionMethodTable = _target.ReadPointer(
12491252
_target.ReadGlobalPointer(Constants.Globals.ExceptionMethodTable));
12501253
data->FreeMethodTable = _target.ReadPointer(

0 commit comments

Comments
 (0)