model/action: bugfix - UNINIT actions do not have a Node
authorBrian Norris <banorris@uci.edu>
Fri, 7 Dec 2012 06:53:07 +0000 (22:53 -0800)
committerBrian Norris <banorris@uci.edu>
Fri, 7 Dec 2012 06:53:07 +0000 (22:53 -0800)
Fix the one place where ModelChecker looks for a Node in an UNINIT
action.

This also adds an ASSERT() within ModelAction to prevent calling
get_node() on an UNINIT action. It is technically OK to call get_node()
in this case, but most callers don't check for NULL, so it's better to
just catch the ASSERT() for this unwanted special case.

action.cc
model.cc

index 121f5ee7499d7161257dd136e5edd646bc8c8c94..d418bdbb6a18ff1e3246b26ef5e8371ecde285b9 100644 (file)
--- a/action.cc
+++ b/action.cc
@@ -349,6 +349,8 @@ void ModelAction::set_try_lock(bool obtainedlock) {
 /** @return The Node associated with this ModelAction */
 Node * ModelAction::get_node() const
 {
+       /* UNINIT actions do not have a Node */
+       ASSERT(!is_uninitialized());
        return node;
 }
 
index 1499d12aa3a9a6c8c24c9838602c23f532c86140..7bff598f974e762daecc27d7d58926bdfa466d68 100644 (file)
--- a/model.cc
+++ b/model.cc
@@ -2510,7 +2510,10 @@ void ModelChecker::build_reads_from_past(ModelAction *curr)
 }
 
 bool ModelChecker::sleep_can_read_from(ModelAction * curr, const ModelAction *write) {
-       while(true) {
+       while (true) {
+               /* UNINIT actions don't have a Node, and they never sleep */
+               if (write->is_uninitialized())
+                       return true;
                Node *prevnode=write->get_node()->get_parent();
 
                bool thread_sleep=prevnode->enabled_status(curr->get_tid())==THREAD_SLEEP_SET;