From bd6a64bc5275e47a69aa6a42eab10e1f3bf3faf5 Mon Sep 17 00:00:00 2001 From: Jan Vorlicek Date: Wed, 5 Jan 2022 17:19:16 +0100 Subject: [PATCH] Fix MethodDesc::CbStackPop for string ctors on x86 (#63391) This method was not taking into account the fact that string ctors don't have dummy this argument after a recent change. Stack walking in cases where prestub for the ctor was invoked resulted in a wrong unwinding of ESP for ctors with more than one argument. This change fixes it by removing "has this" flag from the signature before getting the stack arguments size. --- src/coreclr/vm/method.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/coreclr/vm/method.cpp b/src/coreclr/vm/method.cpp index 6e20c4d28f51c..4309978b13234 100644 --- a/src/coreclr/vm/method.cpp +++ b/src/coreclr/vm/method.cpp @@ -1656,6 +1656,13 @@ UINT MethodDesc::CbStackPop() SUPPORTS_DAC; MetaSig msig(this); ArgIterator argit(&msig); + + bool fCtorOfVariableSizedObject = msig.HasThis() && (GetMethodTable() == g_pStringClass) && IsCtor(); + if (fCtorOfVariableSizedObject) + { + msig.ClearHasThis(); + } + return argit.CbStackPop(); } #endif // TARGET_X86