[GHC] #16297: Access violation and hang with template haskell

GHC ghc-devs at haskell.org
Tue Feb 19 15:38:06 UTC 2019


#16297: Access violation and hang with template haskell
-------------------------------------+-------------------------------------
        Reporter:  jeiea             |                Owner:  (none)
            Type:  bug               |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  Compiler          |              Version:  8.6.3
      Resolution:                    |             Keywords:
Operating System:  Windows           |         Architecture:  x86_64
 Type of failure:  Compile-time      |  (amd64)
  crash or panic                     |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------
Description changed by jeiea:

Old description:

> I found this while building the haskell-ide-engine on windows. During
> that build I was stuck on two packages(fclabels, haskell-lsp-types).
>
> {{{
> D:\test>stack install --resolver lts-13.6 fclabels
> fclabels-2.0.3.3: configure
> fclabels-2.0.3.3: build
>
> --  While building package fclabels-2.0.3.3 using:
>       C:\sr\setup-exe-cache\x86_64-windows\Cabal-
> simple_Z6RU0evB_2.4.0.1_ghc-8.6.3.exe --builddir=.stack-
> work\dist\e626a42b build --ghc-options " -ddump-hi -ddump-to-file
> -fdiagnostics-color=always"
>     Process exited with code: ExitFailure 1
>     Logs have been written to: C:\sr\global-project\.stack-
> work\logs\fclabels-2.0.3.3.log
>
>     Configuring fclabels-2.0.3.3...
>     Preprocessing library for fclabels-2.0.3.3..
>     Building library for fclabels-2.0.3.3..
>     [ 1 of 10] Compiling Data.Label.Point ( src\Data\Label\Point.hs,
> .stack-work\dist\e626a42b\build\Data\Label\Point.o )
>     [ 2 of 10] Compiling Data.Label.Poly  ( src\Data\Label\Poly.hs,
> .stack-work\dist\e626a42b\build\Data\Label\Poly.o )
>     [ 3 of 10] Compiling Data.Label.Partial ( src\Data\Label\Partial.hs,
> .stack-work\dist\e626a42b\build\Data\Label\Partial.o )
>     [ 4 of 10] Compiling Data.Label.Mono  ( src\Data\Label\Mono.hs,
> .stack-work\dist\e626a42b\build\Data\Label\Mono.o )
>     [ 5 of 10] Compiling Data.Label.Failing ( src\Data\Label\Failing.hs,
> .stack-work\dist\e626a42b\build\Data\Label\Failing.o )
>     [ 6 of 10] Compiling Data.Label.Derive ( src\Data\Label\Derive.hs,
> .stack-work\dist\e626a42b\build\Data\Label\Derive.o )
>     [ 7 of 10] Compiling Data.Label       ( src\Data\Label.hs, .stack-
> work\dist\e626a42b\build\Data\Label.o )
>     [ 8 of 10] Compiling Data.Label.Base  ( src\Data\Label\Base.hs,
> .stack-work\dist\e626a42b\build\Data\Label\Base.o )
> -- doesn't terminate
> }}}
>
> {{{
> D:\test>stack install --resolver lts-13.6 haskell-lsp-types
> haskell-lsp-types-0.8.0.1: configure
> haskell-lsp-types-0.8.0.1: build
>
> --  While building package haskell-lsp-types-0.8.0.1 using:
>       C:\sr\setup-exe-cache\x86_64-windows\Cabal-
> simple_Z6RU0evB_2.4.0.1_ghc-8.6.3.exe --builddir=.stack-
> work\dist\e626a42b build --ghc-options " -ddump-hi -ddump-to-file
> -fdiagnostics-color=always"
>     Process exited with code: ExitFailure 11
>     Logs have been written to: D:\Hoj\Desktop\fclabels-2.0.3.3\.stack-
> work\logs\haskell-lsp-types-0.8.0.1.log
>
>     Configuring haskell-lsp-types-0.8.0.1...
>     Preprocessing library for haskell-lsp-types-0.8.0.1..
>     Building library for haskell-lsp-types-0.8.0.1..
>     [ 1 of 24] Compiling Language.Haskell.LSP.Types.Constants (
> src\Language\Haskell\LSP\Types\Constants.hs, .stack-
> work\dist\e626a42b\build\Language\Haskell\LSP\Types\Constants.o )
>     [ 2 of 24] Compiling Language.Haskell.LSP.Types.List (
> src\Language\Haskell\LSP\Types\List.hs, .stack-
> work\dist\e626a42b\build\Language\Haskell\LSP\Types\List.o )
>     [ 3 of 24] Compiling Language.Haskell.LSP.Types.DocumentFilter (
> src\Language\Haskell\LSP\Types\DocumentFilter.hs, .stack-
> work\dist\e626a42b\build\Language\Haskell\LSP\Types\DocumentFilter.o )
>
>     Access violation in generated code when reading 0x1017895900
>
>      Attempting to reconstruct a stack trace...
>
>        Frame    Code address
>      * 0x4ffd920        0x17c3f148 C:\sr\snapshots\3233b5e2\lib\x86_64
> -windows-
> ghc-8.6.3\aeson-1.4.2.0-nGorlomFPWK9VTcoGhjmV\HSaeson-1.4.2.0-nGorlomFPWK9VTcoGhjmV.o+0x2f040
> (aesonzm1zi4zi2zi0zmnGorlomFPWK9VTcoGhjmV_DataziAesonziTH_consToValue_info+0x688)
> }}}
>
> I don't know if those two issues are same.
>
> I tried simplifying the former.
>
> {{{
> -- A.hs
> {-# LANGUAGE NoMonomorphismRestriction #-}
> {-# LANGUAGE TemplateHaskell #-}
>
> module A
>   ( head
>   , tail
>   ) where
>
> -- import Prelude hiding (fst, snd, head, tail)
> -- import Control.Arrow (arr, Kleisli(..), ArrowApply, ArrowZero,
> ArrowChoice)
> import B (getLabel)
>
> -- data Point cat g i f o = Point (cat f o) (cat (cat o i, f) g)
>
> -- data PLens cat f o where
> --   PLens :: !(Point cat g i f o) -> PLens cat (f -> g) (o -> i)
> --   Id   :: ArrowApply cat => PLens cat f f
>
> -- type Lens cat f o = PLens cat (f -> f) (o -> o)
>
> -- head :: (ArrowZero arr, ArrowApply arr, ArrowChoice arr) => Lens arr
> [a] a
> -- tail :: (ArrowZero arr, ArrowApply arr, ArrowChoice arr) => Lens arr
> [a] [a]
>
> (head, tail) = $(getLabel ''[])
> }}}
>
> {{{
> -- B.hs
> {-# LANGUAGE TemplateHaskell #-}
> module B (getLabel) where
> import Language.Haskell.TH
>
> getLabel :: Name -> Q Exp
> getLabel = undefined
> }}}
>
> `stack exec ghc --resolver lts-13.6 -- A.hs B.hs` also hangs.

New description:

 I found this while building the haskell-ide-engine on windows. During that
 build I was stuck in two packages(fclabels, haskell-lsp-types).

 {{{
 D:\test>stack install --resolver lts-13.6 fclabels
 fclabels-2.0.3.3: configure
 fclabels-2.0.3.3: build

 --  While building package fclabels-2.0.3.3 using:
       C:\sr\setup-exe-cache\x86_64-windows\Cabal-
 simple_Z6RU0evB_2.4.0.1_ghc-8.6.3.exe --builddir=.stack-work\dist\e626a42b
 build --ghc-options " -ddump-hi -ddump-to-file -fdiagnostics-color=always"
     Process exited with code: ExitFailure 1
     Logs have been written to: C:\sr\global-project\.stack-
 work\logs\fclabels-2.0.3.3.log

     Configuring fclabels-2.0.3.3...
     Preprocessing library for fclabels-2.0.3.3..
     Building library for fclabels-2.0.3.3..
     [ 1 of 10] Compiling Data.Label.Point ( src\Data\Label\Point.hs,
 .stack-work\dist\e626a42b\build\Data\Label\Point.o )
     [ 2 of 10] Compiling Data.Label.Poly  ( src\Data\Label\Poly.hs,
 .stack-work\dist\e626a42b\build\Data\Label\Poly.o )
     [ 3 of 10] Compiling Data.Label.Partial ( src\Data\Label\Partial.hs,
 .stack-work\dist\e626a42b\build\Data\Label\Partial.o )
     [ 4 of 10] Compiling Data.Label.Mono  ( src\Data\Label\Mono.hs,
 .stack-work\dist\e626a42b\build\Data\Label\Mono.o )
     [ 5 of 10] Compiling Data.Label.Failing ( src\Data\Label\Failing.hs,
 .stack-work\dist\e626a42b\build\Data\Label\Failing.o )
     [ 6 of 10] Compiling Data.Label.Derive ( src\Data\Label\Derive.hs,
 .stack-work\dist\e626a42b\build\Data\Label\Derive.o )
     [ 7 of 10] Compiling Data.Label       ( src\Data\Label.hs, .stack-
 work\dist\e626a42b\build\Data\Label.o )
     [ 8 of 10] Compiling Data.Label.Base  ( src\Data\Label\Base.hs,
 .stack-work\dist\e626a42b\build\Data\Label\Base.o )
 -- doesn't terminate
 }}}

 {{{
 D:\test>stack install --resolver lts-13.6 haskell-lsp-types
 haskell-lsp-types-0.8.0.1: configure
 haskell-lsp-types-0.8.0.1: build

 --  While building package haskell-lsp-types-0.8.0.1 using:
       C:\sr\setup-exe-cache\x86_64-windows\Cabal-
 simple_Z6RU0evB_2.4.0.1_ghc-8.6.3.exe --builddir=.stack-work\dist\e626a42b
 build --ghc-options " -ddump-hi -ddump-to-file -fdiagnostics-color=always"
     Process exited with code: ExitFailure 11
     Logs have been written to: D:\Hoj\Desktop\fclabels-2.0.3.3\.stack-
 work\logs\haskell-lsp-types-0.8.0.1.log

     Configuring haskell-lsp-types-0.8.0.1...
     Preprocessing library for haskell-lsp-types-0.8.0.1..
     Building library for haskell-lsp-types-0.8.0.1..
     [ 1 of 24] Compiling Language.Haskell.LSP.Types.Constants (
 src\Language\Haskell\LSP\Types\Constants.hs, .stack-
 work\dist\e626a42b\build\Language\Haskell\LSP\Types\Constants.o )
     [ 2 of 24] Compiling Language.Haskell.LSP.Types.List (
 src\Language\Haskell\LSP\Types\List.hs, .stack-
 work\dist\e626a42b\build\Language\Haskell\LSP\Types\List.o )
     [ 3 of 24] Compiling Language.Haskell.LSP.Types.DocumentFilter (
 src\Language\Haskell\LSP\Types\DocumentFilter.hs, .stack-
 work\dist\e626a42b\build\Language\Haskell\LSP\Types\DocumentFilter.o )

     Access violation in generated code when reading 0x1017895900

      Attempting to reconstruct a stack trace...

        Frame    Code address
      * 0x4ffd920        0x17c3f148 C:\sr\snapshots\3233b5e2\lib\x86_64
 -windows-
 ghc-8.6.3\aeson-1.4.2.0-nGorlomFPWK9VTcoGhjmV\HSaeson-1.4.2.0-nGorlomFPWK9VTcoGhjmV.o+0x2f040
 (aesonzm1zi4zi2zi0zmnGorlomFPWK9VTcoGhjmV_DataziAesonziTH_consToValue_info+0x688)
 }}}

 I don't know if those two issues are same.

 I tried simplifying the former.

 {{{
 -- A.hs
 {-# LANGUAGE NoMonomorphismRestriction #-}
 {-# LANGUAGE TemplateHaskell #-}

 module A
   ( head
   , tail
   ) where

 -- import Prelude hiding (fst, snd, head, tail)
 -- import Control.Arrow (arr, Kleisli(..), ArrowApply, ArrowZero,
 ArrowChoice)
 import B (getLabel)

 -- data Point cat g i f o = Point (cat f o) (cat (cat o i, f) g)

 -- data PLens cat f o where
 --   PLens :: !(Point cat g i f o) -> PLens cat (f -> g) (o -> i)
 --   Id   :: ArrowApply cat => PLens cat f f

 -- type Lens cat f o = PLens cat (f -> f) (o -> o)

 -- head :: (ArrowZero arr, ArrowApply arr, ArrowChoice arr) => Lens arr
 [a] a
 -- tail :: (ArrowZero arr, ArrowApply arr, ArrowChoice arr) => Lens arr
 [a] [a]

 (head, tail) = $(getLabel ''[])
 }}}

 {{{
 -- B.hs
 {-# LANGUAGE TemplateHaskell #-}
 module B (getLabel) where
 import Language.Haskell.TH

 getLabel :: Name -> Q Exp
 getLabel = undefined
 }}}

 `stack exec ghc --resolver lts-13.6 -- A.hs B.hs` also hangs.

--

-- 
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/16297#comment:1>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list