Skip to content

Commit

Permalink
Remove deadlock in ot_terminate()
Browse files Browse the repository at this point in the history
The method acquires a lock on the static mutex `the_Mutex`.

It then calls itself recursively by re-throwing the exception and hangs because
it has already acquired the lock.

This freezes the process on my Linux system, but it should freeze on other
systems as well.

Unclear purpose, removed.

The mutex used in the signal handler code has the same issue.
  • Loading branch information
OttoAllmendinger committed Sep 29, 2014
1 parent a29d030 commit 93c6083
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions src/core/OTLog.cpp
Expand Up @@ -294,7 +294,7 @@ int OTLogStream::overflow(int c)
return 0;
}

// OTLog Init, must run this befor useing any OTLog function.
// OTLog Init, must run this before using any OTLog function.

// static
bool OTLog::Init(const OTString& strThreadContext, const int32_t& nLogLevel)
Expand Down Expand Up @@ -945,10 +945,6 @@ static const bool SET_TERMINATE = std::set_terminate(ot_terminate);
//
void ot_terminate()
{
static std::mutex the_Mutex;

std::lock_guard<std::mutex> lock(the_Mutex);

try {
// try once to re-throw currently active exception
static bool tried_throw = false;
Expand Down

0 comments on commit 93c6083

Please sign in to comment.