[GHC] #11158: Combine exprIsTrivial and cpe_ExprIsTrivial

GHC ghc-devs at haskell.org
Thu Nov 3 09:56:12 UTC 2016


#11158: Combine exprIsTrivial and cpe_ExprIsTrivial
-------------------------------------+-------------------------------------
        Reporter:  simonpj           |                Owner:
            Type:  task              |               Status:  closed
        Priority:  highest           |            Milestone:  8.2.1
       Component:  Compiler          |              Version:  7.10.2
      Resolution:  fixed             |             Keywords:
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):  Phab:D2666
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by simonpj):

 > Which then fails the consistentStgInfo check in CoreToStg for reasons
 that I am still trying to work out.

 Here's why (I think):

 * As the commit message says, if we case-bind the literal string,
 something that was a static data structure (predicted as `NoCafRefs` by
 `CorePrep` becomes a thunk.   This prediction is made by `rhsIsStatic`,
 called in `CorePrep`.

 * Since it is marked as `NoCafRefs` it won't appear in anyone's SRT

 * But when it is evaluated, the thunk will allocate its result in the
 heap, and update the static closure to point to it.

 * Later the garbage collector will collect that thunk; the only pointer to
 it is from a static closure that is in no SRT.

 * The space will be re-used

 * Later someone uses the thing again, but the pointer now points to
 garbage.  Seg fault.

 It's FATAL for something marked as `NoCafRefs` to turn into a thunk.
 Arrangig to panic on that would be good. It should not be just a warning,
 and I think it'd be worth the tiny perf hit to test it even in non-DEBUG
 code.

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


More information about the ghc-tickets mailing list