summaryrefslogtreecommitdiff
path: root/libraries/ghc-heap
diff options
context:
space:
mode:
authorPeter Trommler <ptrommler@acm.org>2018-10-15 13:51:53 -0400
committerBen Gamari <ben@smart-cactus.org>2018-10-15 18:34:17 -0400
commit058c2813d882266309e8045af7a72eedecbf2dbb (patch)
tree564a33abed0d3920b200e562c49f30ae79568953 /libraries/ghc-heap
parent95ec7c88c7223508db3ba91d6ab9e303d0b062ad (diff)
downloadhaskell-058c2813d882266309e8045af7a72eedecbf2dbb.tar.gz
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
Diffstat (limited to 'libraries/ghc-heap')
-rw-r--r--libraries/ghc-heap/GHC/Exts/Heap/InfoTable.hsc5
1 files changed, 4 insertions, 1 deletions
diff --git a/libraries/ghc-heap/GHC/Exts/Heap/InfoTable.hsc b/libraries/ghc-heap/GHC/Exts/Heap/InfoTable.hsc
index 25fe4982aa..95151b45ee 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