1
0
Fork 0

Add more strong references to pthread stuff. (#10045)

* Add more strong references to pthread stuff.

* Circumvent libgcc/libmusl mistake in multi-threaded detection.

* CHANGELOG.
This commit is contained in:
Max Neunhöffer 2019-09-27 13:42:10 +02:00 committed by KVS85
parent a08a4d3395
commit b8502f8fa7
4 changed files with 31 additions and 28 deletions

View File

@ -1,6 +1,10 @@
v3.5.1 (XXXX-XX-XX)
-------------------
* Fix strange shutdown hanger which came from the fact that currently
libgcc/libmusl wrongly detect multi-threadedness in statically linked
executables.
* Fixed a shutdown bug coming from a read/write lock race.
* Fixed a bug in the edge cache's internal memory accounting, which led

View File

@ -329,10 +329,35 @@ namespace arangodb {
// *restartAction = myRestartAction;
// arangodb::application_features::ApplicationServer::server->beginShutdown();
#ifdef __linux__
// The following is a hack which is currently (September 2019) needed to
// let our static executables compiled with libmusl and gcc 8.3.0 properly
// detect that we are a multi-threaded application.
// See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91737 for developments
// in gcc/libgcc to address this issue.
static void* g(void *p) {
return p;
}
static void gg() {
}
static void f() {
pthread_t t;
pthread_create(&t, nullptr, g, nullptr);
pthread_cancel(t);
pthread_join(t, nullptr);
static pthread_once_t once_control = PTHREAD_ONCE_INIT;
pthread_once(&once_control, gg);
}
#endif
int main(int argc, char* argv[]) {
#ifdef __linux__
// Do not delete this! See lib/Basics/operating-system.h for details.
ThrowSomeException();
// Do not delete this! See above for an explanation.
if (argc >= 1 && strcmp(argv[0], "not a/valid name") == 0) { f(); }
#endif
std::string workdir(arangodb::basics::FileUtils::currentDirectory().result());

View File

@ -2643,20 +2643,3 @@ bool TRI_GETENV(char const* which, std::string& value) {
#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,15 +671,6 @@
#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
// -----------------------------------------------------------------------------