Re: [GHC] #7323: decoding GADTs gives internal error: stg_ap_v_ret

2012-10-22 Thread GHC
#7323: decoding GADTs gives internal error: stg_ap_v_ret
---+
Reporter:  heisenbug   |   Owner:   
Type:  bug |  Status:  new  
Priority:  normal  |   Milestone:  7.8.1
   Component:  Compiler| Version:  7.7  
Keywords:  |  Os:  Linux
Architecture:  x86_64 (amd64)  | Failure:  Runtime crash
  Difficulty:  Unknown |Testcase:  yes  
   Blockedby:  |Blocking:   
 Related:  |  
---+

Comment(by heisenbug):

 It turns out that simply mixing GADTs + unsafeCoerce triggers the bug.
 (see freshly attached.. crash.hs) The order of the GADT constructors
 (being defined) seems to matter, swapping them changes a crash to some
 (apparently) undefined behaviour (neither output, nor pattern match
 failure).

  I suspect that unsafeCoerce does not preserve pointer tagging. 

-- 
Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7323#comment:5
GHC http://www.haskell.org/ghc/
The Glasgow Haskell Compiler

___
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs


Re: [GHC] #7323: decoding GADTs gives internal error: stg_ap_v_ret

2012-10-22 Thread GHC
#7323: decoding GADTs gives internal error: stg_ap_v_ret
+---
  Reporter:  heisenbug  |  Owner:
  Type:  bug| Status:  closed
  Priority:  normal |  Milestone:  7.8.1 
 Component:  Compiler   |Version:  7.7   
Resolution:  invalid|   Keywords:
Os:  Linux  |   Architecture:  x86_64 (amd64)
   Failure:  Runtime crash  | Difficulty:  Unknown   
  Testcase:  yes|  Blockedby:
  Blocking: |Related:
+---
Changes (by igloo):

  * status:  new = closed
  * resolution:  = invalid


Comment:

 `int-e` in #ghc diagnosed this:
 {{{
 GHC correctly infers that when it gets a value
 of type forall a. TypedPair a, then there is no constructor
 that can match.

 And it happily creates a case statement without alternatives,
 relying on the value to be bottom. The code, however, produces
 a non-bottom value of the type. What will happen then is
 unpredictable. (Interestingly, ghc 7.4.1 created a fresh
 bottom value instead, which is arguably more friendly.)
 }}}

 {{{
 Main.main :: GHC.Types.IO ()
 [GblId, Str=DmdType b]
 Main.main =
   case Unsafe.Coerce.unsafeCoerce
  @ (Main.TypedPair GHC.Types.Int)
  @ (Main.TypedPair (GHC.Prim.Any *))
  Main.$WTPInt
   of _ {
   }
 }}}

 This therefore looks like it isn't a bug - just an invalid use of
 `unsafeCoerce`.

 Thanks for taking the time to make such a small testcase, though. And
 thanks too to `int-e` for the diagnosis.

-- 
Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7323#comment:6
GHC http://www.haskell.org/ghc/
The Glasgow Haskell Compiler

___
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs


Re: [GHC] #7323: decoding GADTs gives internal error: stg_ap_v_ret

2012-10-22 Thread GHC
#7323: decoding GADTs gives internal error: stg_ap_v_ret
+---
  Reporter:  heisenbug  |  Owner:
  Type:  bug| Status:  closed
  Priority:  normal |  Milestone:  7.8.1 
 Component:  Compiler   |Version:  7.7   
Resolution:  invalid|   Keywords:
Os:  Linux  |   Architecture:  x86_64 (amd64)
   Failure:  Runtime crash  | Difficulty:  Unknown   
  Testcase:  yes|  Blockedby:
  Blocking: |Related:
+---

Comment(by int-e):

 Interestingly, ghc 7.4.1 used to produce a {{{runTimeError Impossible
 case alternative}}} for such cases rather than relying on the given value
 to be bottom. Is this the result of an optimization (getting rid of
 unreachable default branches in case, say) or an actual regression?

-- 
Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7323#comment:7
GHC http://www.haskell.org/ghc/
The Glasgow Haskell Compiler

___
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs


Re: [GHC] #7323: decoding GADTs gives internal error: stg_ap_v_ret

2012-10-16 Thread GHC
#7323: decoding GADTs gives internal error: stg_ap_v_ret
---+
Reporter:  heisenbug   |   Owner:   
Type:  bug |  Status:  new  
Priority:  normal  |   Milestone:  7.8.1
   Component:  Compiler| Version:  7.7  
Keywords:  |  Os:  Linux
Architecture:  x86_64 (amd64)  | Failure:  Runtime crash
  Difficulty:  Unknown |Testcase:  yes  
   Blockedby:  |Blocking:   
 Related:  |  
---+
Changes (by igloo):

  * difficulty:  = Unknown
  * milestone:  = 7.8.1


-- 
Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7323#comment:4
GHC http://www.haskell.org/ghc/
The Glasgow Haskell Compiler

___
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs


Re: [GHC] #7323: decoding GADTs gives internal error: stg_ap_v_ret

