[GHC] #8569: ASSERT in testcase type-rep, only in some ways:

#8569: ASSERT in testcase type-rep, only in some ways: ------------------------------------+------------------------------------- Reporter: nomeata | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Test Suite | Version: 7.7 Keywords: | Operating System: Unknown/Multiple Architecture: Unknown/Multiple | Type of failure: None/Unknown Difficulty: Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | ------------------------------------+------------------------------------- On HEAD, I currently (d55cc30658ae7c5afc0d62f3bd118fb2a5fcee40) get {{{ =====> type-rep(normal) 2696 of 3834 [0, 0, 0] =====> type-rep(hpc) 2696 of 3834 [0, 0, 0] Compile failed (status 256) errors were: [1 of 1] Compiling Main ( type-rep.hs, type-rep.o ) ghc-stage2: panic! (the 'impossible' happened) (GHC version 7.7.20131124 for x86_64-unknown-linux): ASSERT failed! file compiler/basicTypes/Demand.lhs, line 439 Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug *** unexpected failure for type-rep(hpc) =====> type-rep(optasm) 2696 of 3834 [0, 1, 0] Compile failed (status 256) errors were: [1 of 1] Compiling Main ( type-rep.hs, type-rep.o ) ghc-stage2: panic! (the 'impossible' happened) (GHC version 7.7.20131124 for x86_64-unknown-linux): ASSERT failed! file compiler/basicTypes/Demand.lhs, line 439 Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug *** unexpected failure for type-rep(optasm) =====> type-rep(ghci) 2696 of 3834 [0, 2, 0] =====> type-rep(threaded1) 2696 of 3834 [0, 2, 0] =====> type-rep(threaded2) 2696 of 3834 [0, 2, 0] Compile failed (status 256) errors were: [1 of 1] Compiling Main ( type-rep.hs, type-rep.o ) ghc-stage2: panic! (the 'impossible' happened) (GHC version 7.7.20131124 for x86_64-unknown-linux): ASSERT failed! file compiler/basicTypes/Demand.lhs, line 439 Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug *** unexpected failure for type-rep(threaded2) =====> type-rep(dyn) 2696 of 3834 [0, 3, 0] Compile failed (status 256) errors were: [1 of 1] Compiling Main ( type-rep.hs, type-rep.o ) ghc-stage2: panic! (the 'impossible' happened) (GHC version 7.7.20131124 for x86_64-unknown-linux): ASSERT failed! file compiler/basicTypes/Demand.lhs, line 439 Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug *** unexpected failure for type-rep(dyn) =====> type-rep(optllvm) 2696 of 3834 [0, 4, 0] Compile failed (status 256) errors were: [1 of 1] Compiling Main ( type-rep.hs, type-rep.o ) ghc-stage2: panic! (the 'impossible' happened) (GHC version 7.7.20131124 for x86_64-unknown-linux): ASSERT failed! file compiler/basicTypes/Demand.lhs, line 439 Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug *** unexpected failure for type-rep(optllvm) }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8569 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8569: ASSERT in testcase type-rep, only in some ways: -------------------------------------+------------------------------------ Reporter: nomeata | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Test Suite | Version: 7.7 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Unknown/Multiple Type of failure: None/Unknown | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: -------------------------------------+------------------------------------ Comment (by nomeata): That should be 1df2116c221941ef40a0f6f8fb7dcc42c56738e7 (changed due to pull rebase). -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8569#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8569: ASSERT in testcase type-rep, only in some ways: -------------------------------------+------------------------------------ Reporter: nomeata | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Test Suite | Version: 7.7 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Unknown/Multiple Type of failure: None/Unknown | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: -------------------------------------+------------------------------------ Comment (by nomeata): I have a freshly cleaned and built master checkout here, and it is reproducible again (using `make -C testsuite TEST="type-rep"`) Note that this patch is marked as `skip()` when running `make -C testsuite fast`. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8569#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8569: ASSERT in testcase type-rep, only in some ways: -------------------------------------+------------------------------------ Reporter: nomeata | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Test Suite | Version: 7.7 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Unknown/Multiple Type of failure: None/Unknown | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: -------------------------------------+------------------------------------ Comment (by nomeata): Minimalizing the example yields {{{ module Example (x) where data Rep t where Rint :: Rep Int Rdata :: Rep i -> (t -> i) -> (i -> t) -> Rep t addUp :: Rep a -> a -> Int addUp Rint n = n addUp (Rdata i f g) x = addUp i (f x) x = addUp undefined [1] }}} Again, the problem only occurs with `-O`. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8569#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8569: ASSERT in testcase type-rep, only in some ways:
-------------------------------------+------------------------------------
Reporter: nomeata | Owner:
Type: bug | Status: new
Priority: normal | Milestone:
Component: Test Suite | Version: 7.7
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture: Unknown/Multiple
Type of failure: None/Unknown | Difficulty: Unknown
Test Case: | Blocked By:
Blocking: | Related Tickets:
-------------------------------------+------------------------------------
Comment (by nomeata):
I believe the problem is a mis-calculated demand for `addUp`:
{{{
Rec {
Example.addUp [Occ=LoopBreaker]
:: forall a_aqp. Example.Rep a_aqp -> a_aqp -> GHC.Types.Int
[LclIdX,
Arity=2,
Str=DmdType ] :: Example.Rep a_aBI)
(n_aqq [Dmd=]
f_aqs [Dmd=

#8569: ASSERT in testcase type-rep, only in some ways:
-------------------------------------+------------------------------------
Reporter: nomeata | Owner:
Type: bug | Status: new
Priority: normal | Milestone:
Component: Test Suite | Version: 7.7
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture: Unknown/Multiple
Type of failure: None/Unknown | Difficulty: Unknown
Test Case: | Blocked By:
Blocking: | Related Tickets:
-------------------------------------+------------------------------------
Comment (by nomeata):
Here we go:
{{{
dmdAnal:Case2
scrut ds_dBX{v} [lid]
scrut_ty DmdType {dBX->}
alt_tys [DmdType {aqq->}, DmdType {aqq->}
}}}
If I read this correct, in human terms, this tell me
“The first case branch will use `aqq` (=`n`) at most once, and will take
the box apart and use what’s inside, while do not know anything about how
the right case branch uses `n`. The scrutinee does not talk about `n` at
all. Therefore, the whole expression uses `n` in an unknown number of
times, and also uses what’s inside”.
This sounds wrong to me (but I’m not firm on reading demand signatures
yet).
--
Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8569#comment:5
GHC http://www.haskell.org/ghc/
The Glasgow Haskell Compiler

#8569: ASSERT in testcase type-rep, only in some ways: -------------------------------------+------------------------------------ Reporter: nomeata | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Test Suite | Version: 7.7 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Unknown/Multiple Type of failure: None/Unknown | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: -------------------------------------+------------------------------------ Comment (by nomeata): Tracing this further I find this equation: {{{ lubUse :: UseDmd -> UseDmd -> UseDmd [..] lubUse (UProd ux1) (UProd ux2) | length ux1 == length ux2 = UProd $ zipWith lubMaybeUsed ux1 ux2 | otherwise = Used lubUse (UProd {}) (UCall {}) = Used -- lubUse (UProd {}) Used = Used lubUse (UProd ux) Used = UProd (map (`lubMaybeUsed` useTop) ux) lubUse Used (UProd ux) = UProd (map (`lubMaybeUsed` useTop) ux) [...] lubUse Used _ = Used -- Note [Used should win] }}} Note that `UProd` lub’ed with `Used` yields `UProd`. This contradicts the note `Used should win`. Time for some git archeology... hmm, seems to be like this since dawn of time`^W`the demand analyzer. And as long as no GADTs are around, it probably does not cause problems. A simple fix would be to change that equation, but surely there are reasons for it... -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8569#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8569: ASSERT in testcase type-rep, only in some ways: -------------------------------------+------------------------------------ Reporter: nomeata | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Test Suite | Version: 7.7 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Unknown/Multiple Type of failure: None/Unknown | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: -------------------------------------+------------------------------------ Comment (by nomeata): This might be related to Note [Don't optimise UProd(Used) to Used]. There it says
But with the joint demand of
doesn't convey any clue that there is a product involved, and so the worthSplittingFun will not fire. (We'd need to use the type as well to make it fire.)
so all this trouble of non-canonical demands just to give some bit of information to `worthSplittingFun`, which can probably get this information from `tryWW`, which knows whether the type really is a product type (and not a type variable that was a product type in one branch of a case of the body)? Or are there likely other reasons to keep `UProd(Used)` instead of `UProd`? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8569#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8569: ASSERT in testcase type-rep, only in some ways:
-------------------------------------+------------------------------------
Reporter: nomeata | Owner:
Type: bug | Status: new
Priority: normal | Milestone:
Component: Test Suite | Version: 7.7
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture: Unknown/Multiple
Type of failure: None/Unknown | Difficulty: Unknown
Test Case: | Blocked By:
Blocking: | Related Tickets:
-------------------------------------+------------------------------------
Comment (by Joachim Breitner

#8569: ASSERT in testcase type-rep, only in some ways: -------------------------------------+------------------------------------ Reporter: nomeata | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Test Suite | Version: 7.7 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Unknown/Multiple Type of failure: None/Unknown | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: -------------------------------------+------------------------------------ Comment (by simonpj): In [changeset:"7baefa874d858ec1dd8f875a46eb4be5a732875e/testsuite"]: {{{ #!CommitTicketReference repository="testsuite" revision="7baefa874d858ec1dd8f875a46eb4be5a732875e" Mark type-rep as broken until #8569 is fixed }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8569#comment:9 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8569: ASSERT in testcase type-rep, only in some ways:
-------------------------------------+------------------------------------
Reporter: nomeata | Owner:
Type: bug | Status: new
Priority: normal | Milestone:
Component: Test Suite | Version: 7.7
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture: Unknown/Multiple
Type of failure: None/Unknown | Difficulty: Unknown
Test Case: | Blocked By:
Blocking: | Related Tickets:
-------------------------------------+------------------------------------
Comment (by Joachim Breitner

#8569: ASSERT in testcase type-rep, only in some ways: -------------------------------------+------------------------------------ Reporter: nomeata | Owner: Type: bug | Status: closed Priority: normal | Milestone: Component: Test Suite | Version: 7.7 Resolution: wontfix | Keywords: Operating System: Unknown/Multiple | Architecture: Unknown/Multiple Type of failure: None/Unknown | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: -------------------------------------+------------------------------------ Changes (by nomeata): * status: new => closed * resolution: => wontfix Comment: Guess I did not update the ticket after later discussions. I believe that this is currently a wontfix: * The demand analyser is quite untyped, so in the example in comment:3, where the two branches of a case happen to have quite different types (one being a product, and one not) can only be handled on a best effort basis. Therefore, the code needs to cope with situations where a product demand does not have the right number of components for the constructor at hand. That is also the reason why `lubStr (SCall _) (SProd _)` should not panic. * The `Note [Don't optimise UProd(Used) to Used]` continues to be relevant: We differentiate these semantically equivalent terms to get some insight about how a product is being used. I believe the test suite is now set up to reflect this, i.e. type-rep will expectedly fail when GHC is compiled with `-DDEBUG` *and* the way is an optimizing way. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8569#comment:11 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8569: ASSERT in testcase type-rep, only in some ways: -------------------------------------+------------------------------------ Reporter: nomeata | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Test Suite | Version: 7.7 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Unknown/Multiple Type of failure: None/Unknown | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: -------------------------------------+------------------------------------ Changes (by simonpj): * status: closed => new * resolution: wontfix => Comment: I’m seeing this assertion failure when using the stage1 compiler (built with –DDEBUG) to compile the stage2 compiler. {{{ ghc-stage1.exe: panic! (the 'impossible' happened) (GHC version 7.9.20140227 for i386-unknown-mingw32): ASSERT failed! file compiler\basicTypes\Demand.lhs line 445 3 [U] }}} Turns out that it's another instance of this ticket, but now the bug is now biting GHC itself! However the `type-rep` test is a much easier version to debug. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8569#comment:12 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8569: ASSERT in testcase type-rep, only in some ways:
-------------------------------------+------------------------------------
Reporter: nomeata | Owner:
Type: bug | Status: new
Priority: normal | Milestone:
Component: Test Suite | Version: 7.7
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture: Unknown/Multiple
Type of failure: None/Unknown | Difficulty: Unknown
Test Case: | Blocked By:
Blocking: | Related Tickets:
-------------------------------------+------------------------------------
Comment (by Simon Peyton Jones

#8569: ASSERT in testcase type-rep, only in some ways:
-------------------------------------+------------------------------------
Reporter: nomeata | Owner:
Type: bug | Status: new
Priority: normal | Milestone:
Component: Test Suite | Version: 7.7
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture: Unknown/Multiple
Type of failure: None/Unknown | Difficulty: Unknown
Test Case: | Blocked By:
Blocking: | Related Tickets:
-------------------------------------+------------------------------------
Comment (by Simon Peyton Jones

#8569: ASSERT in testcase type-rep, only in some ways: -------------------------------------+------------------------------------ Reporter: nomeata | Owner: Type: bug | Status: closed Priority: normal | Milestone: Component: Test Suite | Version: 7.7 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: Unknown/Multiple Type of failure: None/Unknown | Difficulty: Unknown Test Case: gadt/type-rep | Blocked By: Blocking: | Related Tickets: -------------------------------------+------------------------------------ Changes (by simonpj): * status: new => closed * testcase: => gadt/type-rep * resolution: => fixed Comment: OK I think I've fixed this. Should we merge the change to 7.8 branch? Perhaps not unless it actually bites someone. The trouble it that "bite" has only shown up so far as an ASSERT failure, and I'm not 100% sure that it won't have some other bad consequence if the assert is omitted and we proceed regardless. But nothing has so far. So I'll close for now. Simon -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8569#comment:15 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8569: ASSERT in testcase type-rep, only in some ways: -------------------------------------+------------------------------------- Reporter: nomeata | Owner: Type: bug | Status: closed Priority: normal | Milestone: Component: Test Suite | Version: 7.7 Resolution: fixed | Keywords: Operating System: | Architecture: Unknown/Multiple Unknown/Multiple | Difficulty: Unknown Type of failure: | Blocked By: None/Unknown | Related Tickets: Test Case: gadt/type- | rep | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Comment (by slyfox): On './validate --slow' TEST="type-rep" also passes for me in -HEAD: {{{ Unexpected results from: TEST="type-rep }}} Does it make sense to reactivate it for '''compiler_debugged()''' case or some yet unfixed subtlety remains in ghc? Thanks! -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8569#comment:16 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8569: ASSERT in testcase type-rep, only in some ways: -------------------------------------+------------------------------------- Reporter: nomeata | Owner: Type: bug | Status: closed Priority: normal | Milestone: Component: Test Suite | Version: 7.7 Resolution: fixed | Keywords: Operating System: | Architecture: Unknown/Multiple Unknown/Multiple | Difficulty: Unknown Type of failure: | Blocked By: None/Unknown | Related Tickets: Test Case: gadt/type- | rep | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Comment (by nomeata): Thanks for the heads up, changed the status of the bug in changeset:f4904fb/ghc. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8569#comment:17 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC