mirror of https://gitee.com/bigwinds/arangodb
Fix a shutdown busy loop after main if two exceptions collide. (#9982)
This commit is contained in:
parent
e5da8b1cef
commit
4656bd0a6a
|
@ -330,6 +330,11 @@ namespace arangodb {
|
||||||
// arangodb::application_features::ApplicationServer::server->beginShutdown();
|
// arangodb::application_features::ApplicationServer::server->beginShutdown();
|
||||||
|
|
||||||
int main(int argc, char* argv[]) {
|
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());
|
std::string workdir(arangodb::basics::FileUtils::currentDirectory().result());
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
#if USE_ENTERPRISE
|
#if USE_ENTERPRISE
|
||||||
|
|
|
@ -2642,3 +2642,21 @@ bool TRI_GETENV(char const* which, std::string& value) {
|
||||||
return true;
|
return true;
|
||||||
#endif
|
#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
|
||||||
|
|
||||||
|
|
|
@ -671,6 +671,15 @@
|
||||||
#define TRI_uid_t uid_t
|
#define TRI_uid_t uid_t
|
||||||
#define TRI_gid_t gid_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
|
#endif
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
Loading…
Reference in New Issue