[GHC] #10504: GHC panics with dsImpSpecs on SPECIALISE pragma with -fhpc enabled

#10504: GHC panics with dsImpSpecs on SPECIALISE pragma with -fhpc enabled -------------------------------------+------------------------------------- Reporter: nh2 | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.10.1 Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: Compile-time Unknown/Multiple | crash Test Case: | Blocked By: Blocking: | Related Tickets: Differential Revisions: | -------------------------------------+------------------------------------- Minimal example code: https://github.com/nh2/ghc-omit-interface-pragmas- dsImpSpecs-bug/ I'm encountering a problem that prevents me from using Haskell program coverage on a code base, getting a GHC panic referring to `dsImpSpecs`. This looks pretty much like this old bug: https://ghc.haskell.org/trac/ghc/ticket/4870 I checked that it happens on GHC 7.8.4 and GHC 7.10.1. ---- The problem happens when I run `cabal build --ghc-options "-fhpc"`, giving me {{{ Package has never been configured. Configuring with default flags. If this fails, please run configure manually. Resolving dependencies... Configuring ghc-omit-interface-pragmas-dsImpSpecs-bug-0.1.0.0... Building ghc-omit-interface-pragmas-dsImpSpecs-bug-0.1.0.0... Preprocessing library ghc-omit-interface-pragmas-dsImpSpecs-bug-0.1.0.0... [1 of 2] Compiling A ( src/A.hs, dist/build/A.o ) [2 of 2] Compiling B ( src/B.hs, dist/build/B.o ) src/B.hs:5:1: Warning: SPECIALISE pragma for non-overloaded function ‘myfun’ ghc: panic! (the 'impossible' happened) (GHC version 7.8.4 for x86_64-unknown-linux): dsImpSpecs ghc-omit-interface-pragmas-dsImpSpecs-bug-0.1.0.0:A.myfun{v rpu} [gid] Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug $ ghc --version The Glorious Glasgow Haskell Compilation System, version 7.8.4 $ cabal --version cabal-install version 1.18.0.8 using version 1.18.1.5 of the Cabal library }}} This doesn't happen when I compile directly with `ghc --make`: {{{ $ cd src && ghc --make -fhpc -fomit-interface-pragmas B.hs -Wall [1 of 2] Compiling A ( A.hs, A.o ) [2 of 2] Compiling B ( B.hs, B.o ) }}} So running cabal with `-v`, I see that the problem happens in: {{{ /home/niklas/opt/ghc-7.8/bin/ghc --make -fbuilding-cabal-package -O -static -dynamic-too -dynosuf dyn_o -dynhisuf dyn_hi -outputdir dist/build -odir dist/build -hidir dist/build -stubdir dist/build -i -idist/build -isrc -idist/build/autogen -Idist/build/autogen -Idist/build -optP-include -optPdist/build/autogen/cabal_macros.h -package-name ghc-omit-interface- pragmas-dsImpSpecs-bug-0.1.0.0 -hide-all-packages -package-db dist/package.conf.inplace -package-id base-4.7.0.2-bfd89587617e381ae01b8dd7b6c7f1c1 -XHaskell98 B A -Wall -fhpc [1 of 2] Compiling A ( src/A.hs, dist/build/A.o ) [2 of 2] Compiling B ( src/B.hs, dist/build/B.o ) src/B.hs:5:1: Warning: SPECIALISE pragma for non-overloaded function ‘myfun’ ghc: panic! (the 'impossible' happened) (GHC version 7.8.4 for x86_64-unknown-linux): dsImpSpecs ghc-omit-interface-pragmas-dsImpSpecs-bug-0.1.0.0:A.myfun{v rpu} [gid] Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug }}} So there it be some flag that cabal passes to GHC that makes this GHC crash appear. Nevertheless, it's a panic, so I guess it's a bug in GHC. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10504 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10504: GHC panics with dsImpSpecs on SPECIALISE pragma with -fhpc enabled -------------------------------------+------------------------------------- Reporter: nh2 | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.10.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple crash | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: -------------------------------------+------------------------------------- Comment (by nh2): Ok, I found what makes the difference, `-O` is the culprit. With `-O`: {{{ $ ghc --make -O -isrc B A -Wall -fhpc [2 of 2] Compiling B ( src/B.hs, src/B.o ) src/B.hs:5:1: Warning: SPECIALISE pragma for non-overloaded function ‘myfun’ ghc: panic! (the 'impossible' happened) (GHC version 7.8.4 for x86_64-unknown-linux): dsImpSpecs main:A.myfun{v r0} [gid] Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug }}} Without `-O`: {{{ $ ghc --make -isrc B A -Wall -fhpc [2 of 2] Compiling B ( src/B.hs, src/B.o ) }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10504#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10504: GHC panics with dsImpSpecs on SPECIALISE pragma with -fhpc enabled -------------------------------------+------------------------------------- Reporter: nh2 | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.10.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple crash | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: -------------------------------------+------------------------------------- Comment (by nh2): By the way, ignore the fact that the repository has `omit-interface- pragmas` in its name - I originally thought that this problem only happens when I enable `-fomit-interface-pragmas`, but it already happens on plain `-fhpc`. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10504#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10504: GHC panics with dsImpSpecs on SPECIALISE pragma with -fhpc enabled -------------------------------------+------------------------------------- Reporter: nh2 | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Code Coverage | Version: 7.10.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple crash | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: -------------------------------------+------------------------------------- Changes (by thomie): * component: Compiler => Code Coverage -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10504#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10504: GHC panics with dsImpSpecs on SPECIALISE pragma with -fhpc enabled -------------------------------------+------------------------------------- Reporter: nh2 | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Code Coverage | Version: 7.10.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple crash | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: -------------------------------------+------------------------------------- Comment (by nh2): Some more info, contributed by a colleague: In the minimal example provided: {{{ ghc --show-iface A.hi ... ef7b9ac4dd27cad757d7fad8ecd0592a myfun :: a {- Strictness: b, Inline: INLINABLE[ALWAYS] -} # actual end of file }}} The myfun function doesn't actually have an unfolding in the .hi interface file (there's no "Unfolding: ..." line). The seeming inconsistency with an import being marked INLINABLE but not having an unfolding is the root cause of the bug (see https://github.com/ghc/ghc/blob/45d9a15c4b85a2ed89579106bdafd84accf2cb39/com...). The hyper-strictness (ie “Strictness: b”, b for bottom a la undefined) is probably why the unfolding isn't retained in this minimal example. Anothere example of when the unfolding isn't retained is if you use `-fomit-inerface-pragmas`. My colleague's conclusion: These are two ways to trigger the same bug: GHC should not crash on a SPECIALIZE for an imported function that has no unfolding, regardless of why it has no unfolding. It would always be better to warn about the missing unfolding/useless SPECIALISE pragma and then ignore the SPECIALISE. Perhaps GHC should also warn about marking a hyperstrict definition as INLINABLE. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10504#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC