model: hack dumpGraph() bug by "leaking" promises
authorBrian Norris <banorris@uci.edu>
Sat, 2 Mar 2013 22:49:00 +0000 (14:49 -0800)
committerBrian Norris <banorris@uci.edu>
Sat, 2 Mar 2013 22:54:50 +0000 (14:54 -0800)
It is possible to end up in an inconsistent state, where a "resolved"
promise may still be referenced if CycleGraph::resolvePromise() failed,
so don't delete 'promise'. Technically, this leaks memory within an
execution, but because it is allocated on the snapshotting heap, this
leak goes away after an execution ends. So, rather than spending more
work on "fixing" the inconsistency, just don't delete the promise yet.

This inconsistency only matters when dumping the mo_graph to file, since
it traverses all the ModelAction/Promise edges, including those that are
semi-dangling mid-merge.

model.cc

index e016ae49bc9cb212638cbff3ae59ea22b7faa8f6..aba71772fde8638892165bf9775df78be30f2819 100644 (file)
--- a/model.cc
+++ b/model.cc
@@ -2524,11 +2524,19 @@ bool ModelChecker::resolve_promise(ModelAction *write, unsigned int promise_idx)
                priv->failed_promise = true;
 
        promises->erase(promises->begin() + promise_idx);
-       delete promise;
+       /**
+        * @todo  It is possible to end up in an inconsistent state, where a
+        * "resolved" promise may still be referenced if
+        * CycleGraph::resolvePromise() failed, so don't delete 'promise'.
+        *
+        * Note that the inconsistency only matters when dumping mo_graph to
+        * file.
+        *
+        * delete promise;
+        */
 
        //Check whether reading these writes has made threads unable to
        //resolve promises
-
        for (unsigned int i = 0; i < actions_to_check.size(); i++) {
                ModelAction *read = actions_to_check[i];
                mo_check_promises(read, true);