delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2018/11/27/04:37:56

X-Recipient: archive-cygwin AT delorie DOT com
DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:date:from:to:subject:message-id:reply-to
:references:mime-version:content-type:in-reply-to; q=dns; s=
default; b=TFd2jhT6BptR+CJBLHEdtDSpsIF84n/DAl5sIawed+oL2I7qbOH+T
dQWuCX4iMeuVmxPCrF6F8UZMG25riRf18SNQi1hhJm0Eqitkf9/8IzQWNQQDsVk8
EF6oej0kXiGqRx/P0K4QnIoOfC8tgBIX1csypY7p2RYXdoFrTzo/+8=
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:date:from:to:subject:message-id:reply-to
:references:mime-version:content-type:in-reply-to; s=default;
bh=Xs1xodoDYUJB9jQN6PXkdmYYRDo=; b=tr52vBzlvMTj1rVsA11Tt6C3WLPr
omCyTtgLZiUxvLyZpFne14EMF7p+nHLYonWCQPCLqHTbDtQuyE2eEggFWa08CH0y
g07Z+shqE2D5KVtbx7Hm1G3fldagfI4g1o8RZDjHh6/CfLoaaq/HyEpmnZbvFatv
0QBlMMLFm9oXYH8=
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Authentication-Results: sourceware.org; auth=none
X-Spam-SWARE-Status: No, score=-100.9 required=5.0 tests=BAYES_00,GOOD_FROM_CORINNA_CYGWIN,KAM_LAZY_DOMAIN_SECURITY,NORMAL_HTTP_TO_IP,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 spammy=houder, Houder, seven, Seven
X-HELO: mout.kundenserver.de
Date: Tue, 27 Nov 2018 10:37:38 +0100
From: Corinna Vinschen <corinna-cygwin AT cygwin DOT com>
To: cygwin AT cygwin DOT com
Subject: Re: No thread safety in clock_gettime (hires_ns::prime)
Message-ID: <20181127093738.GA3928@calimero.vinschen.de>
Reply-To: cygwin AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
References: <CAOWZHxdJi1E9APtSXm35LkDU33VqGZSwnGtvOfdHA9PTTJgRjQ AT mail DOT gmail DOT com> <20181126170140 DOT GO30649 AT calimero DOT vinschen DOT de> <093958e15892f03eecfe6eea1ce6566f AT smtp-cloud7 DOT xs4all DOT net>
MIME-Version: 1.0
In-Reply-To: <093958e15892f03eecfe6eea1ce6566f@smtp-cloud7.xs4all.net>
User-Agent: Mutt/1.9.2 (2017-12-15)

