From d28d1a3b7aafbcd2caf80de26721293126830fa8 Mon Sep 17 00:00:00 2001 From: Brian Demsky Date: Fri, 26 Apr 2013 13:46:35 -0700 Subject: [PATCH] Fix bug that prevents graph generation from compiling. Check in test case that shows theorem that I've been trying to prove for 2 days is in fact not true (and thus difficult to prove). --- execution.cc | 2 +- scanalysis.cc | 3 +++ test/sctest.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 test/sctest.c diff --git a/execution.cc b/execution.cc index e01181a..f2c50c4 100644 --- a/execution.cc +++ b/execution.cc @@ -2643,7 +2643,7 @@ void ModelExecution::dumpGraph(char *filename) const mo_graph->dumpNodes(file); ModelAction **thread_array = (ModelAction **)model_calloc(1, sizeof(ModelAction *) * get_num_threads()); - for (action_list_t::iterator it = action_trace.begin(); it != action_trace.end(); it++) { + for (action_list_t::const_iterator it = action_trace.begin(); it != action_trace.end(); it++) { ModelAction *act = *it; if (act->is_read()) { mo_graph->dot_print_node(file, act); diff --git a/scanalysis.cc b/scanalysis.cc index 8aa400c..d4102fe 100644 --- a/scanalysis.cc +++ b/scanalysis.cc @@ -145,7 +145,10 @@ action_list_t * SCAnalysis::generateSC(action_list_t *list) { //add ordering constraints from this choice if (updateConstraints(act)) { //propagate changes if we have them + bool oc=cyclic; computeCV(list); + if (!oc && cyclic) + model_print("XXXXXXXXXXXXXX\n"); } //add action to end sclist->push_back(act); diff --git a/test/sctest.c b/test/sctest.c new file mode 100644 index 0000000..7aa4805 --- /dev/null +++ b/test/sctest.c @@ -0,0 +1,55 @@ +#include +#include +#include + +#include "librace.h" + +atomic_int x; +atomic_int y; +atomic_int z; + +static void a(void *obj) +{ + atomic_store_explicit(&z, 1, memory_order_relaxed); +} + +static void b(void *obj) +{ + atomic_store_explicit(&x, 1, memory_order_relaxed); + atomic_store_explicit(&y, 1, memory_order_relaxed); + int r1=atomic_load_explicit(&z, memory_order_relaxed); +} +static void c(void *obj) +{ + atomic_store_explicit(&z, 2, memory_order_relaxed); + atomic_store_explicit(&x, 2, memory_order_relaxed); + int r2=atomic_load_explicit(&y, memory_order_relaxed); +} + +static void d(void *obj) +{ + atomic_store_explicit(&z, 3, memory_order_relaxed); + atomic_store_explicit(&y, 2, memory_order_relaxed); + int r3=atomic_load_explicit(&x, memory_order_relaxed); +} + +int user_main(int argc, char **argv) +{ + thrd_t t1, t2,t3, t4; + + atomic_init(&x, 0); + atomic_init(&y, 0); + atomic_init(&z, 0); + + thrd_create(&t1, (thrd_start_t)&a, NULL); + thrd_create(&t2, (thrd_start_t)&b, NULL); + thrd_create(&t3, (thrd_start_t)&c, NULL); + thrd_create(&t4, (thrd_start_t)&d, NULL); + + thrd_join(t1); + thrd_join(t2); + thrd_join(t3); + thrd_join(t4); + + return 0; +} -- 2.34.1