From: Brian Norris Date: Sat, 2 Mar 2013 22:49:00 +0000 (-0800) Subject: model: hack dumpGraph() bug by "leaking" promises X-Git-Url: http://plrg.eecs.uci.edu/git/?p=c11tester.git;a=commitdiff_plain;h=ddb5900f2e0dbde556fd320960f048965cf4f2c2 model: hack dumpGraph() bug by "leaking" promises 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. --- diff --git a/model.cc b/model.cc index e016ae49..aba71772 100644 --- 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);