2012-10-12 Thread GHC
#7323: decoding GADTs gives internal error: stg_ap_v_ret
---+
 Reporter:  heisenbug  |  Owner:
 Type:  bug| Status:  new   
 Priority:  normal |  Component:  Compiler  
  Version:  7.7|   Keywords:
   Os:  Linux  |   Architecture:  x86_64 (amd64)
  Failure:  Runtime crash  |   Testcase:  yes   
Blockedby: |   Blocking:
  Related: |  
---+
Changes (by heisenbug):

 * cc: ggreif@… (added)


Comment:

 I found a pre-7.4 compiler: ghc-7.4.0.20111220
 it emits:
 `internal-error: Impossible case alternative`

 The other compiler did not even typecheck the test case:
 {{{
 ghc-7.5.20120713 internal-error.lhs
 [1 of 1] Compiling Main ( internal-error.lhs, internal-error.o
 )

 internal-error.lhs:39:23:
 Couldn't match type `BL.ByteString'
   with
 `bytestring-0.10.0.0:Data.ByteString.Lazy.Internal.ByteString'
 Expected type: [ByteString]
-
 bytestring-0.10.0.0:Data.ByteString.Lazy.Internal.ByteString
   Actual type: [ByteString] - BL.ByteString
 In the second argument of `(.)', namely `BL.fromChunks'
 In the expression: decode . BL.fromChunks
 In an equation for `decodeAs': decodeAs = decode . BL.fromChunks

 internal-error.lhs:45:41:
 Couldn't match expected type `BL.ByteString'
 with actual type
 `bytestring-0.10.0.0:Data.ByteString.Lazy.Internal.ByteString'
 In the first argument of `BL.toChunks', namely `lazy'
 In the second argument of `($)', namely `BL.toChunks lazy'
 In the expression: decodeAs $ BL.toChunks lazy
 }}}

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

___
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs


Re: [GHC] #7323: decoding GADTs gives internal error: stg_ap_v_ret

2012-10-12 Thread GHC
#7323: decoding GADTs gives internal error: stg_ap_v_ret
---+
 Reporter:  heisenbug  |  Owner:
 Type:  bug| Status:  new   
 Priority:  normal |  Component:  Compiler  
  Version:  7.7|   Keywords:
   Os:  Linux  |   Architecture:  x86_64 (amd64)
  Failure:  Runtime crash  |   Testcase:  yes   
Blockedby: |   Blocking:
  Related: |  
---+

Comment(by heisenbug):

 This is what gdb has to say:
 {{{
 (gdb) run
 Starting program: /home/ggreif/ReleaseFeatureMatrix/internal-error
 warning: no loadable sections found in added symbol-file system-supplied
 DSO at 0x2aaab000
 [Thread debugging using libthread_db enabled]
 internal-error: internal error: stg_ap_v_ret
 (GHC version 7.7.20121012 for x86_64_unknown_linux)
 Please report this as a GHC bug:
 http://www.haskell.org/ghc/reportabug

 Program received signal SIGABRT, Aborted.
 0x0035b2a30285 in raise () from /lib64/libc.so.6
 (gdb) bt
 #0  0x0035b2a30285 in raise () from /lib64/libc.so.6
 #1  0x0035b2a31d30 in abort () from /lib64/libc.so.6
 #2  0x2c623799 in rtsFatalInternalErrorFn (s=0x2c660128
 stg_ap_v_ret,
 ap=0x7fff8680) at rts/RtsMessages.c:170
 #3  0x2c623304 in barf (s=0x2c660128 stg_ap_v_ret) at
 rts/RtsMessages.c:42
 #4  0x2c64d7ae in stg_ap_v_info ()
from /home/ggreif/lib/ghc-7.7.20121012/rts-1.0/libHSrts_debug-
 ghc7.7.20121012.so
 #5  0x in ?? ()
 }}}

-- 
Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7323#comment:2
GHC http://www.haskell.org/ghc/
The Glasgow Haskell Compiler

___
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs


Re: [GHC] #7323: decoding GADTs gives internal error: stg_ap_v_ret

2012-10-12 Thread GHC
#7323: decoding GADTs gives internal error: stg_ap_v_ret
---+
 Reporter:  heisenbug  |  Owner:
 Type:  bug| Status:  new   
 Priority:  normal |  Component:  Compiler  
  Version:  7.7|   Keywords:
   Os:  Linux  |   Architecture:  x86_64 (amd64)
  Failure:  Runtime crash  |   Testcase:  yes   
Blockedby: |   Blocking:
  Related: |  
---+

