rts/STM: Fix nested transaction assertion

Authored by bgamari on Oct 4 2017, 9:59 PM.


Trac Issues

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

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.

Consequently, the existence of invariants means we must refine the assertion in
raiseAsync: We now assert that,

  • We in a invariant-checking transaction and therefore atomically_frame->next_invariant_to_check != END_INVARIANT_CHECK_QUEUE, or
  • We are in a normal, top-level transaction and therefore tso->trec->enclosing_trec == NO_TREC
Test Plan

Validate with T14310

bgamari created this revision.Oct 4 2017, 9:59 PM
bgamari edited the summary of this revision. (Show Details)Oct 4 2017, 10:12 PM
bgamari edited the summary of this revision. (Show Details)
simonmar accepted this revision.Oct 5 2017, 2:55 AM
simonmar added inline comments.

Seems reasonable to me. Please fix the long line though!

This revision is now accepted and ready to land.Oct 5 2017, 2:55 AM
bgamari added inline comments.Oct 5 2017, 2:40 PM

Unfortunately fixing the long line will require that we expand the ASSERT but fair enough.

bgamari updated this revision to Diff 14284.Oct 5 2017, 2:51 PM
bgamari edited the summary of this revision. (Show Details)

Fix long lines

austin resigned from this revision.Nov 9 2017, 5:41 PM
bgamari abandoned this revision.Jan 26 2018, 2:42 PM

Unfortunately D4073, D4067, and D4065 weren't quite sufficient to resolve the issue in question. Howver, ultimately we will likely resolve to deprecate the STM invariant mechanism in GHC 8.6. I won't be continuing work on this issue.