Skip to content

HEAD segfaults on Windows when building large packages (e.g., lsp-types)

When using nightly Windows HEAD bindists, I have noticed that it will segfault when building large packages. Unfortunately, I don't know of a minimal way to reproduce the bug other than to build a large Hackage library with head.hackage. The lsp-types-1.6.0.0 library provides a good example of this. To reproduce, do the following:

  1. Download a nightly x86_64-windows-validate bindist. At the time of writing, I am using the one from here, at commit 3c0e3793.

  2. Using head.hackage, check out the lsp-types-1.6.0.0 library:

    ./head.hackage/scripts/patch-tool unpack lsp-types-1.6.0.0
  3. Build lsp-types-1.6.0.0 using the nightly Windows bindist. It should eventually produce a segfault that looks roughly like this one:

    $ cabal build lsp-types
    
    <elided>
    
    [45 of 52] Compiling Language.LSP.Types.Registration ( src\Language\LSP\Types\Registration.hs, C:\\Users\winferno\Documents\Hacki
    ng\Haskell\staging\dist-newstyle\build\x86_64-windows\ghc-9.5.20221105\lsp-types-1.6.0.0\build\Language\LSP\Types\Registration.o
    )
    
    src\Language\LSP\Types\Registration.hs:128:1: error: [GHC-55017]
        Illegal type variable name: `'
        When splicing a TH declaration
    Access violation in generated code when executing data at 0x7ff6992263d9
    
     Attempting to reconstruct a stack trace...
    
       Frame        Code address
     * 0xe29c6fd9f0 0x7ff6992263d9 C:\Users\winferno\Software\ghc-9.5.20221105\bin\ghc-9.5.20221105.exe+0x50363d9
    
    Error: cabal-3.8.1.0.exe: Failed to build lsp-types-1.6.0.0. The build process
    terminated with exit code 11

    I've also seen the segfault happen without the Illegal type variable name part:

    [45 of 52] Compiling Language.LSP.Types.Registration ( src\Language\LSP\Types\Registration.hs, C:\\Users\winferno\Documents\Hacki
    ng\Haskell\staging\dist-newstyle\build\x86_64-windows\ghc-9.5.20221105\lsp-types-1.6.0.0\build\Language\LSP\Types\Registration.o
    )
    
    Access violation in generated code when reading 0xffffffffffffffff
    
     Attempting to reconstruct a stack trace...
    
       Frame        Code address
     * 0xc27adfd970 0x7ff695a5c188 C:\Users\winferno\Software\ghc-9.5.20221105\bin\ghc-9.5.20221105.exe+0x186c188
    
    Error: cabal-3.8.1.0.exe: Failed to build lsp-types-1.6.0.0. The build process
    terminated with exit code 11
  4. Curiously, if you re-run cabal build lsp-types, it will be able to compile the module that segfaulted above (Language.LSP.Types.Registration), but it will segfault on a later module:

    $ cabal build lsp-types
    
    <elided>
    
    [47 of 52] Compiling Language.LSP.Types.Initialize ( src\Language\LSP\Types\Initialize.hs, C:\\Users\winferno\Documents\Hacking\H
    askell\staging\dist-newstyle\build\x86_64-windows\ghc-9.5.20221105\lsp-types-1.6.0.0\build\Language\LSP\Types\Initialize.o )
    
    Access violation in generated code when executing data at 0x7ef4cc37b0ba
    
     Attempting to reconstruct a stack trace...
    
       Frame        Code address
     * 0xeb45cfda80 0x7ef4cc37b0ba
    
    Error: cabal-3.8.1.0.exe: Failed to build lsp-types-1.6.0.0. The build process
    terminated with exit code 11

    If I then re-run cabal build lsp-types a third time, then compilation will succeed.

    On the other hand, if I run cabal clean and then run cabal build lsp-tyes afresh, then I will reliably reproduce the first segfault at Language.LSP.Types.Registration observed above.

As far as I can tell, this only affects HEAD, and not any GHC version from 9.4 or earlier.

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information