Skip to content

Commit

Permalink
Change function return status to std::atomic to avoid races and deadlock
Browse files Browse the repository at this point in the history
  • Loading branch information
mxz297 committed May 29, 2018
1 parent 5016030 commit 9f497d9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions parseAPI/h/CFG.h
Expand Up @@ -48,6 +48,7 @@
#include <boost/thread/lockable_adapter.hpp>
#include <boost/thread/recursive_mutex.hpp>
#include <list>
#include <atomic>

namespace Dyninst {

Expand Down Expand Up @@ -463,7 +464,7 @@ class PARSER_EXPORT Function : public allocatable, public AnnotatableSparse, pub
InstructionSource * _isrc;

FuncSource _src;
FuncReturnStatus _rs;
std::atomic<FuncReturnStatus> _rs;

std::string _name;
Block * _entry;
Expand Down Expand Up @@ -507,8 +508,7 @@ class PARSER_EXPORT Function : public allocatable, public AnnotatableSparse, pub
CodeObject * obj() const { return _obj; }
FuncSource src() const { return _src; }
FuncReturnStatus retstatus() const {
boost::lock_guard<const Function> g(*this);
return _rs;
return _rs.load();
}
Block * entry() const { return _entry; }
bool parsed() const { return _parsed; }
Expand Down
2 changes: 1 addition & 1 deletion parseAPI/src/Function.C
Expand Up @@ -519,7 +519,7 @@ void Function::set_retstatus(FuncReturnStatus rs)
} else if (rs == UNKNOWN) {
_obj->cs()->incrementCounter(PARSE_UNKNOWN_COUNT);
}
_rs = rs;
_rs.store(rs);
}

void
Expand Down

0 comments on commit 9f497d9

Please sign in to comment.