From 6c543879a31d7d13a6b87e6332f6913f2f89f5e6 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Tue, 9 Oct 2018 15:25:18 +0200 Subject: Avoid races on TZ in environment via tzset() calls POSIX specifies that tzset() consults environment variable TZ and modifies some globals; it also specifies mktime(), localtime() and strftime() to behave as if they called tzset(). Fortunately, we only call strftime() from a test and only call localtime() when not threaded. Provide wrappers for tzset() and mktime() that share the lock used by our environment-access code, to prevent races on the environment (and tzset()'s globals) when we call them. In the process, re-use tst_QDateTime's TimeZoneRollback in its older test systemTimeZoneChange() and presume that this can now be tested cross-platform, since TimeZoneRollback is used in another test where this works. Fixes: QTBUG-71030 Change-Id: I79f559b8857ea2803e73501008bf0d7158c6731f Reviewed-by: Thiago Macieira --- src/corelib/global/qglobal_p.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/corelib/global/qglobal_p.h') diff --git a/src/corelib/global/qglobal_p.h b/src/corelib/global/qglobal_p.h index 0f092e9006..d52f6268e4 100644 --- a/src/corelib/global/qglobal_p.h +++ b/src/corelib/global/qglobal_p.h @@ -61,6 +61,16 @@ #endif #if defined(__cplusplus) +#include + +QT_BEGIN_NAMESPACE + +// These behave as if they consult the environment, so need to share its locking: +Q_CORE_EXPORT void qTzSet(); +Q_CORE_EXPORT time_t qMkTime(struct tm *when); + +QT_END_NAMESPACE + #if !QT_HAS_BUILTIN(__builtin_available) #include #include -- cgit v1.2.3