Skip to content

GHC 9.4+ hangs indefinitely when compiling the monus-weighted-search package

Summary

GHC 9.4+ hangs indefinitely when compiling the Control.Monad.Heap module in the monus-weighted-search package. The hang seems to happen in the Constructed Product Result analysis.

Steps to reproduce

  1. git clone https://github.com/oisdk/monus-weighted-search.git
  2. cd monus-weighted-search
  3. Observe the following terminates: cabal build -w ghc-9.2.8 lib:monus-weighted-search
  4. Observe the following hangs indefinitely: cabal build -w ghc-9.4.1 lib:monus-weighted-search

Additional diagnostic steps that confirm the issue location:

  1. Update monus-weighted-search.cabal so the ghc-options includes -v
  2. Observe cabal build -w ghc-9.4.1 lib:monus-weighted-search gets stuck in the Constructed Product Result analysis
    
         *** Simplifier [Control.Monad.Heap]:
         Result size of Simplifier iteration=1
           = {terms: 10,731, types: 40,759, coercions: 17,664, joins: 12/491}
         Result size of Simplifier iteration=2
           = {terms: 10,711, types: 40,727, coercions: 16,669, joins: 12/487}
         Result size of Simplifier
           = {terms: 10,711, types: 40,727, coercions: 16,669, joins: 12/487}
         !!! Simplifier [Control.Monad.Heap]: finished in 106.51 milliseconds, allocated 182.290 megabytes
         *** Demand analysis [Control.Monad.Heap]:
         Result size of Demand analysis
           = {terms: 10,711, types: 40,727, coercions: 16,669, joins: 12/487}
         !!! Demand analysis [Control.Monad.Heap]: finished in 19.83 milliseconds, allocated 32.152 megabytes
         *** Constructed Product Result analysis [Control.Monad.Heap]:
         
  3. Update monus-weighted-search.cabal so the ghc-options includes -fno-strictness
  4. Observe cabal build -w ghc-9.4.1 lib:monus-weighted-search terminates

Expected behavior

GHC should successfully compile the package. Alternatively, if there is an issue with the code, GHC should report an error rather than hang indefinitely.

Environment

  • GHC version used: 9.4.1, 9.4.2, 9.4.4, 9.4.8, 9.6.6, 9.10.1 (confirmed hanging in all these versions), 9.2.8 (confirmed terminating)
  • Operating System: macOS 15.3.2
  • System Architecture: arm64
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information