Commit aa7fb9a6 authored by Tamar Christina's avatar Tamar Christina

Fix GHCi segfault in Windows 32bit

Summary:
Add missing calling convention to function pointer,
incorrect `cdecl` calling convention which should be `stdcall`
on x86 was causing the stack to be corrupted. When it tried to
return from the function the return pointer would be invalid.

Test Plan: ./validate

Reviewers: austin, erikd, bgamari, thomie

Reviewed By: bgamari, thomie

Differential Revision: https://phabricator.haskell.org/D1683

GHC Trac Issues: #11234
parent c12fc2e6
......@@ -242,8 +242,8 @@ static void machoInitSymbolsWithoutUnderscore( void );
#if defined(OBJFORMAT_PEi386)
// MingW-w64 is missing these from the implementation. So we have to look them up
typedef DLL_DIRECTORY_COOKIE(*LPAddDLLDirectory)(PCWSTR NewDirectory);
typedef WINBOOL(*LPRemoveDLLDirectory)(DLL_DIRECTORY_COOKIE Cookie);
typedef DLL_DIRECTORY_COOKIE(WINAPI *LPAddDLLDirectory)(PCWSTR NewDirectory);
typedef WINBOOL(WINAPI *LPRemoveDLLDirectory)(DLL_DIRECTORY_COOKIE Cookie);
#endif
static void freeProddableBlocks (ObjectCode *oc);
......@@ -920,7 +920,6 @@ error:
*/
pathchar* findSystemLibrary(pathchar* dll_name)
{
IF_DEBUG(linker, debugBelch("\nfindSystemLibrary: dll_name = `%" PATH_FMT "'\n", dll_name));
#if defined(OBJFORMAT_PEi386)
......@@ -941,7 +940,6 @@ pathchar* findSystemLibrary(pathchar* dll_name)
}
return result;
#else
(void)(dll_name); // Function not implemented for other platforms.
return NULL;
......@@ -1064,9 +1062,7 @@ HsBool removeLibrarySearchPath(HsPtr dll_path_index)
else
{
warnMissingKBLibraryPaths();
result = SetEnvironmentVariableW(L"PATH", (LPCWSTR)dll_path_index);
free(dll_path_index);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment