
#14516: getGCStats was broken in 8.2 -------------------------------------+------------------------------------- Reporter: chrisdone | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: | Version: 8.2.1 libraries/base | Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: None/Unknown Unknown/Multiple | Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- The {{{getGCStats}}} function from {{{GHC.Stats}}} defined [http://hackage.haskell.org/package/base-4.10.0.0/docs/GHC-Stats.html#g:2 here] expects the {{{numGCs}}} field to be an {{{Int64}}}, but in the new {{{RTSStats}}} API, it's a {{{Word32}}}, so the function inside is no longer correct: {{{ getGCStats = do ... allocaBytes ((232)) $ \p -> do {-# LINE 284 "GHC/Stats.hsc" #-} getRTSStats_ p bytesAllocated <- ((\hsc_ptr -> peekByteOff hsc_ptr 8)) p {-# LINE 286 "GHC/Stats.hsc" #-} numGcs <- ((\hsc_ptr -> peekByteOff hsc_ptr 0)) p {-# LINE 287 "GHC/Stats.hsc" #-} numByteUsageSamples <- ((\hsc_ptr -> peekByteOff hsc_ptr 4)) p }}} The {{{numGcs}}} line peeks off 8 bytes instead of 4, and so it leads to packages like my {{{weigh}}} package claiming that you've done "4,294,967,299" garbage collections. I've updated {{{weigh}}} to use the new API with some CPP {{{#if}}}'s. Given that the new API changes pretty much everything, both names and types (it took a couple hours to make weigh support the old and the new one), and that the old "compatibility" API is returning bad results, honestly I wouldn't have minded if the old API was just removed in 8.2. Leaving it up to you whether this should be fixed in an 8.2.3 bugfix release or just leave it to be removed in 8.4. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14516 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler