[GHC] #14310: Assertion triggered by STM invariant.

GHC ghc-devs at haskell.org
Thu Oct 5 03:11:23 UTC 2017


#14310: Assertion triggered by STM invariant.
-------------------------------------+-------------------------------------
        Reporter:  mbw               |                Owner:  (none)
            Type:  bug               |               Status:  patch
        Priority:  high              |            Milestone:  8.4.1
       Component:  Compiler          |              Version:  8.2.1
      Resolution:                    |             Keywords:
Operating System:  Linux             |         Architecture:  x86_64
                                     |  (amd64)
 Type of failure:  Runtime crash     |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):  Phab:D4065,
       Wiki Page:                    |  Phab:D4067
-------------------------------------+-------------------------------------

Comment (by bgamari):

 fryguybob had some very useful feedback on these patches. It seems like
 there is yet another issue: the assertion in `raiseAsync` is itself wrong
 (as I suspected in comment:5). To summarize:

 Normal top-level STM transactions (e.g. initiated by an `atomically` call
 in
 Haskell) by definition should have `enclosing_trec == NO_TREC`. The
 `ATOMICALLY_FRAME` handler in `raiseAsync` checks this invariant with an
 assert. In
 the case of nested transactions initiated by `orElse` we will hit a
 `CATCH_RETRY_FRAME` before hitting an `ATOMICALLY_FRAME`, avoiding this
 assertion.

 However, in the case of nested transactions started by the STM machinery
 for the
 purpose that we are checking invariants we have no such
 `CATCH_RETRY_FRAME`.
 `stg_atomically_frame` just pushes an `ATOMICALLY_FRAME`. Since this frame
 will have
 `enclosing_trec != NO_TREC`, this trips the assertion.

 Instead we should be asserting something like,
 {{{#!c
 DEBUG_ONLY(StgAtomicallyFrame *atomically = (StgAtomicallyFrame *) frame);
 ASSERT(tso->trec->enclosing_trec == NO_TREC ||
 atomically->next_invariant_to_check != END_INVARIANT_CHECK_QUEUE);
 }}}

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


More information about the ghc-tickets mailing list