Skip to content
Permalink
Browse files

Make sure that backtrace dump from multiple threads does not cause de…

…adlocks
  • Loading branch information
wonder-sk committed Jul 23, 2016
1 parent b6b5afd commit 7b8c1c5ae1361acd5692673006a8ecb7b2437837
Showing with 8 additions and 0 deletions.
  1. +8 −0 src/app/main.cpp
@@ -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 )
{

0 comments on commit 7b8c1c5

Please sign in to comment.
You can’t perform that action at this time.