delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2024/05/29/06:27:05

DKIM-Filter: OpenDKIM Filter v2.11.0 delorie.com 44TAR4ZX1612589
Authentication-Results: delorie.com;
dkim=pass (1024-bit key, unprotected) header.d=cygwin.com header.i=@cygwin.com header.a=rsa-sha256 header.s=default header.b=R/j9td0T
X-Recipient: archive-cygwin AT delorie DOT com
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 101C4385ED69
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com;
s=default; t=1716978424;
bh=UlvXbSkEHMbdmg7X/c1EREE8kxxBzdpi0cPvWnNXDtM=;
h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe:
List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:
From;
b=R/j9td0TLGPERymyEepOEMFED5hJmkz4pBNR1+UwHWus8XjDB3yPQ+DwP1zW/DsnD
bC+0pNKtdcG/jE8iXp4Q/NMQhP2jPXwxWJ/zZZITEqH3/Rmsam6uf2xqVXpDwU/Cu+
xO2C3flrH/FDqMe52IUB0g4nLGFkndFa43uAV2wM=
X-Original-To: cygwin AT cygwin DOT com
Delivered-To: cygwin AT cygwin DOT com
DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 08BCD385840F
ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 08BCD385840F
ARC-Seal: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1716978402; cv=pass;
b=hkfQVDsDZASOMMqS/SHe5KcgRcAIf1/lPCgbOhk/xLlCE5vwJZCHTszAtWCgyfKFblPMx9pAsqzNbOVdSP3C+U3O9f5DrgnEGN601NMZZ4GvQ6T1kpRpDIYTHWaeiFPRCL0KgZq8a61+8poHaftqgTNqYgTKnEa4Qw0xk8YmWo8=
ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key;
t=1716978402; c=relaxed/simple;
bh=JVNTbmLPw8Z1yQbhzNIvWJskCC2Vvd28bEb4q3a3ExI=;
h=DKIM-Signature:DKIM-Signature:From:To:Subject:Date:Message-ID:
MIME-Version;
b=XNXRvCgWYoouWL/4fZw0HvePCtKmb6KE/Z8YA7+mFE+X2UHfOtl7FQ+fHadGqnK/Ej1huWbm4ZjOO1SwLo9xVjXbwq90GqJD1zqIJYWp7w/f8y7cJ5cfhOhnbpqM7Q2on4M/PG02fkCIaOvGQOMmZKG3dm80rj6CsuMuqldFH68=
ARC-Authentication-Results: i=2; server2.sourceware.org
ARC-Seal: i=1; a=rsa-sha256; t=1716978392; cv=none;
d=strato.com; s=strato-dkim-0002;
b=d67dHIvq2TFGxSHxFylIXXkf0kVDHrk2c0YxHNxBRlSwS3y8FChLsd8f0hNaEfg5N+
8LQndIQeegwPJXfHVwLOyqOOol+M8uoUGYZLQvQGn+VKKcI1lzzaDDWseYuWfZiSb16h
oZ6vBq4T1huhJYABr6qTNXkYFbs1YClMLqjvLipDRKw6jncB8hHuGq0f5rbKxjoiW3zz
WixVJgunxSx3wtn8XA/irYtzP7/QxSoJToN5l4dGIwN5Sej6jBYnLIFY1ECAUPscNPFF
kB4X+jyWWr3MQvdk6j4vDtqHO9RUVn6lagChgrJ41Luel5OLsLK2k5lyswO3OMgFywvh
ssgQ==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; t=1716978392;
s=strato-dkim-0002; d=strato.com;
h=References:In-Reply-To:Message-ID:Date:Subject:To:From:Cc:Date:From:
Subject:Sender;
bh=8maGF8ZqjjeGwEGpNVeHNsH/J8IZB7gjUIQgPdFuGYw=;
b=kHUl5z6h0R94nRjzp1jZjKiaeOHMkiqgnzNS4kyjnRBvHGVF1tjm+N3jsGR/Eqlppe
zfBk8iwULhI3GVu9SsBB9Hxkk+zxsfybyHRxNooAYsFKtL1h1jW013+EGYQrvMosRbf9
F7BGcRiwC3aV3pmrqqxvW7/L3fFEjKVQgLgm4xHuhVeItAcCf6trRbMiceE3RxfVMjeZ
djZWLjj5A7Jt4bdA/H0TPdhMZVavTBIrHRj9cdez+cQwW0wKgXeMibQmRUJcF9ATsaqN
xiYK51w5YbLxe58QqHjKytAoNE1vzhrE7qBBrWZig1vhtBhj1w68jYtm/T2D6qi3J8UD
74Og==
ARC-Authentication-Results: i=1; strato.com;
arc=none;
dkim=none
X-RZG-CLASS-ID: mo00
X-RZG-AUTH: ":Ln4Re0+Ic/6oZXR1YgKryK8brlshOcZlIWs+iCP5vnk6shH0WWb0LN8XZoH94zq68+3cfpPAiqFt2JhGvFnRN6BsfqrAeOb8"
To: cygwin AT cygwin DOT com, Takashi Yano <takashi DOT yano AT nifty DOT ne DOT jp>
Subject: Re: multithreading broken in Cygwin 3.5.3
Date: Wed, 29 May 2024 12:26:31 +0200
Message-ID: <4580924.dSzdyWo4uF@nimes>
In-Reply-To: <20240529190619.53c5820ecafcf31909c4320c@nifty.ne.jp>
References: <3631253 DOT RrQHTzY0li AT nimes>
<20240529190619 DOT 53c5820ecafcf31909c4320c AT nifty DOT ne DOT jp>
MIME-Version: 1.0
X-Spam-Status: No, score=-3.2 required=5.0 tests=BAYES_00, DKIM_SIGNED,
DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, KAM_NUMSUBJECT, RCVD_IN_DNSWL_NONE,
RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS, SPF_NONE, TXREP,
T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6
X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on
server2.sourceware.org
X-BeenThere: cygwin AT cygwin DOT com
X-Mailman-Version: 2.1.30
List-Id: General Cygwin discussions and problem reports <cygwin.cygwin.com>
List-Unsubscribe: <https://cygwin.com/mailman/options/cygwin>,
<mailto:cygwin-request AT cygwin DOT com?subject=unsubscribe>
List-Archive: <https://cygwin.com/pipermail/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-request AT cygwin DOT com?subject=help>
List-Subscribe: <https://cygwin.com/mailman/listinfo/cygwin>,
<mailto:cygwin-request AT cygwin DOT com?subject=subscribe>
From: Bruno Haible via Cygwin <cygwin AT cygwin DOT com>
Reply-To: Bruno Haible <bruno AT clisp DOT org>
Errors-To: cygwin-bounces+archive-cygwin=delorie DOT com AT cygwin DOT com
Sender: "Cygwin" <cygwin-bounces+archive-cygwin=delorie DOT com AT cygwin DOT com>

