From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2155) id 0FAC2385841E; Mon, 13 Nov 2023 19:07:46 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0FAC2385841E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com; s=default; t=1699902466; bh=zhy5NbVJNGzr3xrmEJafi17VBQOzb6ayXpR50e36YXQ=; h=Date:From:To:Cc:Subject:Reply-To:References:In-Reply-To:From; b=Q5wO0fN6T3QcszvkYOvyrXr/S8Gsga16tTomvOL/3InY+4QeZGA8zSA9gLOnvj5oC rFBDkPu7aOkdle858ZJJijmWWjcieJflsR6aJkMEWlr8PNce98DvRATQwIFNFz5+br qDup4tNtxFyJRm5ztwEzifVvWBScyVy0jQNpPep4= Received: by calimero.vinschen.de (Postfix, from userid 500) id 52758A80A3D; Mon, 13 Nov 2023 20:07:44 +0100 (CET) Date: Mon, 13 Nov 2023 20:07:44 +0100 From: Corinna Vinschen To: Bruno Haible Cc: cygwin@cygwin.com Subject: Re: random is not multithread-safe in Cygwin Message-ID: Reply-To: cygwin@cygwin.com Mail-Followup-To: Bruno Haible , cygwin@cygwin.com References: <3811044.57xzQst1vy@nimes> <10013068.gMo3ACIZaO@nimes> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <10013068.gMo3ACIZaO@nimes> List-Id: On Nov 13 19:04, Bruno Haible via Cygwin wrote: > Corinna Vinschen wrote: > > > And indeed glibc, musl libc, AIX, Android, and even NetBSD implement it in a > > > multithread-safe way. > > > > Our code is from FreeBSD, originally. I checked the latest code from > > FreeBSD. It doesn't lock anything in random() and generates the same > > error when running the same test app. > > > > Why is that ok for FreeBSD? > > It is not OK in FreeBSD, either. This is what I noted in the Gnulib manual: > https://git.savannah.gnu.org/gitweb/?p=gnulib.git;a=blob;f=doc/posix-functions/random.texi > > But it is MT-safe in NetBSD (in the '#ifndef SMALL_RANDOM' branch): > http://cvsweb.netbsd.org/bsdweb.cgi/src/common/lib/libc/stdlib/random.c?rev=1.7&content-type=text/x-cvsweb-markup Ok, I pushed a patch(*) to make the random(3) functions thread-safe, more or less following NetBSDs lead. If you get a chance, give the next test release cygwin-3.5.0-0.459.gd223f095905a a try. The patch will be part of the next release, 3.4.10. Thanks, Corinna (*) https://sourceware.org/git/?p=newlib-cygwin.git;a=commit;h=06e463223b95