Skip to content

Commit

Permalink
Make sure that backtrace dump from multiple threads does not cause de…
Browse files Browse the repository at this point in the history
…adlocks
  • Loading branch information
wonder-sk committed Jul 24, 2016
1 parent b6b5afd commit 7b8c1c5
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/app/main.cpp
Expand Up @@ -194,6 +194,14 @@ static void dumpBacktrace( unsigned int depth )
depth = 20;

#if ((defined(linux) || defined(__linux__)) && !defined(ANDROID)) || defined(__FreeBSD__)
// Below there is a bunch of operations that are not safe in multi-threaded
// environment (dup()+close() combo, wait(), juggling with file descriptors).
// Maybe some problems could be resolved with dup2() and waitpid(), but it seems
// that if the operations on descriptors are not serialized, things will get nasty.
// That's why there's this lovely mutex here...
static QMutex mutex;
QMutexLocker locker( &mutex );

int stderr_fd = -1;
if ( access( "/usr/bin/c++filt", X_OK ) < 0 )
{
Expand Down

0 comments on commit 7b8c1c5

Please sign in to comment.