Fix null reference handling in VSD stubs on amd64
authorJan Vorlicek <janvorli@microsoft.com>
Thu, 16 Apr 2020 08:53:48 +0000 (10:53 +0200)
committerJan Vorlicek <janvorli@microsoft.com>
Thu, 16 Apr 2020 08:53:48 +0000 (10:53 +0200)
commitaf2e9f47a6be6ac9acb435c63f5c57823b3952f2
tree4abf1f0bb8ba734ef41dd8eb9ac08944f7b4b731
parentb44492d10a783726a12513c9292ef69489dde468
Fix null reference handling in VSD stubs on amd64

When null "this" pointer is passed to the VSD dispatch and resolve
stubs on amd64, it is not converted to NullReferenceException and it
generates AccessViolationException instead, tearing down the process.
This happens due to the fact that AdjustContextForVirtualStub always
returns FALSE on amd64. It behaves correctly on ARM, x86 and ARM64.
This issue has been present at least since .NET Framework 4.5.

This change fixes it by implementing the AdjustContextForVirtualStub for
amd64 too. I've also found that we were doing this adjustment for ARM
and x86 only at some places while ARM64 needs it too. So I've made it
unconditional for all architectures at all places.
src/coreclr/src/vm/amd64/excepamd64.cpp
src/coreclr/src/vm/amd64/virtualcallstubcpu.hpp