action: don't print clock vector when it is invalid
authorBrian Norris <banorris@uci.edu>
Tue, 2 Oct 2012 19:33:21 +0000 (12:33 -0700)
committerBrian Norris <banorris@uci.edu>
Wed, 3 Oct 2012 00:32:55 +0000 (17:32 -0700)
Due to clock vector snapshotting, a ModelAction may hold a pointer to
an inavlid ClockVector. This fix allows callers of ModelAction::print()
to prevent it from printing a corrupted ClockVector.

action.cc
action.h
model.cc

index 0063d0b27169f29dbe46d2fa71c3535fea2abc9c..6a18ffee8359603d41c475b374817e910287906c 100644 (file)
--- a/action.cc
+++ b/action.cc
@@ -268,7 +268,13 @@ bool ModelAction::happens_before(const ModelAction *act) const
        return act->cv->synchronized_since(this);
 }
 
-void ModelAction::print(void) const
+/**
+ * Print nicely-formatted info about this ModelAction
+ *
+ * @param print_cv True if we want to print clock vector data. Might be false,
+ * for instance, in situations where the clock vector might be invalid
+ */
+void ModelAction::print(bool print_cv) const
 {
        const char *type_str, *mo_str;
        switch (this->type) {
@@ -352,7 +358,7 @@ void ModelAction::print(void) const
                else
                        printf(" Rf: ?");
        }
-       if (cv) {
+       if (cv && print_cv) {
                printf("\t");
                cv->print();
        } else
index fecef4dbf3043ac920d5fb09efef85ffb8d6e863..2bf01dce092b71d1a0fa37bc82a29802036e9d1c 100644 (file)
--- a/action.h
+++ b/action.h
@@ -64,7 +64,7 @@ class ModelAction {
 public:
        ModelAction(action_type_t type, memory_order order, void *loc, uint64_t value = VALUE_NONE);
        ~ModelAction();
-       void print(void) const;
+       void print(bool print_cv = true) const;
 
        thread_id_t get_tid() const { return tid; }
        action_type get_type() const { return type; }
index ae0a787f3ad7a776c416a47cbb302d95f03c02c2..40519e5315a62b12d78d6427a5ab5001236c267f 100644 (file)
--- a/model.cc
+++ b/model.cc
@@ -184,7 +184,7 @@ bool ModelChecker::next_execution()
        if (isfinalfeasible()) {
                printf("Earliest divergence point since last feasible execution:\n");
                if (earliest_diverge)
-                       earliest_diverge->print();
+                       earliest_diverge->print(false);
                else
                        printf("(Not set)\n");