Comment(by heisenbug):

 Debug session on OS X (i386)

 {{{
 Breakpoint 1, 0x003bfe68 in stg_ap_v_info ()
 (gdb) info reg
 eax0x2808   10248 info table:
 Main_TPString_con_info
 ecx0x4  4 INFO TYPE (dito)
 edx0xd00040 13631552
 ebx0x425f4c 4349772
 esp0xbfffd87c   0xbfffd87c
 ebp0xd033ac 0xd033ac
 esi0xd058f8 13654264
 edi0xd05900 13654272
 eip0x3bfe68 0x3bfe68 stg_ap_v_info+676
 eflags 0x202514
 cs 0x1b 27
 ss 0x23 35
 ds 0x23 35
 es 0x23 35
 fs 0x0  0
 gs 0xf  15
 (gdb) x/20x $eax-4
 0x2804 Main_TPString_con_info_dsp+8:  0x00010004  0xff02c683
 0x000c0065  0x9066
 0x2814 Main_TPString_static_info_dsp: 0x003c216c  0x0002
 0x00010007  0xff02c683
 0x2824 Main_TPString_static_info+4:   0x000c0065  0x8955
 0xec8353e5  0xe834
 0x2834 main+10:   0x8d5b  0x3e380283  0x8b008b00
 0x008b0450
 0x2844 main+26:   0x89f04589  0x45c7f455  0x02f0
 0xf0458b00
 (gdb) x/20x $eax
 0x2808 Main_TPString_con_info:0xff02c683  0x000c0065
 0x9066  0x003c216c
 0x2818 Main_TPString_static_info_dsp+4:   0x0002  0x00010007
 0xff02c683  0x000c0065
 0x2828 Main_TPString_static_info+8:   0x8955  0xec8353e5
 0xe834  0x8d5b
 0x2838 main+14:   0x3e380283  0x8b008b00  0x008b0450
 0x89f04589
 0x2848 main+30:   0x45c7f455  0x02f0  0xf0458b00
 0x89f4558b
 (gdb) p *(short*)0x2804
 $1 = 4
 }}}

 It loads the address `Main_TPString_con_info` at this code position:
 `Main_zdWTPString_info+0x14`

 {{{
 _Main_zdWTPString_info_dsp:
 0044orb $_Main_zdWTPInt_info_dsp,%al
 0046addb(%eax),%al
 0048addb%al,(%eax)
 004aaddb%al,(%eax)
 004csldt(%eax)
 004faddb%al,0x7b3b0cc7(%ebx)
 0055popl%esp
 0056ja  0x0073
 0058movl$_Main_TPString_con_info,0xf8(%edi)
 
 005fmovl_Main_zdWTPInt_info_dsp(%ebp),%eax
 0062movl%eax,0xfc(%edi)
 0065movl0x04(%ebp),%eax
 0068movl%eax,(%edi)
 006aleal0xfa(%edi),%esi
 006daddl$0x08,%ebp
 0070jmp *_Main_zdWTPInt_info_dsp(%ebp) calls
 stg_upd_frame_info
 0073movl$_Main_zdWTPInt_info,0x74(%ebx)
 007amovl$_Main_zdWTPString_closure,%esi
 007fjmp *0xfc(%ebx)
 0082orb $_Main_zdWTPInt_info_dsp,%al
 0084addb%al,(%eax)
 0086nop
 }}}

 {{{
 0x003bfa18 stg_upd_frame_info+0:  mov0x4(%ebp),%eax
 0x003bfa1b stg_upd_frame_info+3:  add$0x8,%ebp
 0x003bfa1e stg_upd_frame_info+6:  sub$0x8,%esp
 0x003bfa21 stg_upd_frame_info+9:  push   %eax
 0x003bfa22 stg_upd_frame_info+10: mov%eax,0x4c(%esp)
 0x003bfa26 stg_upd_frame_info+14: call   0x3892d5
 overwritingClosure   overwritingClosure (p=0xd058e8) at
 ClosureMacros.h:474

 0x003bfa2b stg_upd_frame_info+19: add$0xc,%esp
 0x003bfa2e stg_upd_frame_info+22: mov0x40(%esp),%eax
 0x003bfa32 stg_upd_frame_info+26: mov%esi,0x4(%eax)
 0x003bfa35 stg_upd_frame_info+29: mov0x3e63d8,%ecx
 0x003bfa3b stg_upd_frame_info+35: mov%ecx,(%eax)
 0x003bfa3d stg_upd_frame_info+37: mov%eax,%ecx
 0x003bfa3f stg_upd_frame_info+39: and$0xfff0,%ecx
 0x003bfa45 stg_upd_frame_info+45: mov%eax,%edx
 0x003bfa47 stg_upd_frame_info+47: and$0xff000,%edx
 0x003bfa4d stg_upd_frame_info+53: shr$0x7,%edx
 0x003bfa50 stg_upd_frame_info+56: or %ecx,%edx
 0x003bfa52 stg_upd_frame_info+58: cmpw   $0x0,0x14(%edx)
 0x003bfa57 stg_upd_frame_info+63: jne0x3bfa5c
 stg_upd_frame_info+68
 0x003bfa59 stg_upd_frame_info+65: jmp*0x0(%ebp) 
 stg_marked_upd_frame_info
 0x003bfa5c stg_upd_frame_info+68: movswl 0x14(%edx),%ecx
 0x003bfa60 stg_upd_frame_info+72: shl$0x2,%ecx
 0x003bfa63 stg_upd_frame_info+75: mov0x9c(%ebx),%edx
 0x003bfa69 stg_upd_frame_info+81: add