From ddb5900f2e0dbde556fd320960f048965cf4f2c2 Mon Sep 17 00:00:00 2001 From: Brian Norris Date: Sat, 2 Mar 2013 14:49:00 -0800 Subject: [PATCH] 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. --- model.cc | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/model.cc b/model.cc index e016ae4..aba7177 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); -- 2.34.1