[GHC] #14626: No need to enter a scrutinised value

GHC ghc-devs at haskell.org
Mon Jan 15 19:29:40 UTC 2018


#14626: No need to enter a scrutinised value
-------------------------------------+-------------------------------------
        Reporter:  heisenbug         |                Owner:  heisenbug
            Type:  bug               |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  Compiler          |              Version:  8.2.2
      Resolution:                    |             Keywords:  performance
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:  #13861            |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by heisenbug):

 I have a nice one:

 {{{
 libHSghc-8.5-ghc8.5.20180103.dylib`sSTG_info + 98 [inlined] _c147g + 1
    503          -- force evaluation all this stuff to avoid space leaks
    504          {-# SCC "seqString" #-} evaluate $ seqString (showSDoc
 dflags $ vcat $ map ppr imports)
    505
     0x102a5b6ca <+98>:  leal   -0x179cf8(%rip), %eax     ;
 ghc_Outputable_SDC_con_info
     0x102a5b6d0 <+104>: movq   %rax, -0x18(%r12)
     0x102a5b6d5 <+109>: leaq   0x95471c(%rip), %rax      ;
 ghc_Outputable_defaultUserStyle1_closure
     0x102a5b6dc <+116>: movq   %rax, -0x10(%r12)
     0x102a5b6e1 <+121>: movq   %rbx, -0x8(%r12)
     0x102a5b6e6 <+126>: movq   0x8(%rbp), %rax
     0x102a5b6ea <+130>: movq   %rax, (%r12)
     0x102a5b6ee <+134>: movq   -0x10(%r12), %rax
     0x102a5b6f3 <+139>: testb  $0x7, %al
     0x102a5b6f5 <+141>: jne    0x102a5b70b               ; <+163>
 [inlined] _c147A
 libHSghc-8.5-ghc8.5.20180103.dylib`sSTG_info + 143 [inlined] _c147B
    503          -- force evaluation all this stuff to avoid space leaks
    504          {-# SCC "seqString" #-} evaluate $ seqString (showSDoc
 dflags $ vcat $ map ppr imports)
    505
     0x102a5b6f7 <+143>: subq   $0x8, %rsp
     0x102a5b6fb <+147>: movq   -0x10(%r12), %rdi
     0x102a5b700 <+152>: xorl   %eax, %eax
     0x102a5b702 <+154>: callq  0x102eb8604               ; symbol stub
 for: checkTagged
 }}}

 Here the first (banged) field of `SDC` gets initialised to a global
 closure. Clearly it is non-tagged and not evaluated.
 It gets caught by my assertion a bit later. I think this is a clear bug.
 The closure should be entered and evaluated to a WHNF (tagged) constructor
 before saving it into the `SDC` constructor.

 I did a `quick` compilation with `make -j5 GhcStage2HcOpts="-O1 -g"
 stage=2` in this case.

 I still don't understand how GHC manages to create a standalone closure
 (nullary thunk, statically allocated, PC-relative) for `defaultUserStyle
 dflags`.
 {{{
 showSDoc dflags sdoc = renderWithStyle dflags sdoc (defaultUserStyle
 dflags)
 }}}
 It looks ''unary'' to me!

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


More information about the ghc-tickets mailing list