From: Brian Demsky Date: Sat, 28 Jul 2012 17:45:48 +0000 (-0700) Subject: forgot about events that happen after an unresolved read... bug fix checked in X-Git-Tag: pldi2013~298 X-Git-Url: http://plrg.eecs.uci.edu/git/?p=model-checker.git;a=commitdiff_plain;h=c47ea1e8fc71e7934d6a670802247d41a603128a forgot about events that happen after an unresolved read... bug fix checked in --- diff --git a/model.cc b/model.cc index c87f5f9..2b2a5f0 100644 --- 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 (rf!=prevreadfrom) + if (prevreadfrom!=NULL&&rf!=prevreadfrom) 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 *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. @@ -541,6 +578,7 @@ void ModelChecker::resolve_promises(ModelAction *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++; diff --git a/model.h b/model.h index c13dffd..4a55c52 100644 --- 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); + 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);