Skip to content

Windows x86: legacy DAC ICorDebug stack walk truncates in Mini dumps (aligned 8-byte debug-info read runs past the enumerated range) #136331

Open

Description

@max-charlamb

Summary

On Windows x86, the legacy DAC cannot read the compressed debug info of some JIT'd methods in a Mini dump. ICorDebugStackWalk then stops early, so clrstack -i shows only part of the stack. The cDAC and Full dumps are not affected.

Reproduced on .NET 10.0.10 and .NET 11.0.0-rtm.26480.113 (see the repro below). CI also saw intermittent failures with Heap dumps on .NET 10; the repro below did not fail with Heap dumps on either runtime.

Where it fails

For a method with no variables, the bounds blob is the last chunk of its debug info. CompressDebugInfo::EnumMemoryRegions pads the end of that blob to sizeof(NibbleReader::NibbleChunkType), which is 4 bytes on x86. DoBounds / ReadFromBitOffsets reads the bounds through aligned 8-byte loads (PTR_UINT64). When the padded end is only 4-byte aligned, the final load covers 4 bytes that were never written to the dump, so the DAC read fails.

Evidence from a real failing dump (.NET 11.0.0-rtm.26480.113, win-x86, clrstack -i stops right after TestHarness.Stop):

0:000> db 0b61fc78 L30
0b61fc78  22 bf a5 bc bd bf 40 f1-4f 0e ff 00 39 00 36 03
0b61fc88  82 10 89 7c b4 ad 70 05-00 00 00 00 ?? ?? ?? ??     <- mapped memory ends at 0b61fc94

0:000> dq 0b61fc88 L1
0b61fc88  0570adb4`7c891082
0:000> dq 0b61fc90 L1
0b61fc90  ????????`????????                                    <- bytes 90..93 mapped, 94..97 not
  • 0b61fc84 is the debug info of SosHarnessScenarios.AtArgsLocals(), which has no args or locals.
  • The enumerated range ends at 0b61fc94 (4-byte aligned, not 8-byte aligned).
  • The aligned 8-byte load at 0b61fc90 therefore straddles the end of mapped memory.

Why it is data-dependent

Debug-info blobs of methods JIT'd back to back sit next to each other in the loader heap. If the blob after the over-read belongs to a method that is also on the stack, those bytes are in the dump and the read succeeds. The walk only fails when the next blob belongs to a method that is not on the stack, so it is not enumerated.

This is why the same configuration can pass or fail depending on code layout. A walk through a long run of consecutive stack methods can pass, while a stack with an off-stack method JIT'd in between fails.

Minimal repro

Requires an x86 .NET 11 runtime and an x86 dotnet-dump.

Repro.csproj:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net11.0</TargetFramework>
    <PlatformTarget>x86</PlatformTarget>
    <UseAppHost>false</UseAppHost>
  </PropertyGroup>
</Project>

Generate.ps1 creates Program.cs with N chained stack methods M0..M{N-1}. Each one first calls an off-stack helper H<i>, then calls the next method. The last one takes a Mini dump of its own process:

param([int]$Count = 40)
$sb = New-Object System.Text.StringBuilder
[void]$sb.AppendLine(@'
using System;
using System.Diagnostics;
using System.Runtime.CompilerServices;

internal static class Program
{
    private static void Main() => M0();
'@)
for ($i = 0; $i -lt $Count; $i++) {
    $next = if ($i -lt $Count - 1) { "M$($i + 1)();" } else { "Snapshot();" }
    [void]$sb.AppendLine("    [MethodImpl(MethodImplOptions.NoInlining)] private static void H$i() { }")
    [void]$sb.AppendLine("    [MethodImpl(MethodImplOptions.NoInlining)] private static void M$i() { H$i(); $next }")
}
[void]$sb.AppendLine(@'
    [MethodImpl(MethodImplOptions.NoInlining)]
    private static void Snapshot()
    {
        using Process p = Process.Start(new ProcessStartInfo("dotnet-dump", $"collect -p {Environment.ProcessId} --type Mini -o repro.dmp") { UseShellExecute = false })!;
        p.WaitForExit();
    }
}
'@)
[IO.File]::WriteAllText("$PSScriptRoot\Program.cs", $sb.ToString())

Steps:

  1. Run ./Generate.ps1 -Count 40, then dotnet build -c Debug.

  2. Run the app with the x86 dotnet host. It writes repro.dmp.

  3. Analyze with an x86 dotnet-dump:

    dotnet-dump analyze repro.dmp
    > runtimes --usecdac false
    > clrstack -i
    

Expected: all M0..M39 frames, then Stack walk complete.

Actual: about 8 frames, ending in Program.Snapshot and the top M* frames. There is no Stack walk complete. and the remaining frames are missing.

Activity

  1. dotnet-policy-service commented on Oct 22, 2026

    @dotnet-policy-service
    Contributor

    Tagging subscribers to this area: @steveisok, @tommcdon, @dotnet/dotnet-diag
    See info in area-owners.md if you want to be subscribed.

  2. added
    untriaged
    on Oct 22, 2026
  3. changed the title [-]Windows x86 legacy DAC can truncate ICorDebug stack walks in reduced dumps due to 8-byte bounds reads[/-] [+]Windows x86: legacy DAC ICorDebug stack walk truncates in Mini dumps (aligned 8-byte debug-info read runs past the enumerated range)[/+] on Oct 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-Diagnostics-coreclruntriaged

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions