1
0
Fork 0

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

This commit is contained in:
Max Neunhöffer 2019-09-13 12:27:54 +02:00 committed by KVS85
parent 227a92dd3a
commit 59a90f28c0
3 changed files with 32 additions and 0 deletions

View File

@ -299,6 +299,11 @@ static void WINAPI ServiceMain(DWORD dwArgc, LPSTR* lpszArgv) {
#endif
int main(int argc, char* argv[]) {
#ifdef __linux__
// Do not delete this! See lib/Basics/operating-system.h for details.
ThrowSomeException();
#endif
#ifdef __linux__
#if USE_ENTERPRISE
arangodb::checkLicenseKey();

View File

@ -2451,3 +2451,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

@ -675,6 +675,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
// -----------------------------------------------------------------------------