From cd1bfa1601bd20310aeb570f388943ad82ddbe81 Mon Sep 17 00:00:00 2001 From: Max Charlamb <44248479+max-charlamb@users.noreply.github.com> Date: Mon, 22 Sep 2025 13:35:11 -0400 Subject: [PATCH 1/4] properly enumerate uninstrumented bounds --- src/coreclr/vm/debuginfostore.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/coreclr/vm/debuginfostore.cpp b/src/coreclr/vm/debuginfostore.cpp index 9852d79e8324f2..21541cc48d8188 100644 --- a/src/coreclr/vm/debuginfostore.cpp +++ b/src/coreclr/vm/debuginfostore.cpp @@ -1406,12 +1406,19 @@ void CompressDebugInfo::EnumMemoryRegions(CLRDataEnumMemoryFlags flags, PTR_BYTE _ASSERTE(flagByte == 0); } - NibbleReader r(pDebugInfo, 12 /* maximum size of compressed 2 UINT32s */); - + NibbleReader r(pDebugInfo, 24 /* maximum size of compressed 4 UINT32s */); + ULONG cbBounds = r.ReadEncodedU32(); + ULONG cbUninstrumentedBounds = 0; + if (cbBounds == DebugInfoBoundsHasInstrumentedBounds) + { + // This means we have instrumented bounds. + cbBounds = r.ReadEncodedU32(); + cbUninstrumentedBounds = r.ReadEncodedU32(); + } ULONG cbVars = r.ReadEncodedU32(); - pDebugInfo += r.GetNextByteIndex() + cbBounds + cbVars; + pDebugInfo += r.GetNextByteIndex() + cbBounds + cbUninstrumentedBounds + cbVars; DacEnumMemoryRegion(dac_cast(pStart), pDebugInfo - pStart); } From 18978ce49cc8d31e4ee5270b8ca75895b6f0023b Mon Sep 17 00:00:00 2001 From: Max Charlamb <44248479+max-charlamb@users.noreply.github.com> Date: Mon, 22 Sep 2025 13:36:39 -0400 Subject: [PATCH 2/4] spacing --- src/coreclr/vm/debuginfostore.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/coreclr/vm/debuginfostore.cpp b/src/coreclr/vm/debuginfostore.cpp index 21541cc48d8188..56cb6c35705e69 100644 --- a/src/coreclr/vm/debuginfostore.cpp +++ b/src/coreclr/vm/debuginfostore.cpp @@ -1407,7 +1407,7 @@ void CompressDebugInfo::EnumMemoryRegions(CLRDataEnumMemoryFlags flags, PTR_BYTE } NibbleReader r(pDebugInfo, 24 /* maximum size of compressed 4 UINT32s */); - + ULONG cbBounds = r.ReadEncodedU32(); ULONG cbUninstrumentedBounds = 0; if (cbBounds == DebugInfoBoundsHasInstrumentedBounds) From 9480006acdc181d712592f3cf4919590c92b660c Mon Sep 17 00:00:00 2001 From: Max Charlamb <44248479+max-charlamb@users.noreply.github.com> Date: Mon, 22 Sep 2025 22:22:53 -0400 Subject: [PATCH 3/4] add padding for multi-byte reads --- src/coreclr/vm/debuginfostore.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/coreclr/vm/debuginfostore.cpp b/src/coreclr/vm/debuginfostore.cpp index 56cb6c35705e69..d734de2ee3cbbf 100644 --- a/src/coreclr/vm/debuginfostore.cpp +++ b/src/coreclr/vm/debuginfostore.cpp @@ -1420,6 +1420,10 @@ void CompressDebugInfo::EnumMemoryRegions(CLRDataEnumMemoryFlags flags, PTR_BYTE pDebugInfo += r.GetNextByteIndex() + cbBounds + cbUninstrumentedBounds + cbVars; + // NibbleReader reads in units of sizeof(NibbleChunkType) + // So we need to account for any partial chunk at the end. + pDebugInfo += sizeof(NibbleReader::NibbleChunkType) - 1; + DacEnumMemoryRegion(dac_cast(pStart), pDebugInfo - pStart); } #endif // DACCESS_COMPILE From 0cf85c0410b294f606353cc994c0cf4b2fe784cd Mon Sep 17 00:00:00 2001 From: Max Charlamb <44248479+max-charlamb@users.noreply.github.com> Date: Tue, 23 Sep 2025 12:04:56 -0400 Subject: [PATCH 4/4] use alignup --- src/coreclr/vm/debuginfostore.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/coreclr/vm/debuginfostore.cpp b/src/coreclr/vm/debuginfostore.cpp index d734de2ee3cbbf..2687329aea9862 100644 --- a/src/coreclr/vm/debuginfostore.cpp +++ b/src/coreclr/vm/debuginfostore.cpp @@ -1422,7 +1422,7 @@ void CompressDebugInfo::EnumMemoryRegions(CLRDataEnumMemoryFlags flags, PTR_BYTE // NibbleReader reads in units of sizeof(NibbleChunkType) // So we need to account for any partial chunk at the end. - pDebugInfo += sizeof(NibbleReader::NibbleChunkType) - 1; + pDebugInfo = AlignUp(dac_cast(pDebugInfo), sizeof(NibbleReader::NibbleChunkType)); DacEnumMemoryRegion(dac_cast(pStart), pDebugInfo - pStart); }