Takashi Yano wrote:
> As you mentioned in private mail to me, this seems to be a regression of
> pthread::once() introduced by
> commit 2c5433e5da8216aaf7458e50c63683c68fb0d3e8.
> 
> I'll submit a patch for that issue shortly.

My workaround implementation of pthread_once (in gnulib) looks like this:

  /* This would be the code, for
       typedef struct
         {
           pthread_mutex_t mutex;
           _Atomic unsigned int num_threads;
           _Atomic unsigned int done;
         }
       pthread_once_t;
   */
  if (once_control->done == 0)
    {
      once_control->num_threads += 1;
      pthread_mutex_lock (&once_control->mutex);
      if (once_control->done == 0)
        {
          (*initfunction) ();
          once_control->done = 1;
        }
      pthread_mutex_unlock (&once_control->mutex);
      if ((once_control->num_threads -= 1) == 0)
        pthread_mutex_destroy (&once_control->mutex);
    }

It makes sure that
  - The last thread that had been dealing with the mutex deletes
    the mutex.
  - Once the mutex is deleted, is it never again accessed. The
    entry test of the 'done' boolean ensures this.

Bruno




-- 
Problem reports:      https://cygwin.com/problems.html
FAQ:                  https://cygwin.com/faq/
Documentation:        https://cygwin.com/docs.html
Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple

- Raw text -


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