1
0
Fork 0

Fix a shutdown busy loop after main if two exceptions collide. (#9982)

This commit is contained in:
Max Neunhöffer 2019-09-13 12:27:30 +02:00 committed by KVS85
parent e5da8b1cef
commit 4656bd0a6a
3 changed files with 32 additions and 0 deletions

View File

@ -330,6 +330,11 @@ namespace arangodb {
// arangodb::application_features::ApplicationServer::server->beginShutdown();
int main(int argc, char* argv[]) {
#ifdef __linux__
// Do not delete this! See lib/Basics/operating-system.h for details.
ThrowSomeException();
#endif
std::string workdir(arangodb::basics::FileUtils::currentDirectory().result());
#ifdef __linux__
#if USE_ENTERPRISE

View File

@ -2642,3 +2642,21 @@ bool TRI_GETENV(char const* which, std::string& value) {
return true;
#endif
}
//////////////////////////////////////////////////////////////////////////////
/// @brief bug fix for some race on libmusl and static linking
//////////////////////////////////////////////////////////////////////////////
// The following function just throws an exception and catches it. This is
// used on Linux for the case that we link statically and the underlying
// C-library is libmusl. This configuration has a bug in libgcc which
// triggers a shutdown busy loop (after main), provided the very first
// exception being thrown in the life of the process happens in two threads
// at the same time. By throwing right at the beginning of main() when the
// process is still single-threaded, we circumvent this problem.
#ifdef __linux__
void ThrowSomeException() {
try { throw 42; } catch(int const&) {};
}
#endif

View File

@ -671,6 +671,15 @@
#define TRI_uid_t uid_t
#define TRI_gid_t gid_t
// The following function just throws an exception and catches it. This is
// used on Linux for the case that we link statically and the underlying
// C-library is libmusl. This configuration has a bug in libgcc which
// triggers a shutdown busy loop (after main), provided the very first
// exception being thrown in the life of the process happens in two threads
// at the same time. By throwing right at the beginning of main() when the
// process is still single-threaded, we circumvent this problem.
void ThrowSomeException();
#endif
// -----------------------------------------------------------------------------