Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix UMEntryThunkCache::GetUMEntryThunk #55834

Merged
merged 1 commit into from
Jul 16, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Fix UMEntryThunkCache::GetUMEntryThunk
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
commit cce74266d1176c10c3339bff168d384b7285e2e8
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