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;