really, really nasty bug...see page 8-9 of vol 3A of intel processor manual for x86...
authorbdemsky <bdemsky>
Sat, 2 Apr 2011 22:53:33 +0000 (22:53 +0000)
committerbdemsky <bdemsky>
Sat, 2 Apr 2011 22:53:33 +0000 (22:53 +0000)
Robust/src/Runtime/oooJava/hashStructure.c

index 2bbf4c84f6ae89e05b96e13ab8ebeaec7269d391..488d63006c36384c8467a9cc6bb4fef055145ba4 100644 (file)
@@ -160,7 +160,7 @@ inline int rcr_BWRITEBINCASE(HashStructure *T, int key, SESEcommon *task, struct
   b->item.status=status;
   bintail->next=(BinItem_rcr*)b;
   be->tail=(BinItem_rcr*)b;
-  BARRIER();
+  MBARRIER(); //need to make sure that the read below doesn't pass the write above
   if (bintail->status==READY&&bintail->total==0) {
     //we may have to set write as ready
     while(1) {
@@ -374,6 +374,7 @@ void rcr_TAILWRITECASE(HashStructure *T, BinItem_rcr *val, BinItem_rcr *bintail,
 
 void rcr_RETIREHASHTABLE(HashStructure *T, SESEcommon *task, int key, BinItem_rcr *b) {
   atomic_dec(&b->total);
+
   //Need to clear ourself out of the read bin so that we aren't resolved after being freed
   if(ISREADBIN(b->type)) {
     //Have to clear our entry out of bin if we retired early
@@ -398,7 +399,6 @@ void rcr_RETIREHASHTABLE(HashStructure *T, SESEcommon *task, int key, BinItem_rc
       }
       be->head=val;
     }
-    
     if (b->next==NULL || b->total>0) {
       return;
     }