--UlVJffcvxoiEqYs2
Content-Type: text/plain; charset=utf-8
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Nov 26 19:07, Houder wrote:
> On Mon, 26 Nov 2018 18:01:40, Corinna Vinschen  wrote:
> >=20
> > On Nov 23 11:27, James E. King III wrote:
> [snip]
>=20
> > > I found that a call to
> > > clock_gettime(CLOCK_MONOTONIC, ..) has a one-time initialization that
> > > is not thread-safe.  If two threads call this at the same time, they
> > > will race.  The results I am seeing are typically that one of the two
> > > callers get a timespec structure with zero values, and no error return
> > > code from the call.
> >=20
> > Thanks for the testcase, but I can't reproduce the problem, neither on
> > 32 bit nor on 64 bit.  I tweaked your makefile to have a 100K loop I
> > started multiple times with differently optimzed code, but to no avail.
> >=20
> > To account for that, I inspected the code doing the initialization and
> > found that it uses REALTIME priority when trying to make sure multiple
> > threads don't collide.  This is a bit on the dangerous side, apparently.
> >=20
> > I tweaked the code to use a spinlock instead.
> >=20
> > I'm just about to upload new developer snapshots to
> > https://cygwin.com/snapshots/
> >=20
> > Should be up in 10 mins or so.  Can you please try if this fixes the
> > problem for you?
>=20
>  - only replaced the cygwin1.dll ...
>=20
> Henri
>=20
> 64-@@ uname -a
> CYGWIN_NT-6.1 Seven 2.11.3(0.329/5/3)  x86_64 Cygwin
> 64-@@ ls -l /bin/cygwin1*
> -rwxr-xr-x 1 Henri None 3339661 Nov  8 14:36 /bin/cygwin1-2.11.2.X
> -rwxr-xr-x 1 Henri None 3337995 Nov 26 18:43 /bin/cygwin1-64-20181126.X
> -rwxr-xr-x 1 Henri None 3337995 Nov 26 18:43 /bin/cygwin1.dll
> 64-@@ cd threads
> 64-@@ make test
> 64-@@ make test
> 64-@@ make test
> 64-@@ make test
> 64-@@ make test
> 64-@@ make test
> 64-@@ make test
> 64-@@ make test
> 64-@@ vi Makefile
> 64-@@ for loop in {1..100}; do ./cyg_hires_clock_race.exe; done
> 64-@@ for loop in {1..100}; do ./cyg_hires_clock_race.exe; done
> 64-@@ for loop in {1..100}; do ./cyg_hires_clock_race.exe; done
> 64-@@ for loop in {1..100}; do ./cyg_hires_clock_race.exe; done
> 64-@@ for loop in {1..100}; do ./cyg_hires_clock_race.exe; done
> 64-@@ for loop in {1..100}; do ./cyg_hires_clock_race.exe; done
> 64-@@ for loop in {1..100}; do ./cyg_hires_clock_race.exe; done
> 64-@@ for loop in {1..100}; do ./cyg_hires_clock_race.exe; done
> 64-@@ for loop in {1..100}; do ./cyg_hires_clock_race.exe; done
> 64-@@ for loop in {1..100}; do ./cyg_hires_clock_race.exe; done
> 64-@@ for loop in {1..100}; do ./cyg_hires_clock_race.exe; done
> 64-@@ for loop in {1..100}; do ./cyg_hires_clock_race.exe; done
> 64-@@ for loop in {1..100}; do ./cyg_hires_clock_race.exe; done
> 64-@@ #... wait a while ...
> 64-@@ for loop in {1..100}; do ./cyg_hires_clock_race.exe; done
> 64-@@ for loop in {1..1000}; do ./cyg_hires_clock_race.exe; done
> 64-@@ for loop in {1..1000}; do ./cyg_hires_clock_race.exe; done
> 64-@@ for loop in {1..1000}; do ./cyg_hires_clock_race.exe; done
> 64-@@ for loop in {1..10000}; do ./cyg_hires_clock_race.exe; done
> 64-@@# That is enough!

Thanks a lot for testing!  (Particulary since I couldn't even
reproduce this on W7)


Corinna

--=20
Corinna Vinschen
Cygwin Maintainer

--UlVJffcvxoiEqYs2
Content-Type: application/pgp-signature; name="signature.asc"

-----BEGIN PGP SIGNATURE-----

iQIzBAEBCAAdFiEEoVYPmneWZnwT6kwF9TYGna5ET6AFAlv9EGIACgkQ9TYGna5E
T6A+XRAAl8jboNtNoGmGAso16T+Bz8gK9RH5+1aAPXGSaBgjXorm2Ku/WyLNXYJc
kGvmWn1us3cBGv7t25X0nz9gNFT2Kk226sRwG2Prk1f8TWQboJxYo/XCKldpZV/e
8hY5WYrCnTcSboCrkkDXl8heqAjc4ofSD7T2ugBINKZOF2agdOcU277B2VJ31WTA
pakW8NWH8HYTImVrXe7G0Kyx0DJJtuX5McZAr8oNPq5KPZpms8qTYBqdHzCZl5/p
qT5IdjKCuJp8mVObFvrPOFNOxJIUTUF/YI9i26Wk8ARzq6PzXNHWyewF6doS5qrU
pR1npza0Uv8F+J0cDUw6WLARyS72My5RZ5xe2262JeQLynJR3rszS750fkqzgPLW
1VF+6eKPTXiQwUWwTniBUHKSlO5kqxcsaqH//b9UmDBAaDbqFrmMi4ifbsixc1J1
2E0Sw6QxNirgkrRU0XmrkefOmXSMlBy0eYy5AKf51uu/jXgEwizom+S0ErqFYjeh
iH9dQswiDCvwOyHzE9mvn/SlnDuq29rNVjwGtSER4NWGmaILH46tt2WuzNL/Xpo9
yobz3//22fZoL0KzWnevKMdVP7pVQHuCNt8VpMbIc1UuwazT0pAhuCAUzrxabXYR
VjlDuQlgImWwDWXndNLZhZGQ6hxfAkb7eC+Hj3iLTZyQdZmJZfA=
=MZCf
-----END PGP SIGNATURE-----

--UlVJffcvxoiEqYs2--

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019