Skip to content

Commit ac6d868

Browse files
Fix createdump SIGSEGV on Heap dumps with interpreter active (dotnet#128163)
> [!NOTE] > This PR was authored with assistance from GitHub Copilot. Fixes dotnet#128044. ## Problem createdump SIGSEGVs on Linux when generating a Heap-type minidump for a process running interpreted code. The crash reproduces locally with the `InterpreterStack` DumpTests debuggee and matches the CI failure that prompted `<DumpTypes>Full</DumpTypes>` to be added as a temporary workaround. The faulting backtrace is: ``` #0 Thread::IsAddressInStack threads.cpp:6741 #1 Thread::EnumMemoryRegionsWorker threads.cpp:6909 (calls IsAddressInStack(currentSP)) #2 Thread::EnumMemoryRegions threads.cpp #3 ThreadStore::EnumMemoryRegions #4 ClrDataAccess::EnumMemDumpAllThreadsStack #5 ClrDataAccess::EnumMemoryRegionsWorkerHeap (HEAP2-only path) ``` ## Root cause `Thread::m_pInterpThreadContext` was declared as a raw `InterpThreadContext *`. In non-DAC code that's a normal host pointer, but in DAC mode the field's value is a target-process address. When `IsAddressInStack` (a DAC-callable helper) dereferenced `m_pInterpThreadContext->pStackStart` it read from a target-process address as if it were a host address, which faults inside createdump. ## Fix Change the field type to `PTR_InterpThreadContext` (DPTR), matching the treatment of other Thread fields like `m_pFrame`. In non-DAC builds `DPTR(T)` is just `T*`, so there is no overhead or behavior change. In DAC builds the read goes through `__DPtr<T>` and marshals correctly from the target. Also remove the `<DumpTypes>Full</DumpTypes>` workaround on the `InterpreterStack` DumpTests debuggee so the Heap path that originally failed is exercised again. ## Validation Locally reproduced the original SIGSEGV on Linux x64 with the auto-dump mechanism (`DOTNET_DbgMiniDumpType=2` + `DOTNET_Interpreter=MethodA`) running the `InterpreterStack` debuggee. With this fix applied, createdump produces a complete Heap dump (~74 MB) instead of crashing. --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 78a3f96 commit ac6d868

4 files changed

Lines changed: 2 additions & 6 deletions

File tree

src/coreclr/vm/common.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ typedef DPTR(class DelegateEEClass) PTR_DelegateEEClass;
124124
typedef VPTR(class EECodeManager) PTR_EECodeManager;
125125
#ifdef FEATURE_INTERPRETER
126126
typedef VPTR(class InterpreterCodeManager) PTR_InterpreterCodeManager;
127+
typedef DPTR(struct InterpThreadContext) PTR_InterpThreadContext;
127128
#endif
128129
typedef DPTR(class RangeSectionMap) PTR_RangeSectionMap;
129130
typedef DPTR(class EEConfig) PTR_EEConfig;

src/coreclr/vm/threads.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -921,7 +921,7 @@ class Thread
921921

922922
#ifdef FEATURE_INTERPRETER
923923
public:
924-
InterpThreadContext *m_pInterpThreadContext;
924+
PTR_InterpThreadContext m_pInterpThreadContext;
925925
InterpThreadContext* GetInterpThreadContext();
926926
InterpThreadContext* GetOrCreateInterpThreadContext();
927927
#endif // FEATURE_INTERPRETER

src/native/managed/cdac/tests/DumpTests/Debuggees/InterpreterStack/InterpreterStack.csproj

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<!-- Full dumps only: Linux createdump segfaults during heap-dump region
4-
enumeration when the interpreter is active. Tracked by
5-
https://github.com/dotnet/runtime/issues/128044 — revisit once fixed. -->
6-
<DumpTypes>Full</DumpTypes>
73
<R2RModes>Jit</R2RModes>
84
<!-- Selectively interpret MethodA/B/C while Main and CoreLib remain JIT'd,
95
producing a mixed stack with InterpreterFrame transition boundaries.

src/native/managed/cdac/tests/DumpTests/InterpreterStackDumpTests.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ namespace Microsoft.Diagnostics.DataContractReader.DumpTests;
2222
public class InterpreterStackDumpTests : DumpTestBase
2323
{
2424
protected override string DebuggeeName => "InterpreterStack";
25-
protected override string DumpType => "full";
2625

2726
private void SkipIfInterpreterNotAvailable()
2827
{

0 commit comments

Comments
 (0)