[commit: ghc] master: Fix GHCi segfault in Windows 32bit (aa7fb9a)

git at git.haskell.org git at git.haskell.org
Tue Dec 22 05:21:08 UTC 2015


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/aa7fb9a64da740eb42e56e085adc445f0103e743/ghc

>---------------------------------------------------------------

commit aa7fb9a64da740eb42e56e085adc445f0103e743
Author: Tamar Christina <tamar at zhox.com>
Date:   Mon Dec 21 21:02:46 2015 +0100

    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


>---------------------------------------------------------------

aa7fb9a64da740eb42e56e085adc445f0103e743
 rts/Linker.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/rts/Linker.c b/rts/Linker.c
index 7ca7e94..a082ba7 100644
--- a/rts/Linker.c
+++ b/rts/Linker.c
@@ -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);
         }
 



More information about the ghc-commits mailing list