summaryrefslogtreecommitdiff
path: root/rts/STM.c
diff options
context:
space:
mode:
authorRyan Yates <ryates@cs.rochester.edu>2013-04-08 19:18:51 -0400
committerIan Lynagh <ian@well-typed.com>2013-04-17 20:49:26 +0100
commit87baa31cb117181ab4f4b26387653996d1792167 (patch)
treef07d62d999a51e3dbfe72c5fd15c1dcc38b88dd2 /rts/STM.c
parent78f9189e49b5f1e57610429959c4054d7e27a24f (diff)
downloadhaskell-87baa31cb117181ab4f4b26387653996d1792167.tar.gz
Check to see if TVar's are locked in check_read_only (fixes #7815)
Diffstat (limited to 'rts/STM.c')
-rw-r--r--rts/STM.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/rts/STM.c b/rts/STM.c
index eee0f46bbc..8f4bdfbecb 100644
--- a/rts/STM.c
+++ b/rts/STM.c
@@ -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;