[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
random: Fix multithread-safety bug in general
|
From: |
Bruno Haible |
|
Subject: |
random: Fix multithread-safety bug in general |
|
Date: |
Fri, 10 Nov 2023 16:59:46 +0100 |
Since CheriBSD is derived from FreeBSD, it sounds likely that FreeBSD's random()
function is equally not multithread-safe.
To verify this hypothesis, I wrote a MT-safety test for random(). The result
(with a REPEAT_COUNT of 1000000):
glibc OK
musl libc OK
FreeBSD 11.0 Expected value #932913 not found in multithreaded results. (18
failures among 100 runs)
FreeBSD 13.2 Expected value #712890 not found in multithreaded results. (2
failures among 100 runs)
NetBSD OK
OpenBSD Expected value #0 not found in multithreaded results. => SKIP
macOS Expected value #16 not found in multithreaded results.
AIX OK
Solaris10 Expected value #4 not found in multithreaded results.
Solaris11 Expected value #46 not found in multithreaded results.
Cygwin 2.9.0 Expected value #2499 not found in multithreaded results.
Cygwin 3.4.6 Expected value #367 not found in multithreaded results.
mingw OK (uses gnulib implementation)
MSVC OK (uses gnulib implementation)
Haiku Expected value #188587 not found in multithreaded results. (1
failure among 100 runs)
Minix SKIP
Android OK
So, in general, it requires 100'000'000 repetitions to determine
whether the function is MT-safe. But that's too long for a unit test.
I'm therefore reducing it to 100'000 repetitions and hardcoding the
known platforms in the configure test. Even these 100'000 repetitions
take 3 seconds on Haiku or 1 second on mingw or MSVC.
2023-11-10 Bruno Haible <bruno@clisp.org>
doc: Mention an srandom limitation on OpenBSD.
* doc/posix-functions/srandom.texi: Mention the OpenBSD limitation.
2023-11-10 Bruno Haible <bruno@clisp.org>
random tests: Add multithread-safety test.
* tests/test-random-mt.c: New file.
* modules/random-tests (Files): Add it.
(Depends-on): Add xalloc, thread, yield.
(Makefile.am): Also build and test test-random-mt.
random: Fix multithread-safety bug in general.
* m4/random.m4 (gl_FUNC_RANDOM): Override also macOS, FreeBSD, Solaris,
Cygwin, Haiku.
* doc/posix-functions/random.texi: Mention the wider scope of the
multithread-safety bug.
0001-random-Fix-multithread-safety-bug-in-general.patch
Description: Text Data
0002-random-tests-Add-multithread-safety-test.patch
Description: Text Data
0003-doc-Mention-an-srandom-limitation-on-OpenBSD.patch
Description: Text Data
| [Prev in Thread] |
Current Thread |
[Next in Thread] |
- random: Fix multithread-safety bug in general,
Bruno Haible <=