From d258295a31d4f58fa7fda9e4a9e97e93e05aab96 Mon Sep 17 00:00:00 2001 From: Max Charlamb Date: Tue, 24 Feb 2026 22:31:26 -0500 Subject: [PATCH] fix --- .../Contracts/StackWalk/StackWalk_1.cs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Contracts/StackWalk/StackWalk_1.cs b/src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Contracts/StackWalk/StackWalk_1.cs index 281bf58b6d3fe3..296d2200dac4af 100644 --- a/src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Contracts/StackWalk/StackWalk_1.cs +++ b/src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Contracts/StackWalk/StackWalk_1.cs @@ -237,10 +237,18 @@ private bool IsManaged(TargetPointer ip, [NotNullWhen(true)] out CodeBlockHandle { IExecutionManager eman = _target.Contracts.ExecutionManager; TargetCodePointer codePointer = CodePointerUtils.CodePointerFromAddress(ip, _target); - if (eman.GetCodeBlockHandle(codePointer) is CodeBlockHandle cbh && cbh.Address != TargetPointer.Null) + try { - codeBlockHandle = cbh; - return true; + if (eman.GetCodeBlockHandle(codePointer) is CodeBlockHandle cbh && cbh.Address != TargetPointer.Null) + { + codeBlockHandle = cbh; + return true; + } + } + catch (VirtualReadException) + { + // If we fail to read memory while looking up the code block, the IP is not in managed code + // (or the data is corrupted). Treat as not managed and continue the walk. } codeBlockHandle = default; return false;