From c729361f9f8f6c0602d401d5e230ba63ab11a682 Mon Sep 17 00:00:00 2001 From: Jüri Valdmann Date: Wed, 19 Feb 2020 14:15:34 +0100 Subject: [PATCH] Fix recursive deadlock in sandbox::InitLibcLocaltimeFunctions QtWebEngineProcess overrides the C library's localtime* functions by redefining the symbols in src/process/main.cpp and then using dlsym(RTLD_NEXT, ...) to fetch the original symbols in //sandbox/linux/services/libc_interceptor.cc. The functions InitLibcLocaltimeFunctions{,Impl} use pthread_once to guarantee that this symbol resolution happens only once. If dlsym fails, for example because the C library is earlier in the search path than QtWebEngineCore, then InitLibcLocaltimeFunctionsImpl tries to print an error message with LOG(ERROR). However, printing a log message involves also printing the timestamp in the local time zone, using, of course, localtime_r. Thus, InitLibcLocaltimeFunctions depends on localtime_r depends on InitLibcLocaltimeFunctions, and we get a deadlock due to the recursive use of pthread_once. This deadlock happens only for utility processes and not for zygotes or renderers, since the latter proxy the localtime* calls back to the main process. (See service_manager::ZygoteMain, where the first function call is to sandbox::SetAmZygoteOrRenderer, and compare with content::UtilityMain) Task-number: QTBUG-82186 Change-Id: I32009e8482b2634c47082a4c89393dc61c22507e --- diff --git a/src/3rdparty/chromium/sandbox/linux/services/libc_interceptor.cc b/chromium/sandbox/linux/services/libc_interceptor.cc index ed4dd02..fad77f9 100644 --- a/src/3rdparty/chromium/sandbox/linux/services/libc_interceptor.cc +++ b/src/3rdparty/chromium/sandbox/linux/services/libc_interceptor.cc @@ -199,6 +199,7 @@ g_libc_funcs->localtime64_r = reinterpret_cast(dlsym(RTLD_NEXT, "localtime64_r")); +#if !defined(TOOLKIT_QT) if (!g_libc_funcs->localtime || !g_libc_funcs->localtime_r) { // https://bugs.chromium.org/p/chromium/issues/detail?id=16800 // @@ -210,6 +211,7 @@ " time related functions to misbehave. " "https://bugs.chromium.org/p/chromium/issues/detail?id=16800"; } +#endif if (!g_libc_funcs->localtime) g_libc_funcs->localtime = gmtime;