summaryrefslogtreecommitdiffstats
path: root/src/corelib/global/qrandom.h
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2021-04-02 01:18:32 -0700
committerThiago Macieira <thiago.macieira@intel.com>2021-05-23 12:08:43 -0700
commit928ce402a41c291e6f746cac903a4a44702c4689 (patch)
tree69a91d922965d59e577897af602b9d73ff6a0bf3 /src/corelib/global/qrandom.h
parent4ef99b8fbb3ba32df5591ac306fe8a7baa31c92c (diff)
QHash & QRandomGenerator: cooperate to provide a simpler initial seed
Instead of initializing the whole QRandomGenerator::system(), which in turn gets to checking CPUID and whether the HWRNG works, trust the operating system functions for an initial value. On Linux, we'll use 4 or 8 of the 16 bytes of random data that the kernel populates for us on AT_RANDOM. This should make Qt applications not stall on an early system launch without an RNG daemon, if compiled without getentropy() support. And avoids silly mistakes causing recursion, like QTBUG-78007 found. Additionally, qt_random_initial_value() will most likely not throw either. It's marked noexcept, even though SystemGenerator::fillBuffer could throw on Linux, if the current thread is canceled, but Linux also has AT_RANDOM. That leaves the other Unix systems without getentropy() (read: macOS, since the BSDs have getentropy()). Fixes: QTBUG-69555 Change-Id: Id2983978ad544ff79911fffd1671fca1a9f9044d Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/corelib/global/qrandom.h')
-rw-r--r--src/corelib/global/qrandom.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/corelib/global/qrandom.h b/src/corelib/global/qrandom.h
index d6b8bd742e..c59ae4d42d 100644
--- a/src/corelib/global/qrandom.h
+++ b/src/corelib/global/qrandom.h
@@ -217,6 +217,7 @@ protected:
private:
Q_CORE_EXPORT quint64 _fillRange(void *buffer, qptrdiff count);
+ friend quintptr qt_initial_random_value() noexcept;
friend class QRandomGenerator64;
struct SystemGenerator;
struct SystemAndGlobalGenerators;