summaryrefslogtreecommitdiff
path: root/compiler/ghci
diff options
context:
space:
mode:
authorÖmer Sinan Ağacan <omeragacan@gmail.com>2018-07-04 09:12:01 +0300
committerÖmer Sinan Ağacan <omeragacan@gmail.com>2018-07-04 09:12:27 +0300
commit15bb4e0b6c08b1f8f5511f04af14242f13833ed1 (patch)
tree2e50184512814b19d4c17d1e0f3ab7a14767e2fa /compiler/ghci
parent6cb189d1d465d18879b6a4b107fbdce53b2ebf56 (diff)
downloadhaskell-15bb4e0b6c08b1f8f5511f04af14242f13833ed1.tar.gz
Fix nptr field alignment in RtClosureInspect
`extractSubTerms` (which is extracting pointer and non-pointer fields of a closure) was computing the alignment incorrectly when aligning a 64-bit value (e.g. a Double) on i386 by aligning it to 64-bits instead of to word size (32-bits). This is documented in `mkVirtHeapOffsetsWithPadding`: > Align the start offset (eg, 2-byte value should be 2-byte aligned). > But not more than to a word. Fixes #15061 Test Plan: Validated on both 32-bit and 64-bit. 32-bit fails with various unrelated stat failures, but no actual test failures. Reviewers: hvr, bgamari Reviewed By: bgamari Subscribers: simonpj, rwbarton, thomie, carter GHC Trac Issues: #15061 Differential Revision: https://phabricator.haskell.org/D4906
Diffstat (limited to 'compiler/ghci')
-rw-r--r--compiler/ghci/RtClosureInspect.hs11
1 files changed, 7 insertions, 4 deletions
diff --git a/compiler/ghci/RtClosureInspect.hs b/compiler/ghci/RtClosureInspect.hs
index 81bdb613b5..d540983139 100644
--- a/compiler/ghci/RtClosureInspect.hs
+++ b/compiler/ghci/RtClosureInspect.hs
@@ -742,11 +742,14 @@ extractSubTerms recurse clos = liftM thdOf3 . go 0 0
dflags <- getDynFlags
let word_size = wORD_SIZE dflags
size_b = primRepSizeB dflags rep
- -- Fields are always aligned.
- !aligned_idx = roundUpTo arr_i size_b
+ -- Align the start offset (eg, 2-byte value should be 2-byte
+ -- aligned). But not more than to a word. The offset calculation
+ -- should be the same with the offset calculation in
+ -- StgCmmLayout.mkVirtHeapOffsetsWithPadding.
+ !aligned_idx = roundUpTo arr_i (min word_size size_b)
!new_arr_i = aligned_idx + size_b
ws | size_b < word_size =
- [index size_b array aligned_idx word_size]
+ [index size_b aligned_idx word_size]
| otherwise =
let (q, r) = size_b `quotRem` word_size
in ASSERT( r == 0 )
@@ -761,7 +764,7 @@ extractSubTerms recurse clos = liftM thdOf3 . go 0 0
(error "unboxedTupleTerm: no HValue for unboxed tuple") terms
-- Extract a sub-word sized field from a word
- index item_size_b array index_b word_size =
+ index item_size_b index_b word_size =
(word .&. (mask `shiftL` moveBytes)) `shiftR` moveBytes
where
mask :: Word