Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix DAC getting alloc context for thread #103610

Merged
merged 1 commit into from
Jun 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/coreclr/debug/daccess/request.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -720,7 +720,7 @@ ClrDataAccess::GetThreadAllocData(CLRDATA_ADDRESS addr, struct DacpAllocData *da

Thread* thread = PTR_Thread(TO_TADDR(addr));

gc_alloc_context* pAllocContext = thread->GetAllocContext();
PTR_gc_alloc_context pAllocContext = thread->GetAllocContext();

if (pAllocContext != NULL)
{
Expand Down Expand Up @@ -827,7 +827,7 @@ HRESULT ClrDataAccess::GetThreadDataImpl(CLRDATA_ADDRESS threadAddr, struct Dacp
threadData->state = thread->m_State;
threadData->preemptiveGCDisabled = thread->m_fPreemptiveGCDisabled;

gc_alloc_context* allocContext = thread->GetAllocContext();
PTR_gc_alloc_context allocContext = thread->GetAllocContext();
if (allocContext)
{
threadData->allocContextPtr = TO_CDADDR(allocContext->alloc_ptr);
Expand Down
8 changes: 5 additions & 3 deletions src/coreclr/vm/threads.h
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,8 @@ class TailCallTls
const PortableTailCallFrame* GetFrame() { return m_frame; }
};

typedef DPTR(struct gc_alloc_context) PTR_gc_alloc_context;

// #ThreadClass
//
// A code:Thread contains all the per-thread information needed by the runtime. We can get this
Expand Down Expand Up @@ -947,12 +949,12 @@ class Thread

// We store a pointer to this thread's alloc context here for easier introspection
// from other threads and diagnostic tools
gc_alloc_context* m_alloc_context;
PTR_gc_alloc_context m_alloc_context;

public:
inline void InitAllocContext() { LIMITED_METHOD_CONTRACT; m_alloc_context = &t_thread_alloc_context; }
inline void InitAllocContext() { LIMITED_METHOD_CONTRACT; m_alloc_context = PTR_gc_alloc_context(&t_thread_alloc_context); }

inline gc_alloc_context *GetAllocContext() { LIMITED_METHOD_CONTRACT; return m_alloc_context; }
inline PTR_gc_alloc_context GetAllocContext() { LIMITED_METHOD_CONTRACT; return m_alloc_context; }

// This is the type handle of the first object in the alloc context at the time
// we fire the AllocationTick event. It's only for tooling purpose.
Expand Down
Loading