Dear Maintainer, Current version of qqwing uses srand(time(0)) and rand() as a way to generate the board. It makes running multiple instances of the program in parallel for faster sudoku generation impossible, because all are started in the same second, generating exactly the same sequence of numbers, and as a result, sequence of boards. The solution is to replace the randomness based on time with one based on a truly random seed, and rand() with a random generator that does not rely on a global state like srand. My patch makes use of several C++11 features such as std::random_device, std::uniform_int_distribution and std::shuffle that are state of the art solutions to the aforementioned issue.
Hi Jackson,
as per ITS bug I have uploaded qqwing to delayed=10.
Kind regards
Andreas.
We believe that the bug you reported is fixed in the latest version of
qqwing, which is due to be installed in the Debian FTP archive.
A summary of the changes between this version and the previous one is
attached.
Thank you for reporting the bug, which will now be closed. If you
have further comments please address them to 1013230@bugs.debian.org,
and the maintainer will reopen the bug report if appropriate.
Debian distribution maintenance software
pp.
Andreas Tille <tille@debian.org> (supplier of updated qqwing package)
(This message was generated automatically at their request; if you
believe that there is a problem with it please contact the archive
administrators by mailing ftpmaster@ftp-master.debian.org)
Format: 1.8
Date: Thu, 24 Oct 2024 13:59:09 +0200
Source: qqwing
Architecture: source
Version: 1.3.4-2
Distribution: unstable
Urgency: medium
Maintainer: Debian Games Team <pkg-games-devel@lists.alioth.debian.org>
Changed-By: Andreas Tille <tille@debian.org>
Closes: 1013230 1013892 1015611 1083130
Changes:
qqwing (1.3.4-2) unstable; urgency=medium
.
[ Andreas Tille ]
* Team upload.
Closes: #1083130
* Maintain package in Debian Games team
* Standards-Version: 4.7.0 (routine-update)
* debhelper-compat 13 (routine-update)
* Secure URI in copyright format (routine-update)
* Rules-Requires-Root: no (routine-update)
* Use secure URI in Homepage field.
* watch file standard 4 (routine-update)
* Secure URI in watch file
* Drop symbols file. The library is rarely used by other packages and
potentially causes trouble when built with new gcc versions.
Closes: #1015611
* Adapt dh_missing to debhelper compat level 13
.
[ Krzysztof Aleksander Pyrkosz ]
* Improved random number generation to allow running multiple instances of
the program in parallel
Closes: #1013230
* Do not get stuck in an infinite loop on ARM
Closes: #1013892
Checksums-Sha1:
3a92e82fa835ee24d1a3e1c8bbec3de15fe966c1 2004 qqwing_1.3.4-2.dsc
4e241d6fb994b58ee7a758381608c2b1457a0434 3912 qqwing_1.3.4-2.debian.tar.xz
3a79db1592d165eb2abdb617ad26d3b4b3dadb6a 6848 qqwing_1.3.4-2_amd64.buildinfo
Checksums-Sha256:
7b52dc21a59809a70d305c689f074629168dcbe047f87ecc04bd3c3b4aa779a8 2004 qqwing_1.3.4-2.dsc
4674c416f92e6b9bf83e5ecbc46e528d1826f5c699e056ca325b442b407a3c1b 3912 qqwing_1.3.4-2.debian.tar.xz
90b988d55da52f1913f1b2277116545c39c336d9acaceff2655abb717c34ffce 6848 qqwing_1.3.4-2_amd64.buildinfo
Files:
443013f871d055b867daa48803a8e6f1 2004 misc optional qqwing_1.3.4-2.dsc
20322a4b2c03482280ba8f81a9910737 3912 misc optional qqwing_1.3.4-2.debian.tar.xz
7b7ac883df6c098372486388f2dc2bae 6848 misc optional qqwing_1.3.4-2_amd64.buildinfo
-----BEGIN PGP SIGNATURE-----
iQJFBAEBCgAvFiEE8fAHMgoDVUHwpmPKV4oElNHGRtEFAmcaN+IRHHRpbGxlQGRl
Ymlhbi5vcmcACgkQV4oElNHGRtEZ6w/+MiHz1mV3HWp1Fkxqui8deUW/pEKjtOIx
/R8fLwCcJNdYpafWQC/hE0YVq5r7cfZy/K+NUsHJFC0QAZ6vnJ546z8ym4VS5jLF
hsHu80pYmhyttXnRCfeWcISsAooWXfdI5Vp5eGrjpF8C32PDmXPBDbqXfSndySJ/
pn+yF14YU43H3GfglS88beUV5JyruNJNNkZudAT4OiNYZze12q55fOr6iDE9chiD
7QwtrGvCGaJzLptUzLuf7m7pcq2hbaAJTwJ6m/9EL/loRvkmJvzgJ0zcRa9Y1pHv
+wM8iZ+meFcDaPPo1GJW3Dkum3IKjJjMLTsJA2UoDIVSA3OWSQyybHEwBeRDOj3s
RUYPFwWW2JI5RkULoGidoayPUYxZYPuTE6fQxM1us0XVRAE95eirtFiA0Q6krmIt
31HAbyt0yp4mB67ncQRRQArNVot7LbsN6ECcLj1hroWfUBnrucJUp1fl2bTzcX5S
YaIdEs5q2yrlr/wRwFFK0p3YfdwkkMLnlYSTx0wR4k9MnlMlHEgxYWCh2IwsZa5Y
W3hcVKb7Ht2qr0ICRn/VOfk7gl2u0IdxUfjrcSt2t2ooSUWV/PKs6VzXdijG6JeD
gGUPN5Bhgvbfkjx+iXXDznbBDgojWwXBTvAYf/OEVaN8yOr6dNayRa0Wi8rpNWbk
vzN8C+CqevM=
=wbRb
-----END PGP SIGNATURE-----
Control: retitle -1 qqwing: generates same boards if multiple instances are run during the same second
Control: severity -1 normal
Control: tags -1 + upstream
Unfortunately this patch resulted in an ABI break which crashed
gnome-sudoku, so it had to be reverted. If you are interested in improving
(lib)qqwing's random number generation, I would recommend doing that
upstream rather than as a Debian-specific change.
One simple way to avoid the symptom that you originally reported would be
to continue using the global random number generator rand(), but change the
seed passed to srand() to one that is unique to a particular run, perhaps
taken from from getentropy(), or perhaps taking into account factors like
getpid() or applicationStartTime (which is in microseconds, so is much less
likely to be the same for two runs).
Or the std::mt19937 object could perhaps be global or thread-local,
depending what the thread-safety requirements of libqqwing are (I don't
know what those requirements are, and I'd suggest consulting upstream to
find out).
Or if it's absolutely necessary to break the ABI by making the data
structure larger, then that should be done in coordination with upstream
and accompanied by a SONAME bump, so that dependent programs will not crash
(they will use and require the old version until they're recompiled, after
which they'll use and require the new version).
Thanks,
smcv