[GHC] #14677: Code generator does not correctly tag a pointer

GHC ghc-devs at haskell.org
Fri Jan 4 21:57:08 UTC 2019


#14677: Code generator does not correctly tag a pointer
-------------------------------------+-------------------------------------
        Reporter:  simonpj           |                Owner:  (none)
            Type:  bug               |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  Compiler          |              Version:  8.2.2
      Resolution:                    |             Keywords:  CodeGen
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |            Test Case:
      Blocked By:  15155             |             Blocking:  14626
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by heisenbug):

 >
 > When you say "incorrect behaviour" do you meant that we get a seg-fault?
 Or just that we enter a closure that could be properly tagged?

 I mean the latter. Compiling the following code

 {{{#!hs
 module T15155 (a, B(..), b) where

 newtype A = A Int
 newtype B = B A

 {-# NOINLINE a #-}
 a = A 42
 b = B a
 }}}


 to STG, I see:
 {{{#!hs
 T15155.a1 :: GHC.Types.Int
 [GblId, Caf=NoCafRefs, Str=m, Unf=OtherCon []] =
     CCS_DONT_CARE GHC.Types.I#! [42#];

 T15155.a [InlPrag=NOINLINE] :: T15155.A
 [GblId, Str=m, Unf=OtherCon []] =
     [] \u [] T15155.a1;

 T15155.b :: T15155.B
 [GblId, Str=m, Unf=OtherCon []] =
     [] \u [] T15155.a;
 }}}
 `a` and `b` look reasonably similar from their structure.
 The CMM picture is quite different:
 {{{

 [section ""data" . T15155.a1_closure" {
      T15155.a1_closure:
          const GHC.Types.I#_con_info;
          const 42;
  }]

 [section ""data" . T15155.a_closure" {
      T15155.a_closure:
          const stg_IND_STATIC_info;
          const T15155.a1_closure+1;
          const 0;
          const 0;
  }]

 [section ""data" . T15155.b_closure" {
      T15155.b_closure:
          const stg_IND_STATIC_info;
          const T15155.a_closure;
          const 0;
          const 0;
  }]
 }}}
 There is no tag on the indirectee of `T15155.b_closure`, even if they
 possess equivalent unfoldings. Of course there is some obscure rule
 somewhere that strips the tag, so that no crash happens. For me "correct"
 would mean that `T15155.a_closure+1` is allowed and a being the
 consequence of
 {{{
 T15155.a [InlPrag=NOINLINE] :: T15155.A
 [GblId, Str=m, >>>>Unf=OtherCon []<<<<] =
     [] \u [] T15155.a1;
 }}}.

 OTOH "not crashing" is merely law-abiding in my eyes.

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


More information about the ghc-tickets mailing list