Skip to content

Commit

Permalink
[cdac] Always re-read global pointers in GetUsefulGlobals (dotnet#110633
Browse files Browse the repository at this point in the history
)

`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.
  • Loading branch information
elinor-fung authored Dec 12, 2024
1 parent 4951e38 commit f0e64f5
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/native/managed/cdacreader/src/Legacy/SOSDacImpl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<TargetPointer> _stringMethodTable;
private readonly Lazy<TargetPointer> _objectMethodTable;

Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit f0e64f5

Please sign in to comment.