mirror of https://gitee.com/bigwinds/arangodb
Add more strong references to pthread stuff. (#10046)
* Add more strong references to pthread stuff. * Circumvent libgcc/libmusl mistake in multi-threaded detection.
This commit is contained in:
parent
e51bc5ca52
commit
59544d5b83
|
@ -1,6 +1,9 @@
|
|||
v3.4.9 (XXXX-XX-XX)
|
||||
-------------------
|
||||
|
||||
* Fix strange shutdown hanger which came from the fact that currently
|
||||
libgcc/libmusl wrongly detect multi-threadedness in statically linked
|
||||
executables.
|
||||
|
||||
* Obtain new unique IDs via a background thread.
|
||||
|
||||
|
|
|
@ -298,10 +298,35 @@ static void WINAPI ServiceMain(DWORD dwArgc, LPSTR* lpszArgv) {
|
|||
|
||||
#endif
|
||||
|
||||
#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
|
||||
|
||||
#ifdef __linux__
|
||||
|
|
|
@ -2452,20 +2452,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
|
||||
|
||||
|
|
|
@ -675,15 +675,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
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
|
Loading…
Reference in New Issue