bugfix - set backtrack events according to an *enabled* thread
authorBrian Norris <banorris@uci.edu>
Fri, 4 May 2012 06:46:43 +0000 (23:46 -0700)
committerBrian Norris <banorris@uci.edu>
Tue, 8 May 2012 17:35:33 +0000 (10:35 -0700)
Previously, I naively set a backtracking point for the thread that performed
the conflicting action, whether or not that thread existed at the point to
which I am backtracking. Utilize the TreeNode::is_enabled() method, plus thread
parent walking, to find the correct thread for the backtracking.

Note that this also requires a model checking event for each THREAD_CREATE
event. So add this feature.

libthreads.cc
model.cc

index 73a948cc4a493a7fa4b3c1bea65af8653c6ebc17..b5760ae6eab89f381a67b12a4e05f0402ef7ad76 100644 (file)
@@ -14,6 +14,8 @@ int thrd_create(thrd_t *t, void (*start_routine)(), void *arg)
        DBG();
        ret = model->add_thread(new Thread(t, start_routine, arg));
        DEBUG("create thread %d\n", id_to_int(thrd_to_id(*t)));
+       /* seq_cst is just a 'don't care' parameter */
+       model->switch_to_master(new ModelAction(THREAD_CREATE, memory_order_seq_cst, NULL, VALUE_NONE));
        return ret;
 }
 
index 0084e74fcf69b989f8c2c91a8bdc747caa546494..e3238258a3aa86b0570ff8ed8159eb62e27a899c 100644 (file)
--- a/model.cc
+++ b/model.cc
@@ -190,6 +190,9 @@ void ModelChecker::set_backtracking(ModelAction *act)
 
        node = prev->get_node();
 
+       while (t && !node->is_enabled(t))
+               t = t->get_parent();
+
        /* Check if this has been explored already */
        if (node->hasBeenExplored(t->get_id()))
                return;