From: Brian Demsky <bdemsky@uci.edu>
Date: Thu, 13 Sep 2012 05:57:00 +0000 (-0700)
Subject: fix for horrible bug...  turns out that we could generate an infinite set of bad... 
X-Git-Tag: pldi2013~211
X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=03a2997dd18bfee9058c42019865eeb33262df21;p=model-checker.git

fix for horrible bug...  turns out that we could generate an infinite set of bad executions due to future values...
fix--don't send future values backwards until all of your promises are resolved...
---

diff --git a/model.cc b/model.cc
index 015ca16..795c4a9 100644
--- a/model.cc
+++ b/model.cc
@@ -28,6 +28,7 @@ ModelChecker::ModelChecker(struct model_params params) :
 	obj_map(new HashTable<const void *, action_list_t, uintptr_t, 4>()),
 	obj_thrd_map(new HashTable<void *, std::vector<action_list_t>, uintptr_t, 4 >()),
 	promises(new std::vector<Promise *>()),
+	futurevalues(new std::vector<struct PendingFutureValue>()),
 	lazy_sync_with_release(new HashTable<void *, std::list<ModelAction *>, uintptr_t, 4>()),
 	thrd_last_action(new std::vector<ModelAction *>(1)),
 	node_stack(new NodeStack()),
@@ -404,6 +405,16 @@ Thread * ModelChecker::check_current_action(ModelAction *curr)
 		bool updated_promises=resolve_promises(curr);
 		updated=updated_mod_order|updated_promises;
 
+		if (promises->size()==0) {
+			for(unsigned int i=0;i<futurevalues->size();i++) {
+				struct PendingFutureValue pfv=(*futurevalues)[i];
+				if (pfv.act->get_node()->add_future_value(pfv.value, pfv.expiration) &&
+						(!priv->next_backtrack || *pfv.act > *priv->next_backtrack))
+					priv->next_backtrack = pfv.act;
+			}
+			futurevalues->resize(0);
+		}
+
 		mo_graph->commitChanges();
 		th->set_return_value(VALUE_NONE);
 	}
@@ -714,9 +725,8 @@ bool ModelChecker::w_modification_order(ModelAction *curr)
 				if (thin_air_constraint_may_allow(curr, act)) {
 					if (isfeasible() ||
 							(curr->is_rmw() && act->is_rmw() && curr->get_reads_from()==act->get_reads_from() && isfeasibleotherthanRMW())) {
-						if (act->get_node()->add_future_value(curr->get_value(), curr->get_seq_number()+params.maxfuturedelay) &&
-								(!priv->next_backtrack || *act > *priv->next_backtrack))
-							priv->next_backtrack = act;
+						struct PendingFutureValue pfv={curr->get_value(),curr->get_seq_number()+params.maxfuturedelay,act};
+						futurevalues->push_back(pfv);
 					}
 				}
 			}
diff --git a/model.h b/model.h
index fec8d1f..9afe642 100644
--- a/model.h
+++ b/model.h
@@ -32,6 +32,12 @@ struct model_params {
 	int maxfuturedelay;
 };
 
+struct PendingFutureValue {
+	uint64_t value;
+	modelclock_t expiration;
+	ModelAction * act;
+};
+
 /**
  * Structure for holding small ModelChecker members that should be snapshotted
  */
@@ -143,6 +149,7 @@ private:
 
 	HashTable<void *, std::vector<action_list_t>, uintptr_t, 4 > *obj_thrd_map;
 	std::vector<Promise *> *promises;
+	std::vector<struct PendingFutureValue> *futurevalues;
 
 	/**
 	 * Collection of lists of objects that might synchronize with one or