[commit: ghc] master: ghc-heap: Fix writing closures on big endian (058c281)

git at git.haskell.org git at git.haskell.org
Tue Oct 16 00:00:21 UTC 2018


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

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

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

commit 058c2813d882266309e8045af7a72eedecbf2dbb
Author: Peter Trommler <ptrommler at acm.org>
Date:   Mon Oct 15 13:51:53 2018 -0400

    ghc-heap: Fix writing closures on big endian
    
    We need to write the closure type as a HalfWord not
    an Int. On big endian systems the closure type ends up being zero
    (the upper word of the Int) making the closure an invalid object.
    
    Test Plan: validate (preferably on a big endian system)
    
    Reviewers: bgamari, hvr, erikd, simonmar
    
    Reviewed By: simonmar
    
    Subscribers: rwbarton, carter
    
    Differential Revision: https://phabricator.haskell.org/D5212


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

058c2813d882266309e8045af7a72eedecbf2dbb
 libraries/ghc-heap/GHC/Exts/Heap/InfoTable.hsc | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/libraries/ghc-heap/GHC/Exts/Heap/InfoTable.hsc b/libraries/ghc-heap/GHC/Exts/Heap/InfoTable.hsc
index 25fe498..95151b4 100644
--- a/libraries/ghc-heap/GHC/Exts/Heap/InfoTable.hsc
+++ b/libraries/ghc-heap/GHC/Exts/Heap/InfoTable.hsc
@@ -59,7 +59,7 @@ pokeItbl a0 itbl = do
 #endif
   (#poke StgInfoTable, layout.payload.ptrs) a0 (ptrs itbl)
   (#poke StgInfoTable, layout.payload.nptrs) a0 (nptrs itbl)
-  (#poke StgInfoTable, type) a0 (fromEnum (tipe itbl))
+  (#poke StgInfoTable, type) a0 (toHalfWord (fromEnum (tipe itbl)))
 #if __GLASGOW_HASKELL__ > 804
   (#poke StgInfoTable, srt) a0 (srtlen itbl)
 #else
@@ -72,6 +72,9 @@ pokeItbl a0 itbl = do
     Just (Left xs) -> pokeArray code_offset xs
     Just (Right xs) -> pokeArray code_offset xs
 #endif
+  where
+    toHalfWord :: Int -> HalfWord
+    toHalfWord i = fromIntegral i
 
 -- | Size in bytes of a standard InfoTable
 itblSize :: Int



More information about the ghc-commits mailing list