Skip to content

Commit

Permalink
Check to see if TVar's are locked in check_read_only (fixes #7815)
Browse files Browse the repository at this point in the history
  • Loading branch information
fryguybob authored and Ian Lynagh committed Apr 17, 2013
1 parent 78f9189 commit 87baa31
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions rts/STM.c
Expand Up @@ -905,8 +905,12 @@ static StgBool check_read_only(StgTRecHeader *trec STG_UNUSED) {
s = e -> tvar;
if (entry_is_read_only(e)) {
TRACE("%p : check_read_only for TVar %p, saw %ld", trec, s, e -> num_updates);
if (s -> num_updates != e -> num_updates) {
// ||s -> current_value != e -> expected_value) {

// Note we need both checks and in this order as the TVar could be
// locked by another transaction that is committing but has not yet
// incremented `num_updates` (See #7815).
if (s -> current_value != e -> expected_value ||
s -> num_updates != e -> num_updates) {
TRACE("%p : mismatch", trec);
result = FALSE;
BREAK_FOR_EACH;
Expand Down

0 comments on commit 87baa31

Please sign in to comment.