libqt5-qtwebengine/QTBUG-82186.patch

49 lines
2.4 KiB
Diff

From c729361f9f8f6c0602d401d5e230ba63ab11a682 Mon Sep 17 00:00:00 2001
From: Jüri Valdmann <juri.valdmann@qt.io>
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
---
Index: qtwebengine-everywhere-src-5.15.0-beta4/src/3rdparty/chromium/sandbox/linux/services/libc_interceptor.cc
===================================================================
--- qtwebengine-everywhere-src-5.15.0-beta4.orig/src/3rdparty/chromium/sandbox/linux/services/libc_interceptor.cc
+++ qtwebengine-everywhere-src-5.15.0-beta4/src/3rdparty/chromium/sandbox/linux/services/libc_interceptor.cc
@@ -190,6 +190,7 @@ static void InitLibcLocaltimeFunctionsIm
g_libc_localtime64_r =
reinterpret_cast<LocaltimeRFunction>(dlsym(RTLD_NEXT, "localtime64_r"));
+#if !defined(TOOLKIT_QT)
if (!g_libc_localtime || !g_libc_localtime_r) {
// https://bugs.chromium.org/p/chromium/issues/detail?id=16800
//
@@ -201,6 +202,7 @@ static void InitLibcLocaltimeFunctionsIm
" time related functions to misbehave. "
"https://bugs.chromium.org/p/chromium/issues/detail?id=16800";
}
+#endif
if (!g_libc_localtime)
g_libc_localtime = gmtime;