crucial bugfix: add a store/load memory barrier to popWSDeque()
authorSimon Marlow <marlowsd@gmail.com>
Fri, 6 Feb 2009 13:08:04 +0000 (13:08 +0000)
committerSimon Marlow <marlowsd@gmail.com>
Fri, 6 Feb 2009 13:08:04 +0000 (13:08 +0000)
rts/parallel/WSDeque.c

index 75ff919..4ae9417 100644 (file)
@@ -130,7 +130,14 @@ popWSDeque (WSDeque *q)
     
     b = q->bottom;
     /* "decrement b as a test, see what happens" */
-    q->bottom = --b; 
+
+    b--;
+    q->bottom = b;
+
+    // very important that the following read of q->top does not occur
+    // before the earlier write to q->bottom.
+    store_load_barrier();
+
     pos = (q->elements) + (b & (q->moduloSize));
     t = q->top; /* using topBound would give an *upper* bound, we
                    need a lower bound. We use the real top here, but