Ticket #7815: 0001-Check-to-see-if-TVar-s-are-locked-in-check_read_only.patch

File 0001-Check-to-see-if-TVar-s-are-locked-in-check_read_only.patch, 1.2 KB (added by fryguybob, 13 months ago)
  • rts/STM.c

    From 0e5f4d46165ac347a6d96c23c8752dc6f2c94944 Mon Sep 17 00:00:00 2001
    From: Ryan Yates <ryates@cs.rochester.edu>
    Date: Mon, 8 Apr 2013 19:18:51 -0400
    Subject: [PATCH] Check to see if TVar's are locked in check_read_only (fixes
     #7815)
    
    ---
     rts/STM.c | 8 ++++++--
     1 file changed, 6 insertions(+), 2 deletions(-)
    
    diff --git a/rts/STM.c b/rts/STM.c
    index eee0f46..8f4bdfb 100644
    a b static StgBool check_read_only(StgTRecHeader *trec STG_UNUSED) { 
    905905      s = e -> tvar; 
    906906      if (entry_is_read_only(e)) { 
    907907        TRACE("%p : check_read_only for TVar %p, saw %ld", trec, s, e -> num_updates); 
    908         if (s -> num_updates != e -> num_updates) { 
    909           // ||s -> current_value != e -> expected_value) { 
     908         
     909        // Note we need both checks and in this order as the TVar could be 
     910        // locked by another transaction that is committing but has not yet 
     911        // incremented `num_updates` (See #7815). 
     912        if (s -> current_value != e -> expected_value || 
     913            s -> num_updates != e -> num_updates) { 
    910914          TRACE("%p : mismatch", trec); 
    911915          result = FALSE; 
    912916          BREAK_FOR_EACH;