From 1ced3dc2f0a7640ec7f724c477ea87affc697ea9 Mon Sep 17 00:00:00 2001 From: Brian Norris Date: Tue, 2 Oct 2012 12:33:21 -0700 Subject: [PATCH] action: don't print clock vector when it is invalid 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 | 10 ++++++++-- action.h | 2 +- model.cc | 2 +- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/action.cc b/action.cc index 0063d0b2..6a18ffee 100644 --- 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 diff --git a/action.h b/action.h index fecef4db..2bf01dce 100644 --- 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; } diff --git a/model.cc b/model.cc index ae0a787f..40519e53 100644 --- 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"); -- 2.34.1