Skip to content

Commit

Permalink
Fix UMEntryThunkCache::GetUMEntryThunk (#55834)
Browse files Browse the repository at this point in the history
The function was initializing UMThunkMarshInfo allocated from Stub heap
without using the ExecutableWriterHolder. That causes a crash when a
hosting application calls coreclr_create_delegate.
This was discovered in .NET 6 Preview 6 when running a xamarin app that
uses a special host.

This code path is exercised only by coreclr_create_delegate.
  • Loading branch information
janvorli committed Jul 16, 2021
1 parent b8c799d commit 57c4e7e
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/coreclr/vm/dllimportcallback.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,8 @@ UMEntryThunk *UMEntryThunkCache::GetUMEntryThunk(MethodDesc *pMD)
Holder<UMThunkMarshInfo *, DoNothing, UMEntryThunkCache::DestroyMarshInfo> miHolder;
miHolder.Assign(pMarshInfo);

pMarshInfo->LoadTimeInit(pMD);
ExecutableWriterHolder<UMThunkMarshInfo> marshInfoWriterHolder(pMarshInfo, sizeof(UMThunkMarshInfo));
marshInfoWriterHolder.GetRW()->LoadTimeInit(pMD);

ExecutableWriterHolder<UMEntryThunk> thunkWriterHolder(pThunk, sizeof(UMEntryThunk));
thunkWriterHolder.GetRW()->LoadTimeInit(pThunk, NULL, NULL, pMarshInfo, pMD);
Expand Down

0 comments on commit 57c4e7e

Please sign in to comment.