]> Savannah Git Hosting - gnulib.git/commitdiff
random: Fix multithread-safety bug in general.
authorBruno Haible <bruno@clisp.org>
Fri, 10 Nov 2023 15:46:17 +0000 (16:46 +0100)
committerBruno Haible <bruno@clisp.org>
Fri, 10 Nov 2023 15:46:17 +0000 (16:46 +0100)
* 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.

ChangeLog
doc/posix-functions/random.texi
m4/random.m4

index 5c92da54ec27a092cbe7e05cb37657931b8f4c46..d38e5b56659cb6aef1c459fdb33a58db746565eb 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2023-11-10  Bruno Haible  <bruno@clisp.org>
+
+       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.
+
 2023-11-09  Bruno Haible  <bruno@clisp.org>
 
        sigsegv: Improve port to CHERI.
index e0bb8e76bca94c42bd0473983e225442096cda2a..84cacbe8b5e41c4f6edf0f00500078a286b5a6ba 100644 (file)
@@ -15,8 +15,8 @@ mingw, MSVC 14.
 This function is only defined as an inline function on some platforms:
 Android 4.4.
 @item
-This function crashes when used in multithreaded programs on some platforms:
-CheriBSD.
+This function is not multithread-safe on some platforms:
+macOS 12.5, FreeBSD 13.2, Solaris 11.4, Cygwin 3.4.6, Haiku.
 @end itemize
 
 Portability problems not fixed by Gnulib:
index 69bac2459ae27a2d715d40ffc5b2b5659d80b0dc..4e4f01b8ed659fb25c4bfaee44a757eeb6564cd3 100644 (file)
@@ -1,4 +1,4 @@
-# random.m4 serial 7
+# random.m4 serial 8
 dnl Copyright (C) 2012-2023 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -44,10 +44,13 @@ AC_DEFUN([gl_FUNC_RANDOM],
       future*) REPLACE_SETSTATE=1 ;;
     esac
   fi
-  dnl On CheriBSD, random() lacks locking, leading to an out-of-bounds read
-  dnl inside random_r.
+  dnl On several platforms, random() is not multithread-safe.
   if test $ac_cv_func_initstate = no || test $ac_cv_func_setstate = no \
-     || case "$host" in aarch64c-*-freebsd*) true;; *) false;; esac; then
+     || case "$host_os" in \
+          darwin* | freebsd* | solaris* | cygwin* | haiku*) true ;; \
+          *) false ;; \
+        esac
+  then
     dnl In order to define initstate or setstate, we need to define all the
     dnl functions at once.
     REPLACE_RANDOM=1