forgot about events that happen after an unresolved read... bug fix checked in
authorBrian Demsky <bdemsky@uci.edu>
Sat, 28 Jul 2012 17:45:48 +0000 (10:45 -0700)
committerBrian Norris <banorris@uci.edu>
Thu, 2 Aug 2012 17:12:55 +0000 (10:12 -0700)
model.cc
model.h

index c87f5f9d07813ecbd40cce8603369f24eebea459..2b2a5f0ecef177282c4a065d8ac4a91d01eb20dc 100644 (file)
--- a/model.cc
+++ b/model.cc
@@ -403,7 +403,7 @@ void ModelChecker::r_modification_order(ModelAction * curr, const ModelAction *r
                        if (act->happens_before(curr)) {
                                if (act->is_read()) {
                                        const ModelAction * prevreadfrom=act->get_reads_from();
                        if (act->happens_before(curr)) {
                                if (act->is_read()) {
                                        const ModelAction * prevreadfrom=act->get_reads_from();
-                                       if (rf!=prevreadfrom)
+                                       if (prevreadfrom!=NULL&&rf!=prevreadfrom)
                                                cyclegraph->addEdge(rf, prevreadfrom);
                                } else if (rf!=act) {
                                        cyclegraph->addEdge(rf, act);
                                                cyclegraph->addEdge(rf, prevreadfrom);
                                } else if (rf!=act) {
                                        cyclegraph->addEdge(rf, act);
@@ -414,6 +414,43 @@ void ModelChecker::r_modification_order(ModelAction * curr, const ModelAction *r
        }
 }
 
        }
 }
 
+/** Updates the cyclegraph with the constraints imposed from the
+ *  current read. */
+void ModelChecker::post_r_modification_order(ModelAction * curr, const ModelAction *rf) {
+       std::vector<action_list_t> *thrd_lists = obj_thrd_map->ensureptr(curr->get_location());
+       unsigned int i;
+       ASSERT(curr->is_read());
+
+       /* Iterate over all threads */
+       for (i = 0; i < thrd_lists->size(); i++) {
+               /* Iterate over actions in thread, starting from most recent */
+               action_list_t *list = &(*thrd_lists)[i];
+               action_list_t::reverse_iterator rit;
+               ModelAction *lastact=NULL;
+
+               /* Find last action that happens after curr */
+               for (rit = list->rbegin(); rit != list->rend(); rit++) {
+                       ModelAction *act = *rit;
+                       if (curr->happens_before(act)) {
+                               lastact=act;
+                       } else
+                               break;
+               }
+
+                       /* Include at most one act per-thread that "happens before" curr */
+               if (lastact!=NULL) {
+                       if (lastact->is_read()) {
+                               const ModelAction * postreadfrom=lastact->get_reads_from();
+                               if (postreadfrom!=NULL&&rf!=postreadfrom)
+                                       cyclegraph->addEdge(postreadfrom, rf);
+                       } else if (rf!=lastact) {
+                               cyclegraph->addEdge(lastact, rf);
+                       }
+                       break;
+               }
+       }
+}
+
 /**
  * Updates the cyclegraph with the constraints imposed from the current write.
  * @param curr The current action. Must be a write.
 /**
  * Updates the cyclegraph with the constraints imposed from the current write.
  * @param curr The current action. Must be a write.
@@ -541,6 +578,7 @@ void ModelChecker::resolve_promises(ModelAction *write) {
                        ModelAction * read=promise->get_action();
                        read->read_from(write);
                        r_modification_order(read, write);
                        ModelAction * read=promise->get_action();
                        read->read_from(write);
                        r_modification_order(read, write);
+                       post_r_modification_order(read, write);
                        promises->erase(promises->begin()+promise_index);
                } else
                        promise_index++;
                        promises->erase(promises->begin()+promise_index);
                } else
                        promise_index++;
diff --git a/model.h b/model.h
index c13dffd7f24c01a2802ebcc2a1351d1a7231aa22..4a55c52b5e9f2ac637b952f12598d7374ccb561f 100644 (file)
--- a/model.h
+++ b/model.h
@@ -88,6 +88,7 @@ private:
        ModelAction * get_last_seq_cst(const void *location);
        void build_reads_from_past(ModelAction *curr);
        ModelAction * process_rmw(ModelAction * curr);
        ModelAction * get_last_seq_cst(const void *location);
        void build_reads_from_past(ModelAction *curr);
        ModelAction * process_rmw(ModelAction * curr);
+       void post_r_modification_order(ModelAction * curr, const ModelAction *rf);
        void r_modification_order(ModelAction * curr, const ModelAction *rf);
        void w_modification_order(ModelAction * curr);
 
        void r_modification_order(ModelAction * curr, const ModelAction *rf);
        void w_modification_order(ModelAction * curr);