From fbc3fc411a2b619f638612dcaf322983c7a403c3 Mon Sep 17 00:00:00 2001 From: Simon Marlow Date: Fri, 6 Feb 2009 13:08:04 +0000 Subject: [PATCH] crucial bugfix: add a store/load memory barrier to popWSDeque() --- rts/parallel/WSDeque.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/rts/parallel/WSDeque.c b/rts/parallel/WSDeque.c index 75ff919..4ae9417 100644 --- a/rts/parallel/WSDeque.c +++ b/rts/parallel/WSDeque.c @@ -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 -- 1.7.10.4