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=w5sSQW7LbeDU9uLpbijpjlWzXf3wX6t7riHxwuNbBQ+w96At6Nzuo GhwEO9sgvqc/KkJ1fmhGVAHXLrsRcUUvYnmWMC0vLJlYn54hwNhtHBqYzCaZQ2L0 QLOUXp/eiJe0EgxQ/hPUn587aVyft13daiwojnyEz17lh9CiC2B5Rw= 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=XbZhphYDNgzGP5FahZFI2jBdRA8=; b=T5AL9fDFtEGFwG/NJ7yfD9IpuG5P R4fFAnmrT08ilkrST9EItqMNcfIYEKhoLg8vWDPDr7ls2i4WF7CszvkM+nQ3GW6t BZGO2DdyF2kUaucv2wTyDw23lkW6kicfjX4WfExVmNp80SZkGl1t22Q8wRwOJSqY DJ3VXklDsqXI/c8= Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , 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,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 spammy=mins, 100k, race X-HELO: mout.kundenserver.de Date: Mon, 26 Nov 2018 18:01:40 +0100 From: Corinna Vinschen To: cygwin AT cygwin DOT com Subject: Re: No thread safety in clock_gettime (hires_ns::prime) Message-ID: <20181126170140.GO30649@calimero.vinschen.de> Reply-To: cygwin AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com References: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="IuhbYIxU28t+Kd57" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.2 (2017-12-15) --IuhbYIxU28t+Kd57 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Nov 23 11:27, James E. King III wrote: > Using 32-bit cygwin that I set up yesterday. Don't do that. Use 64 bit Cygwin whenever possible. 32 bit is a lost cause. > 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. 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. 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. I tweaked the code to use a spinlock instead. I'm just about to upload new developer snapshots to https://cygwin.com/snapshots/ Should be up in 10 mins or so. Can you please try if this fixes the problem for you? Thanks, Corinna --=20 Corinna Vinschen Cygwin Maintainer --IuhbYIxU28t+Kd57 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEoVYPmneWZnwT6kwF9TYGna5ET6AFAlv8JvQACgkQ9TYGna5E T6AfAw//ZnLUoz042YhK0hnbSV7mXqoJRxk6qs5gjhzQoGLwJP444qYRLhf0LZtl xklCmTjsXKrhUA78KubhaDvHs2ipLWZmj5hhMowU41EGBk4n7BzcJ7r8BROaMm+4 eGHkDQI5E4tDm0NexTmOgKPD0PzKaVaGcat1vEB6JPjXCXBDC9czZt1PiD6Hm5DN lpZPh8ulf8jBbH7qmLNWZbomBAaXIPMGW+h2f0v5e/evWGl6lC1SyOjUk7lFeJGE 9I40bvk/dyNWK9uPTmv6cQ05iNUaW7jVf2WPSTdzN3e+KnBy6EZoCbSEI/aof6Yh fgeqkbb/dH+QJzB9nF4QbgxMe/TcH9f4/BtvLT2OZkbw+qO8GhKybr4rSGNl0E38 tQYsdQ0DdczhTyMEDN+CNKszPzkPtdXQqkuUAJBoe3J6jIpc/IUdCCqpdKAwR8la pJcYBe5Fnu1SRq/iPFcrMCy54Hujl9SKy57nkE0eK6u1eMEt/xOOoT/vC+AIb3zc Op2zhC2WoMuoc9ZvMTZKAWH1IpLuItawjl8H1WhkFU93z2kf9zZ7NnAIkdtqW6Qb EAAtjRER10u2JIEkQrxhNV4Opm1lreevh3UVK11wRXy6tRsOWuyYZQIWGdtd1cOS ZemHqRxZDP4GGqa1biUyRo6lhH2ifcP3N9POFCESxADjdu9MR+w= =JM/G -----END PGP SIGNATURE----- --IuhbYIxU28t+Kd57--