summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJüri Valdmann <juri.valdmann@qt.io>2020-02-19 14:15:34 +0100
committerJüri Valdmann <juri.valdmann@qt.io>2020-02-25 08:59:24 +0000
commit12a57d9c943eaa80d87481712fe58f7bf6678ba2 (patch)
tree1761f817aa35cf37795ce5c6b7b6acfe2edf4686
parentc3737fb3824b8bc4e1dfd84573d413bce0a68bdd (diff)
downloadqtwebengine-chromium-12a57d9c943eaa80d87481712fe58f7bf6678ba2.tar.gz
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 Reviewed-by: Michal Klocek <michal.klocek@qt.io>
-rw-r--r--chromium/sandbox/linux/services/libc_interceptor.cc2
1 files changed, 2 insertions, 0 deletions
diff --git a/chromium/sandbox/linux/services/libc_interceptor.cc b/chromium/sandbox/linux/services/libc_interceptor.cc
index ed4dd02473a..fad77f9b5f0 100644
--- a/chromium/sandbox/linux/services/libc_interceptor.cc
+++ b/chromium/sandbox/linux/services/libc_interceptor.cc
@@ -199,6 +199,7 @@ static void InitLibcLocaltimeFunctionsImpl() {
g_libc_funcs->localtime64_r =
reinterpret_cast<LocaltimeRFunction>(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 @@ static void InitLibcLocaltimeFunctionsImpl() {
" 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;