diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2021-04-02 01:18:32 -0700 |
---|---|---|
committer | Thiago Macieira <thiago.macieira@intel.com> | 2021-05-23 12:08:43 -0700 |
commit | 928ce402a41c291e6f746cac903a4a44702c4689 (patch) | |
tree | 69a91d922965d59e577897af602b9d73ff6a0bf3 /src/corelib/global/qrandom_p.h | |
parent | 4ef99b8fbb3ba32df5591ac306fe8a7baa31c92c (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_p.h')
-rw-r--r-- | src/corelib/global/qrandom_p.h | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/src/corelib/global/qrandom_p.h b/src/corelib/global/qrandom_p.h index 7e228b3fde..9c90967df8 100644 --- a/src/corelib/global/qrandom_p.h +++ b/src/corelib/global/qrandom_p.h @@ -80,6 +80,8 @@ static const struct } qt_randomdevice_control; #endif +quintptr qt_initial_random_value() noexcept; + QT_END_NAMESPACE #endif // QRANDOM_P_H |