From ef795ab915a9311fc24c7ea7048f40d0a3bb34b3 Mon Sep 17 00:00:00 2001 From: root Date: Wed, 25 Dec 2019 19:54:20 -0800 Subject: [PATCH] More bug fixes --- action.cc | 5 +++++ action.h | 1 + cyclegraph.cc | 14 ++++++++++++++ cyclegraph.h | 1 + execution.cc | 7 ++++++- 5 files changed, 27 insertions(+), 1 deletion(-) diff --git a/action.cc b/action.cc index 814c7fb1..16dcc5cd 100644 --- a/action.cc +++ b/action.cc @@ -305,6 +305,11 @@ bool ModelAction::is_write() const return type == ATOMIC_WRITE || type == ATOMIC_RMW || type == ATOMIC_INIT || type == NONATOMIC_WRITE; } +bool ModelAction::is_create() const +{ + return type == THREAD_CREATE || type == PTHREAD_CREATE; +} + bool ModelAction::is_free() const { return type == READY_FREE; diff --git a/action.h b/action.h index 95167c43..2b4b4141 100644 --- a/action.h +++ b/action.h @@ -136,6 +136,7 @@ public: bool is_trylock() const; bool is_unlock() const; bool is_wait() const; + bool is_create() const; bool is_notify() const; bool is_notify_one() const; bool is_success_lock() const; diff --git a/cyclegraph.cc b/cyclegraph.cc index bb481e13..6c7e945e 100644 --- a/cyclegraph.cc +++ b/cyclegraph.cc @@ -297,6 +297,10 @@ void CycleGraph::freeAction(const ModelAction * act) { CycleNode *dst = cn->edges[i]; dst->removeInEdge(cn); } + for(unsigned int i=0;iinedges.size();i++) { + CycleNode *src = cn->inedges[i]; + src->removeEdge(cn); + } delete cn; } @@ -325,6 +329,16 @@ void CycleNode::removeInEdge(CycleNode *src) { } } +void CycleNode::removeEdge(CycleNode *dst) { + for(unsigned int i=0;i < edges.size();i++) { + if (edges[i] == dst) { + edges[i] = edges[edges.size()-1]; + edges.pop_back(); + break; + } + } +} + /** * @param i The index of the edge to return * @returns The CycleNode edge indexed by i diff --git a/cyclegraph.h b/cyclegraph.h index a7e2a115..716e811d 100644 --- a/cyclegraph.h +++ b/cyclegraph.h @@ -70,6 +70,7 @@ public: void clearRMW() { hasRMW = NULL; } ModelAction * getAction() const { return action; } void removeInEdge(CycleNode *src); + void removeEdge(CycleNode *dst); ~CycleNode(); SNAPSHOTALLOC diff --git a/execution.cc b/execution.cc index 4e4a6bb2..1c03a97a 100644 --- a/execution.cc +++ b/execution.cc @@ -63,7 +63,7 @@ ModelExecution::ModelExecution(ModelChecker *m, Scheduler *scheduler) : thrd_last_fence_release(), priv(new struct model_snapshot_members ()), mo_graph(new CycleGraph()), - fuzzer(new NewFuzzer()), + fuzzer(new Fuzzer()), isfinished(false) { /* Initialize a model-checker thread, for special ModelActions */ @@ -1823,6 +1823,11 @@ void ModelExecution::collectActions() { removeAction(act); delete act; } + } else if (act->is_create()) { + if (act->get_thread_operand()->get_state()==THREAD_COMPLETED) { + removeAction(act); + delete act; + } } else { removeAction(act); delete act; -- 2.34.1