Skip to content

Commit

Permalink
Mark forward delegate stubs as not having hidden arguments
Browse files Browse the repository at this point in the history
Forward delegate interop stubs do not use hidden argument. The hidden argument passed to them is a random value that can lead to crash during stackwalking.

Fixes dotnet#62613
  • Loading branch information
jkotas committed Dec 10, 2021
1 parent 506463c commit 1d69304
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 6 deletions.
5 changes: 1 addition & 4 deletions src/coreclr/vm/dllimport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -784,14 +784,11 @@ class ILStubState : public StubState
{
// Struct marshal stubs don't actually call anything so they do not need the secrect parameter.
}
#ifndef HOST_64BIT
else if (SF_IsForwardDelegateStub(m_dwStubFlags))
{
// Forward delegate stubs get all the context they need in 'this' so they
// don't use the secret parameter. Except for AMD64 where we use the secret
// argument to pass the real target to the stub-for-host.
// don't use the secret parameter.
}
#endif // !HOST_64BIT
else
{
// All other IL stubs will need to use the secret parameter.
Expand Down
1 change: 0 additions & 1 deletion src/coreclr/vm/metasig.h
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,6 @@ DEFINE_METASIG_T(IM(Str_BindingFlags_Binder_Obj_ArrObj_ArrParameterModifier_Cult
s g(BINDING_FLAGS) C(BINDER) j a(j) a(g(PARAMETER_MODIFIER)) C(CULTURE_INFO) a(s), j))
DEFINE_METASIG_T(IM(Str_Type_Str_RetVoid, s C(TYPE) s, v))
DEFINE_METASIG_T(SM(Delegate_RetIntPtr, C(DELEGATE), I))
DEFINE_METASIG_T(SM(Delegate_RefIntPtr_RetIntPtr, C(DELEGATE) r(I), I))
DEFINE_METASIG_T(SM(RuntimeTypeHandle_RetType, g(RT_TYPE_HANDLE), C(TYPE)))
DEFINE_METASIG_T(SM(RuntimeTypeHandle_RetIntPtr, g(RT_TYPE_HANDLE), I))
DEFINE_METASIG_T(SM(RuntimeMethodHandle_RetIntPtr, g(METHOD_HANDLE), I))
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/vm/method.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2606,7 +2606,7 @@ class DynamicMethodDesc : public StoredSigMethodDesc
bool HasMDContextArg()
{
LIMITED_METHOD_CONTRACT;
return IsCLRToCOMStub() || IsPInvokeStub();
return IsCLRToCOMStub() || (IsPInvokeStub() && !IsDelegateStub());
}

//
Expand Down

0 comments on commit 1d69304

Please sign in to comment.