From 15edba41014690332f4753f932fa7d928096cb73 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 3 Sep 2019 07:49:32 -0700 Subject: qFatal: make it so you cannot disable the message Solves a few recursion problems in Qt, since then we won't try to inspect the logging registry while creating the logging registry. Fixes: QTBUG-78007 Change-Id: I44cc9ee732f54d2380bafffd15c0f51c7140682e Reviewed-by: Eskil Abrahamsen Blomfeldt Reviewed-by: Friedemann Kleint --- src/corelib/global/qlogging.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/corelib/global') diff --git a/src/corelib/global/qlogging.cpp b/src/corelib/global/qlogging.cpp index bf9c2ed2be..3c82097cfe 100644 --- a/src/corelib/global/qlogging.cpp +++ b/src/corelib/global/qlogging.cpp @@ -1814,8 +1814,8 @@ static void qt_message_print(QtMsgType msgType, const QMessageLogContext &contex #ifndef QT_BOOTSTRAPPED Q_TRACE(qt_message_print, msgType, context.category, context.function, context.file, context.line, message); - // qDebug, qWarning, ... macros do not check whether category is enabled - if (isDefaultCategory(context.category)) { + // qDebug, qWarning, ... macros do not check whether category is enabledgc + if (msgType != QtFatalMsg && isDefaultCategory(context.category)) { if (QLoggingCategory *defaultCategory = QLoggingCategory::defaultCategory()) { if (!defaultCategory->isEnabled(msgType)) return; -- cgit v1.2.3 From 5cea83a8a2fc3384bb07a7265c8d907171cb1ea4 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 13 Aug 2019 21:32:44 -0700 Subject: QRandom: retry the use of RDRAND instruction as recommended by manuals MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Intel whitepaper[1] recommends retrying RDRAND some 10 times even after it fails, since the hardware has a fairness algorithm and reseeds itself quite quickly. [1] https://software.intel.com/en-us/articles/intel-digital-random-number-generator-drng-software-implementation-guide Change-Id: I907a43cd9a714da288a2fffd15baafd88242d8b6 Reviewed-by: André Hartmann --- src/corelib/global/qrandom.cpp | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'src/corelib/global') diff --git a/src/corelib/global/qrandom.cpp b/src/corelib/global/qrandom.cpp index bf01b7ae2a..fa26d54afa 100644 --- a/src/corelib/global/qrandom.cpp +++ b/src/corelib/global/qrandom.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2017 Intel Corporation. +** Copyright (C) 2019 Intel Corporation. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtCore module of the Qt Toolkit. @@ -103,17 +103,22 @@ static QT_FUNCTION_TARGET(RDRND) qsizetype qt_random_cpu(void *buffer, qsizetype { unsigned *ptr = reinterpret_cast(buffer); unsigned *end = ptr + count; + int retries = 10; while (ptr + sizeof(qregisteruint)/sizeof(*ptr) <= end) { - if (_rdrandXX_step(reinterpret_cast(ptr)) == 0) + if (_rdrandXX_step(reinterpret_cast(ptr))) + ptr += sizeof(qregisteruint)/sizeof(*ptr); + else if (--retries == 0) goto out; - ptr += sizeof(qregisteruint)/sizeof(*ptr); } - if (sizeof(*ptr) != sizeof(qregisteruint) && ptr != end) { - if (_rdrand32_step(ptr)) - goto out; - ++ptr; + while (sizeof(*ptr) != sizeof(qregisteruint) && ptr != end) { + bool ok = _rdrand32_step(ptr); + if (!ok && --retries) + continue; + if (ok) + ++ptr; + break; } out: -- cgit v1.2.3