Skip to content

Commit

Permalink
Include all dlerror messages to DllNotFoundException (#70964)
Browse files Browse the repository at this point in the history
  • Loading branch information
HJLeee authored Jun 22, 2022
1 parent ead19a3 commit fdc3b51
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,14 @@ public void Throw(string libraryName)

public void TrackErrorMessage(string? message)
{
_errorMessage = message;
if (_errorMessage == null)
{
_errorMessage = Environment.NewLine;
}
if (!_errorMessage.Contains(message))
{
_errorMessage += message + Environment.NewLine;
}
}
}
}
Expand Down
12 changes: 12 additions & 0 deletions src/coreclr/vm/nativelibrary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ namespace
LIMITED_METHOD_CONTRACT;
m_hr = E_FAIL;
m_priorityOfLastError = 0;
m_message = SString(SString::Utf8, "\n");
}

VOID TrackErrorCode()
Expand Down Expand Up @@ -137,7 +138,18 @@ namespace

void SetMessage(LPCSTR message)
{
#ifdef TARGET_UNIX
//Append dlerror() messages
SString new_message = SString(SString::Utf8, message);
SString::Iterator i = m_message.Begin();
if (!m_message.Find(i, new_message))
{
m_message += new_message;
m_message += SString(SString::Utf8, "\n");
}
#else
m_message = SString(SString::Utf8, message);
#endif
}

HRESULT m_hr;
Expand Down

0 comments on commit fdc3b51

Please sign in to comment.