model: is_deadlocked() (sort of) had a bug
authorBrian Norris <banorris@uci.edu>
Wed, 14 Nov 2012 23:53:16 +0000 (15:53 -0800)
committerBrian Norris <banorris@uci.edu>
Wed, 14 Nov 2012 23:53:16 +0000 (15:53 -0800)
We were comparing the boolean (is_enabled(t)) to an enum
(THREAD_DISABLED). This happened to work as we wanted to because
THREAD_DISABLED == 0 == false. But that's not really what I meant...

Anyway, this uses a proper ModelChecker::is_enabled(tid) interface.

model.cc

index 35eefa674d43d937799acd8940e00d1b0faf4cc3..daf2d15cf2f3227bedc0abc0094bcfed20d12308 100644 (file)
--- a/model.cc
+++ b/model.cc
@@ -266,10 +266,11 @@ bool ModelChecker::is_deadlocked() const
 {
        bool blocking_threads = false;
        for (unsigned int i = 0; i < get_num_threads(); i++) {
 {
        bool blocking_threads = false;
        for (unsigned int i = 0; i < get_num_threads(); i++) {
-               Thread *t = get_thread(int_to_id(i));
-               if (scheduler->is_enabled(t) != THREAD_DISABLED)
+               thread_id_t tid = int_to_id(i);
+               if (is_enabled(tid))
                        return false;
                        return false;
-               else if (!t->is_model_thread() && t->get_pending())
+               Thread *t = get_thread(tid);
+               if (!t->is_model_thread() && t->get_pending())
                        blocking_threads = true;
        }
        return blocking_threads;
                        blocking_threads = true;
        }
        return blocking_threads;