From 3bb0124686cf897db5e0c69b96c73e1699a89829 Mon Sep 17 00:00:00 2001 From: Mike McLaughlin Date: Thu, 20 Jan 2022 17:16:56 -0800 Subject: [PATCH 1/2] Fix crash when VS4Mac is debugging VS4Mac arm64 Issue: https://github.com/dotnet/runtime/issues/64011 --- src/coreclr/debug/daccess/dacdbiimpl.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/coreclr/debug/daccess/dacdbiimpl.cpp b/src/coreclr/debug/daccess/dacdbiimpl.cpp index ebb5d12c0ce3aa..6c57f6ffc33e57 100644 --- a/src/coreclr/debug/daccess/dacdbiimpl.cpp +++ b/src/coreclr/debug/daccess/dacdbiimpl.cpp @@ -5428,6 +5428,11 @@ GENERICS_TYPE_TOKEN DacDbiInterfaceImpl::ResolveExactGenericArgsToken(DWORD if (dwExactGenericArgsTokenIndex == 0) { + // In a rare case of VS4Mac debugging VS4Mac ARM64 optimized code we get a null token for certain stack frame variables + if (rawToken == 0) + { + return rawToken; + } // In this case the real generics type token is the MethodTable of the "this" object. // Note that we want the target address here. From c9900e5f3e1c280741f301a4602b19dc98476b3f Mon Sep 17 00:00:00 2001 From: Mike McLaughlin Date: Thu, 20 Jan 2022 21:32:52 -0800 Subject: [PATCH 2/2] Code review feedback. Add better comment --- src/coreclr/debug/daccess/dacdbiimpl.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/coreclr/debug/daccess/dacdbiimpl.cpp b/src/coreclr/debug/daccess/dacdbiimpl.cpp index 6c57f6ffc33e57..4efcd8a8323b4f 100644 --- a/src/coreclr/debug/daccess/dacdbiimpl.cpp +++ b/src/coreclr/debug/daccess/dacdbiimpl.cpp @@ -5428,7 +5428,12 @@ GENERICS_TYPE_TOKEN DacDbiInterfaceImpl::ResolveExactGenericArgsToken(DWORD if (dwExactGenericArgsTokenIndex == 0) { - // In a rare case of VS4Mac debugging VS4Mac ARM64 optimized code we get a null token for certain stack frame variables + // In a rare case of VS4Mac debugging VS4Mac ARM64 optimized code we get a null generics argument token. We aren't sure + // why the token is null, it may be a bug or it may be by design in the runtime. In the interest of time we are working + // around the issue rather than investigating the root cause. This workaround should only cause us to degrade generic + // types from exact type parameters to approximate or canonical type parameters. In the future if we discover this issue + // is happening more frequently than we expect or the workaround is more impactful than we expect we may need to remove + // this workaround and resolve the underlying issue. if (rawToken == 0) { return rawToken;