Skip to content

Commit

Permalink
Merge pull request #347 from mfherbst/master
Browse files Browse the repository at this point in the history
Disable dlclose calls on EngineOpenMP destruction
  • Loading branch information
madsbk committed May 29, 2017
2 parents 5f0b8b0 + 17120bd commit 58ba2dc
Showing 1 changed file with 22 additions and 6 deletions.
28 changes: 22 additions & 6 deletions ve/openmp/engine_openmp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,28 @@ EngineOpenMP::EngineOpenMP(const ConfigParser &config, jitk::Statistics &stat) :
}

EngineOpenMP::~EngineOpenMP() {
for(void *handle: _lib_handles) {
dlerror(); // Reset errors
if (dlclose(handle)) {
cerr << dlerror() << endl;
}
}
// If this cleanup is enabled, the application segfaults
// on destruction of the EngineOpenMP class.
//
// The reason for that is that OpenMP currently has no
// means in the definition of the standard to do a proper
// cleanup and hence internally does something funny.
// See https://stackoverflow.com/questions/5200418/destroying-threads-in-openmp-c
// for details.
//
// TODO A more sensible way to get around this issue
// would be to also dlopen the openmp library
// itself and therefore increase our reference count
// to it. This enables the kernel so files to be unlinked
// and cleaned up, but prevents the problematic code on
// openmp cleanup to be triggered at bohrium runtime.

// for(void *handle: _lib_handles) {
// dlerror(); // Reset errors
// if (dlclose(handle)) {
// cerr << dlerror() << endl;
// }
// }
}

// Returns the filename of the given 'hash'
Expand Down

0 comments on commit 58ba2dc

Please sign in to comment.