Skip to content

Commit

Permalink
fix(profiler): potential segfault after main function
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasrothenberger committed May 17, 2024
1 parent e7c82f1 commit 252062f
Show file tree
Hide file tree
Showing 14 changed files with 25 additions and 20 deletions.
2 changes: 1 addition & 1 deletion rtlib/functions/dp_add_bb_deps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace __dp {
extern "C" {
// hybrid analysis
void __dp_add_bb_deps(char *depStringPtr) {
if(!dpInited){
if((!dpInited) || (targetTerminated)){
return;
}

Expand Down
2 changes: 1 addition & 1 deletion rtlib/functions/dp_alloca.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ extern "C" {

void __dp_alloca(LID lid, char *var, ADDR startAddr, ADDR endAddr,
int64_t numBytes, int64_t numElements) {
if (!dpInited){
if ((!dpInited) || (targetTerminated)){
return;
}

Expand Down
2 changes: 1 addition & 1 deletion rtlib/functions/dp_call.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ namespace __dp {
extern "C" {

void __dp_call(LID lid) {
if (!dpInited){
if ((!dpInited) || (targetTerminated)){
return;
}

Expand Down
2 changes: 1 addition & 1 deletion rtlib/functions/dp_decl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ void __dp_decl(LID lid, ADDR addr, char *var, ADDR lastaddr, int64_t count) {
void __dp_decl(LID lid, ADDR addr, char *var) {
#endif

if (!dpInited){
if ((!dpInited) || (targetTerminated)){
return;
}

Expand Down
2 changes: 1 addition & 1 deletion rtlib/functions/dp_delete.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ namespace __dp {
extern "C" {

void __dp_delete(LID lid, ADDR startAddr) {
if (!dpInited){
if ((!dpInited) || (targetTerminated)){
return;
}

Expand Down
4 changes: 4 additions & 0 deletions rtlib/functions/dp_finalize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ namespace __dp {
extern "C" {

void __dp_finalize(LID lid) {
if(targetTerminated){
return;
}

#ifdef DP_PTHREAD_COMPATIBILITY_MODE
pthread_compatibility_mutex.lock();
#endif
Expand Down
17 changes: 9 additions & 8 deletions rtlib/functions/dp_func_exit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,24 +31,25 @@ namespace __dp {
extern "C" {

void __dp_func_exit(LID lid, int32_t isExit) {
#ifdef DP_PTHREAD_COMPATIBILITY_MODE
std::lock_guard<std::mutex> guard(pthread_compatibility_mutex);
#endif
#ifdef DP_RTLIB_VERBOSE
cout << "__dp_func_exit\n";
#endif
timers->start(TimerRegion::FUNC_EXIT);

if (targetTerminated) {
if (DP_DEBUG) {
cout << "Exiting function LID " << std::dec << dputil::decodeLID(lid);
cout << " but target program has returned from main(). Destructors?"
<< endl;
}
timers->stop_and_add(TimerRegion::FUNC_EXIT);
return;
}

#ifdef DP_PTHREAD_COMPATIBILITY_MODE
std::lock_guard<std::mutex> guard(pthread_compatibility_mutex);
#endif
#ifdef DP_RTLIB_VERBOSE
cout << "__dp_func_exit\n";
#endif
timers->start(TimerRegion::FUNC_EXIT);


lastCallOrInvoke = 0;
lastProcessedLine = lid;

Expand Down
2 changes: 1 addition & 1 deletion rtlib/functions/dp_loop_entry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ namespace __dp {
extern "C" {

void __dp_loop_entry(LID lid, int32_t loopID) {
if (!dpInited){
if ((!dpInited) || (targetTerminated)){
return;
}

Expand Down
2 changes: 1 addition & 1 deletion rtlib/functions/dp_loop_exit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ namespace __dp {
extern "C" {

void __dp_loop_exit(LID lid, int32_t loopID) {
if(!dpInited){
if((!dpInited) || (targetTerminated)){
return;
}

Expand Down
2 changes: 1 addition & 1 deletion rtlib/functions/dp_new.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ namespace __dp {
extern "C" {

void __dp_new(LID lid, ADDR startAddr, ADDR endAddr, int64_t numBytes) {
if (!dpInited){
if ((!dpInited) || (targetTerminated)){
return;
}

Expand Down
2 changes: 1 addition & 1 deletion rtlib/functions/dp_read.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ void __dp_read(LID lid, ADDR addr, char *var, ADDR lastaddr, int64_t count) {
void __dp_read(LID lid, ADDR addr, char *var) {
#endif

if (!dpInited){
if ((!dpInited) || (targetTerminated)){
return;
}

Expand Down
2 changes: 1 addition & 1 deletion rtlib/functions/dp_report_bb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ namespace __dp {
extern "C" {

void __dp_report_bb(uint32_t bbIndex) {
if (!dpInited){
if ((!dpInited) || (targetTerminated)){
return;
}

Expand Down
2 changes: 1 addition & 1 deletion rtlib/functions/dp_report_bb_pair.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ namespace __dp {
extern "C" {

void __dp_report_bb_pair(int32_t semaphore, uint32_t bbIndex) {
if (!dpInited){
if ((!dpInited) || (targetTerminated)){
return;
}

Expand Down
2 changes: 1 addition & 1 deletion rtlib/functions/dp_write.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ void __dp_write(LID lid, ADDR addr, char *var, ADDR lastaddr, int64_t count) {
void __dp_write(LID lid, ADDR addr, char *var) {
#endif

if (!dpInited){
if ((!dpInited) || (targetTerminated)){
return;
}

Expand Down

0 comments on commit 252062f

Please sign in to comment.