Skip to content

Commit

Permalink
fix debug assert around string literals (dotnet#75576)
Browse files Browse the repository at this point in the history
  • Loading branch information
EgorBo authored Sep 14, 2022
1 parent 8de1809 commit 36aa98b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/coreclr/jit/ee_il_dll.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1628,7 +1628,19 @@ const WCHAR* Compiler::eeGetCPString(size_t strHandle)
return (nullptr);
}

CORINFO_String* asString = *((CORINFO_String**)strHandle);
CORINFO_String* asString = nullptr;
if (impGetStringClass() == *((CORINFO_CLASS_HANDLE*)strHandle))
{
// strHandle is a frozen string
// We assume strHandle is never an "interior" pointer in a frozen string
// (jit is not expected to perform such foldings)
asString = (CORINFO_String*)strHandle;
}
else
{
// strHandle is a pinned handle to a string object
asString = *((CORINFO_String**)strHandle);
}

if (ReadProcessMemory(GetCurrentProcess(), asString, buff, sizeof(buff), nullptr) == 0)
{
Expand Down
5 changes: 5 additions & 0 deletions src/coreclr/jit/morph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11161,6 +11161,11 @@ GenTree* Compiler::fgMorphSmpOp(GenTree* tree, MorphAddrContext* mac, bool* optA
//
if (!tree->AsIndir()->IsVolatile())
{
if (op1->IsIconHandle(GTF_ICON_STR_HDL))
{
tree->gtFlags |= (GTF_IND_INVARIANT | GTF_IND_NONFAULTING | GTF_IND_NONNULL);
}

/* Try to Fold *(&X) into X */
if (op1->gtOper == GT_ADDR)
{
Expand Down

0 comments on commit 36aa98b

Please sign in to comment.