Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

"Jesus saves...but Gretzky gets the rebound!" -- Daniel Hinojosa (hinojosa@hp-sdd)


devel / comp.lang.c++ / Re: Thread-safe initialization of static objects

SubjectAuthor
* Thread-safe initialization of static objectsBonita Montero
+* Re: Thread-safe initialization of static objectsPavel
|+* Re: Thread-safe initialization of static objectsBonita Montero
||+* Re: Thread-safe initialization of static objectsPavel
|||`* Re: Thread-safe initialization of static objectsBonita Montero
||| `* Re: Thread-safe initialization of static objectsPavel
|||  `* Re: Thread-safe initialization of static objectsBonita Montero
|||   +* Re: Thread-safe initialization of static objectsScott Lurndal
|||   |+* Re: Thread-safe initialization of static objectsRichard Damon
|||   ||`* Re: Thread-safe initialization of static objectsChris M. Thomasson
|||   || `* Re: Thread-safe initialization of static objectsRichard Damon
|||   ||  `* Re: Thread-safe initialization of static objectsChris M. Thomasson
|||   ||   +* Re: Thread-safe initialization of static objectsRichard Damon
|||   ||   |`- Re: Thread-safe initialization of static objectsChris M. Thomasson
|||   ||   `* Re: Thread-safe initialization of static objectsScott Lurndal
|||   ||    `- Re: Thread-safe initialization of static objectsChris M. Thomasson
|||   |`- Re: Thread-safe initialization of static objectsBonita Montero
|||   +* Re: Thread-safe initialization of static objectsPavel
|||   |`* Re: Thread-safe initialization of static objectsBonita Montero
|||   | +* Re: Thread-safe initialization of static objectsPavel
|||   | |`* Re: Thread-safe initialization of static objectsBonita Montero
|||   | | +* Re: Thread-safe initialization of static objectsPaavo Helde
|||   | | |`* Re: Thread-safe initialization of static objectsBonita Montero
|||   | | | +* Re: Thread-safe initialization of static objectsPavel
|||   | | | |`* Re: Thread-safe initialization of static objectsBonita Montero
|||   | | | | +* Re: Thread-safe initialization of static objectsRichard Damon
|||   | | | | |`* Re: Thread-safe initialization of static objectsBonita Montero
|||   | | | | | +* Re: Thread-safe initialization of static objectsRichard Damon
|||   | | | | | |+* Re: Thread-safe initialization of static objectsBonita Montero
|||   | | | | | ||+* Re: Thread-safe initialization of static objectsPaavo Helde
|||   | | | | | |||+* Re: Thread-safe initialization of static objectsBonita Montero
|||   | | | | | ||||+- Re: Thread-safe initialization of static objectsChris M. Thomasson
|||   | | | | | ||||`* Re: Thread-safe initialization of static objectsPaavo Helde
|||   | | | | | |||| +* Re: Thread-safe initialization of static objectsBonita Montero
|||   | | | | | |||| |+- Re: Thread-safe initialization of static objectsRichard Damon
|||   | | | | | |||| |`- Re: Thread-safe initialization of static objectsChris M. Thomasson
|||   | | | | | |||| `* Re: Thread-safe initialization of static objectsBonita Montero
|||   | | | | | ||||  `* Re: Thread-safe initialization of static objectsBonita Montero
|||   | | | | | ||||   `* Re: Thread-safe initialization of static objectsPaavo Helde
|||   | | | | | ||||    +- Re: Thread-safe initialization of static objectsBonita Montero
|||   | | | | | ||||    `- Re: Thread-safe initialization of static objectsBonita Montero
|||   | | | | | |||`* Re: Thread-safe initialization of static objectsMichael S
|||   | | | | | ||| +- Re: Thread-safe initialization of static objectsScott Lurndal
|||   | | | | | ||| `- Re: Thread-safe initialization of static objectsChris M. Thomasson
|||   | | | | | ||`* Re: Thread-safe initialization of static objectsRichard Damon
|||   | | | | | || `- Re: Thread-safe initialization of static objectsChris M. Thomasson
|||   | | | | | |`* Re: Thread-safe initialization of static objectsPavel
|||   | | | | | | `* Re: Thread-safe initialization of static objectsChris M. Thomasson
|||   | | | | | |  `* Re: Thread-safe initialization of static objectsPavel
|||   | | | | | |   `* Re: Thread-safe initialization of static objectsChris M. Thomasson
|||   | | | | | |    `- Re: Thread-safe initialization of static objectsPavel
|||   | | | | | `- Re: Thread-safe initialization of static objectsChris M. Thomasson
|||   | | | | `- Re: Thread-safe initialization of static objectsPavel
|||   | | | `* Re: Thread-safe initialization of static objectsChris M. Thomasson
|||   | | |  `* Re: Thread-safe initialization of static objectsBonita Montero
|||   | | |   +* Re: Thread-safe initialization of static objectsChris M. Thomasson
|||   | | |   |`* Re: Thread-safe initialization of static objectsBonita Montero
|||   | | |   | `* Re: Thread-safe initialization of static objectsChris M. Thomasson
|||   | | |   |  +- Re: Thread-safe initialization of static objectsChris M. Thomasson
|||   | | |   |  `* Re: Thread-safe initialization of static objectsBonita Montero
|||   | | |   |   +- Re: Thread-safe initialization of static objectsChris M. Thomasson
|||   | | |   |   `- Re: Thread-safe initialization of static objectsChris M. Thomasson
|||   | | |   +- Re: Thread-safe initialization of static objectsChris M. Thomasson
|||   | | |   `* Re: Thread-safe initialization of static objectsRichard Damon
|||   | | |    `* Re: Thread-safe initialization of static objectsBonita Montero
|||   | | |     +- Re: Thread-safe initialization of static objectsChris M. Thomasson
|||   | | |     `* Re: Thread-safe initialization of static objectsChris M. Thomasson
|||   | | |      `* Re: Thread-safe initialization of static objectsBonita Montero
|||   | | |       `* Re: Thread-safe initialization of static objectsChris M. Thomasson
|||   | | |        `* Re: Thread-safe initialization of static objectsBonita Montero
|||   | | |         `* Re: Thread-safe initialization of static objectsChris M. Thomasson
|||   | | |          `* Re: Thread-safe initialization of static objectsBonita Montero
|||   | | |           `* Re: Thread-safe initialization of static objectsChris M. Thomasson
|||   | | |            `* Re: Thread-safe initialization of static objectsBonita Montero
|||   | | |             `* Re: Thread-safe initialization of static objectsChris M. Thomasson
|||   | | |              +- Re: Thread-safe initialization of static objectsChris M. Thomasson
|||   | | |              `* Re: Thread-safe initialization of static objectsBonita Montero
|||   | | |               `* Re: Thread-safe initialization of static objectsChris M. Thomasson
|||   | | |                `* Re: Thread-safe initialization of static objectsBonita Montero
|||   | | |                 `* Re: Thread-safe initialization of static objectsScott Lurndal
|||   | | |                  +- Re: Thread-safe initialization of static objectsBonita Montero
|||   | | |                  `* Re: Thread-safe initialization of static objectsChris M. Thomasson
|||   | | |                   `* Re: Thread-safe initialization of static objectsBonita Montero
|||   | | |                    `* Re: Thread-safe initialization of static objectsRichard Damon
|||   | | |                     `* Re: Thread-safe initialization of static objectsBonita Montero
|||   | | |                      `* Re: Thread-safe initialization of static objectsPavel
|||   | | |                       `* Re: Thread-safe initialization of static objectsBonita Montero
|||   | | |                        +* Re: Thread-safe initialization of static objectsChris M. Thomasson
|||   | | |                        |`* Re: Thread-safe initialization of static objectsBonita Montero
|||   | | |                        | `* Re: Thread-safe initialization of static objectsChris M. Thomasson
|||   | | |                        |  `* Re: Thread-safe initialization of static objectsBonita Montero
|||   | | |                        |   +* Re: Thread-safe initialization of static objectsChris M. Thomasson
|||   | | |                        |   |`* Re: Thread-safe initialization of static objectsBonita Montero
|||   | | |                        |   | +* Re: Thread-safe initialization of static objectsChris M. Thomasson
|||   | | |                        |   | |`* Re: Thread-safe initialization of static objectsBonita Montero
|||   | | |                        |   | | `* Re: Thread-safe initialization of static objectsChris M. Thomasson
|||   | | |                        |   | |  `* Re: Thread-safe initialization of static objectsBonita Montero
|||   | | |                        |   | |   `* Re: Thread-safe initialization of static objectsChris M. Thomasson
|||   | | |                        |   | |    `* Re: Thread-safe initialization of static objectsBonita Montero
|||   | | |                        |   | |     `* Re: Thread-safe initialization of static objectsChris M. Thomasson
|||   | | |                        |   | |      `* Re: Thread-safe initialization of static objectsBonita Montero
|||   | | |                        |   | `- Re: Thread-safe initialization of static objectsChris M. Thomasson
|||   | | |                        |   `* Re: Thread-safe initialization of static objectsKaz Kylheku
|||   | | |                        `* Re: Thread-safe initialization of static objectsPavel
|||   | | `- Re: Thread-safe initialization of static objectsChris M. Thomasson
|||   | `- Re: Thread-safe initialization of static objectsChris M. Thomasson
|||   `- Re: Thread-safe initialization of static objectsMarcel Mueller
||`- Re: Thread-safe initialization of static objectsChris M. Thomasson
|`* Re: Thread-safe initialization of static objectsChris M. Thomasson
+* Re: Thread-safe initialization of static objectsPaavo Helde
+* Re: Thread-safe initialization of static objectsChris M. Thomasson
+* Re: Thread-safe initialization of static objectsChris M. Thomasson
`* Re: Thread-safe initialization of static objectsFrederick Virchanza Gotham

Pages:123456789101112131415161718192021222324252627
Re: Thread-safe initialization of static objects

<uY5OM.30730$Yxl8.13078@fx14.iad>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=1587&group=comp.lang.c%2B%2B#1587

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!newsfeed.hasname.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx14.iad.POSTED!not-for-mail
Subject: Re: Thread-safe initialization of static objects
Newsgroups: comp.lang.c++
References: <udafjf$2joeq$1@dont-email.me> <udigbv$6ddc$2@dont-email.me>
<0M4LM.170545$uEkc.43152@fx35.iad> <udk0hm$h1e9$3@dont-email.me>
<udl0ti$lp5v$4@dont-email.me> <udn883$135tl$1@dont-email.me>
<udnqhc$160ia$3@dont-email.me> <udoico$1d0tr$1@dont-email.me>
<udotj5$1e8do$2@dont-email.me> <udpbun$1gf8c$1@dont-email.me>
<udqatg$1mar3$1@dont-email.me> <udqbg3$1mdv6$1@dont-email.me>
<udqq8u$1p3q6$1@dont-email.me> <uds0qa$22qfj$1@dont-email.me>
<udtg9s$2aqb5$1@dont-email.me> <uduimg$2imqi$1@dont-email.me>
<FUEMM.7469$ZkX3.6739@fx09.iad> <ue3bhh$3l4s1$1@dont-email.me>
<ue3nga$3ms5s$1@dont-email.me> <eohNM.4832$3lL1.1360@fx47.iad>
<ue4cqe$3rjfr$1@dont-email.me> <LwlNM.50924$QShe.20423@fx11.iad>
<ue4p5v$3truj$1@dont-email.me> <EjoNM.17221$DXgc.9861@fx36.iad>
<ue5tfc$7pns$1@dont-email.me> <zPGNM.14021$BMnd.11871@fx04.iad>
<ue7f6g$frod$2@dont-email.me> <LWINM.13017$ZkX3.12109@fx09.iad>
<ue8mn0$q534$4@dont-email.me>
From: pauldontspamtolk@removeyourself.dontspam.yahoo (Pavel)
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
Firefox/91.0 SeaMonkey/2.53.17
MIME-Version: 1.0
In-Reply-To: <ue8mn0$q534$4@dont-email.me>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Lines: 12
Message-ID: <uY5OM.30730$Yxl8.13078@fx14.iad>
X-Complaints-To: https://www.astraweb.com/aup
NNTP-Posting-Date: Tue, 19 Sep 2023 00:30:18 UTC
Date: Mon, 18 Sep 2023 20:30:18 -0400
X-Received-Bytes: 1985
 by: Pavel - Tue, 19 Sep 2023 00:30 UTC

Bonita Montero wrote:
> Am 17.09.2023 um 22:01 schrieb Pavel:
>
>> Of course you don't show that the synchronization primitives that are
>> used for static initialization are mutexes.
>
> Call it mutex or whatever: the standard requires that contenders
> sleep in place, and that's only possible with something that works
> like a mutex.
Define "works like a mutex".

Re: Thread-safe initialization of static objects

<ds6OM.29862$DXgc.27330@fx36.iad>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=1588&group=comp.lang.c%2B%2B#1588

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx36.iad.POSTED!not-for-mail
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
Subject: Re: Thread-safe initialization of static objects
Newsgroups: comp.lang.c++
References: <udafjf$2joeq$1@dont-email.me> <udk0hm$h1e9$3@dont-email.me>
<udl0ti$lp5v$4@dont-email.me> <udn883$135tl$1@dont-email.me>
<udnqhc$160ia$3@dont-email.me> <udoico$1d0tr$1@dont-email.me>
<udotj5$1e8do$2@dont-email.me> <udpbun$1gf8c$1@dont-email.me>
<udqatg$1mar3$1@dont-email.me> <udqbg3$1mdv6$1@dont-email.me>
<udqq8u$1p3q6$1@dont-email.me> <uds0qa$22qfj$1@dont-email.me>
<udtg9s$2aqb5$1@dont-email.me> <uduimg$2imqi$1@dont-email.me>
<FUEMM.7469$ZkX3.6739@fx09.iad> <ue3bhh$3l4s1$1@dont-email.me>
<ue3nga$3ms5s$1@dont-email.me> <eohNM.4832$3lL1.1360@fx47.iad>
<ue4cqe$3rjfr$1@dont-email.me> <LwlNM.50924$QShe.20423@fx11.iad>
<ue4p5v$3truj$1@dont-email.me> <EjoNM.17221$DXgc.9861@fx36.iad>
<ue5tfc$7pns$1@dont-email.me> <zPGNM.14021$BMnd.11871@fx04.iad>
<ue7f6g$frod$2@dont-email.me> <ue7gdm$fumm$4@dont-email.me>
<ue7hc3$g7tm$1@dont-email.me> <ue7r4j$i3u1$1@dont-email.me>
<ue8mid$q534$2@dont-email.me> <O9XNM.16067$JX2f.12159@fx13.iad>
<ue9gao$1ousp$1@dont-email.me>
From: Richard@Damon-Family.org (Richard Damon)
Content-Language: en-US
In-Reply-To: <ue9gao$1ousp$1@dont-email.me>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Lines: 25
Message-ID: <ds6OM.29862$DXgc.27330@fx36.iad>
X-Complaints-To: abuse@easynews.com
Organization: Forte - www.forteinc.com
X-Complaints-Info: Please be sure to forward a copy of ALL headers otherwise we will be unable to process your complaint properly.
Date: Mon, 18 Sep 2023 21:04:08 -0400
X-Received-Bytes: 2496
 by: Richard Damon - Tue, 19 Sep 2023 01:04 UTC

On 9/18/23 8:37 AM, Bonita Montero wrote:
> Am 18.09.2023 um 14:13 schrieb Richard Damon:
>
>> Why?
>
> Because a mutex does this also with an appropriate exception. And there
> wouldn't be more problems if such an excepton would be thrown, but less.
>

So implementions needs to be allowed to do the wrong thing?

Shows your sense of how programs shoudld (not) work.

>> Since it can be done without ever failing, ...
>
> I've shown that libc++, libstdc++ and MSVC handle this with per-object
> mutexes, and if you create an arbitrary number of mutexes this might
> fail.
>
>

Nope. You show that you can not read.

Others have pointed out what the code of those functions ACTUALLY do, an
it isn't what you are calling a "Mutex", and it can't fail.

Re: Thread-safe initialization of static objects

<ueb3c7$2638l$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=1589&group=comp.lang.c%2B%2B#1589

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Bonita.Montero@gmail.com (Bonita Montero)
Newsgroups: comp.lang.c++
Subject: Re: Thread-safe initialization of static objects
Date: Tue, 19 Sep 2023 05:08:54 +0200
Organization: A noiseless patient Spider
Lines: 15
Message-ID: <ueb3c7$2638l$1@dont-email.me>
References: <udafjf$2joeq$1@dont-email.me> <udn883$135tl$1@dont-email.me>
<udnqhc$160ia$3@dont-email.me> <udoico$1d0tr$1@dont-email.me>
<udotj5$1e8do$2@dont-email.me> <udpbun$1gf8c$1@dont-email.me>
<udqatg$1mar3$1@dont-email.me> <udqbg3$1mdv6$1@dont-email.me>
<udqq8u$1p3q6$1@dont-email.me> <uds0qa$22qfj$1@dont-email.me>
<udtg9s$2aqb5$1@dont-email.me> <uduimg$2imqi$1@dont-email.me>
<FUEMM.7469$ZkX3.6739@fx09.iad> <ue3bhh$3l4s1$1@dont-email.me>
<ue3nga$3ms5s$1@dont-email.me> <eohNM.4832$3lL1.1360@fx47.iad>
<ue4cqe$3rjfr$1@dont-email.me> <LwlNM.50924$QShe.20423@fx11.iad>
<ue4p5v$3truj$1@dont-email.me> <ue4t6i$3um57$1@dont-email.me>
<ue5sp2$7ms9$1@dont-email.me> <ue7gb8$fumm$3@dont-email.me>
<ue7gkn$g3o5$1@dont-email.me> <ue7hb6$g6eb$1@dont-email.me>
<ue7hdn$g7tm$2@dont-email.me> <ue7hps$g6eb$4@dont-email.me>
<ue7htp$g7tm$6@dont-email.me> <ue7idv$gach$4@dont-email.me>
<ue7j3g$ggh4$1@dont-email.me> <ue7lnd$h1b4$1@dont-email.me>
<ue8lpq$q25a$1@dont-email.me> <uea7vf$1tgqs$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 19 Sep 2023 03:08:55 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="85b9ebaf81ad877fb9605894b3bc8446";
logging-data="2297109"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+uryGmOULJ4iwtwpzB978kmO+llIiAf+A="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:D24YalDDD4gVo/SoFH3rmp7oQUU=
In-Reply-To: <uea7vf$1tgqs$1@dont-email.me>
Content-Language: de-DE
 by: Bonita Montero - Tue, 19 Sep 2023 03:08 UTC

Am 18.09.2023 um 21:21 schrieb Chris M. Thomasson:
> On 9/17/2023 10:05 PM, Bonita Montero wrote:
>> Am 17.09.2023 um 21:57 schrieb Chris M. Thomasson:
>>
>>> I still don't think you know how they work.
>>
>> You didn't read the paper, not me.
>>
>
> I already know how futexes work. In and out.

You said that everythong happens in userspace. And you didn't notice
that it isn't impossible to have a blocking thread this way ...

Re: Thread-safe initialization of static objects

<ueb3f7$2638l$2@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=1590&group=comp.lang.c%2B%2B#1590

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Bonita.Montero@gmail.com (Bonita Montero)
Newsgroups: comp.lang.c++
Subject: Re: Thread-safe initialization of static objects
Date: Tue, 19 Sep 2023 05:10:31 +0200
Organization: A noiseless patient Spider
Lines: 8
Message-ID: <ueb3f7$2638l$2@dont-email.me>
References: <udafjf$2joeq$1@dont-email.me> <udl0ti$lp5v$4@dont-email.me>
<udn883$135tl$1@dont-email.me> <udnqhc$160ia$3@dont-email.me>
<udoico$1d0tr$1@dont-email.me> <udotj5$1e8do$2@dont-email.me>
<udpbun$1gf8c$1@dont-email.me> <udqatg$1mar3$1@dont-email.me>
<udqbg3$1mdv6$1@dont-email.me> <udqq8u$1p3q6$1@dont-email.me>
<uds0qa$22qfj$1@dont-email.me> <udtg9s$2aqb5$1@dont-email.me>
<uduimg$2imqi$1@dont-email.me> <FUEMM.7469$ZkX3.6739@fx09.iad>
<ue3bhh$3l4s1$1@dont-email.me> <ue3nga$3ms5s$1@dont-email.me>
<eohNM.4832$3lL1.1360@fx47.iad> <ue4cqe$3rjfr$1@dont-email.me>
<LwlNM.50924$QShe.20423@fx11.iad> <ue4p5v$3truj$1@dont-email.me>
<ue4t6i$3um57$1@dont-email.me> <ue5sp2$7ms9$1@dont-email.me>
<ue7gb8$fumm$3@dont-email.me> <ue7gkn$g3o5$1@dont-email.me>
<20230917121015.206@kylheku.com> <ue7k2n$gmqv$1@dont-email.me>
<20230917123203.524@kylheku.com> <ue8lst$q25a$2@dont-email.me>
<20230918101705.91@kylheku.com> <uea1rj$1saml$1@dont-email.me>
<hK5OM.30729$Yxl8.9621@fx14.iad>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 19 Sep 2023 03:10:31 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="85b9ebaf81ad877fb9605894b3bc8446";
logging-data="2297109"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18JsXxI0sNbB9vZm1dIVv4JZRSfPUD/N0I="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:Rg80tLKJbslDIugjcvF0I8p7D+Q=
Content-Language: de-DE
In-Reply-To: <hK5OM.30729$Yxl8.9621@fx14.iad>
 by: Bonita Montero - Tue, 19 Sep 2023 03:10 UTC

Am 19.09.2023 um 02:15 schrieb Pavel:

> Or, when there is nothing to create, there is nothing to defer,

I've shown that static initialization actually uses a mutex per object.
The runtimes for sure not pre-create a number of mutexes for that since
static objects are just zeroed memory before initialization.

Re: Thread-safe initialization of static objects

<ueb3h4$2638l$3@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=1591&group=comp.lang.c%2B%2B#1591

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Bonita.Montero@gmail.com (Bonita Montero)
Newsgroups: comp.lang.c++
Subject: Re: Thread-safe initialization of static objects
Date: Tue, 19 Sep 2023 05:11:32 +0200
Organization: A noiseless patient Spider
Lines: 14
Message-ID: <ueb3h4$2638l$3@dont-email.me>
References: <udafjf$2joeq$1@dont-email.me> <0M4LM.170545$uEkc.43152@fx35.iad>
<udk0hm$h1e9$3@dont-email.me> <udl0ti$lp5v$4@dont-email.me>
<udn883$135tl$1@dont-email.me> <udnqhc$160ia$3@dont-email.me>
<udoico$1d0tr$1@dont-email.me> <udotj5$1e8do$2@dont-email.me>
<udpbun$1gf8c$1@dont-email.me> <udqatg$1mar3$1@dont-email.me>
<udqbg3$1mdv6$1@dont-email.me> <udqq8u$1p3q6$1@dont-email.me>
<uds0qa$22qfj$1@dont-email.me> <udtg9s$2aqb5$1@dont-email.me>
<uduimg$2imqi$1@dont-email.me> <FUEMM.7469$ZkX3.6739@fx09.iad>
<ue3bhh$3l4s1$1@dont-email.me> <ue3nga$3ms5s$1@dont-email.me>
<eohNM.4832$3lL1.1360@fx47.iad> <ue4cqe$3rjfr$1@dont-email.me>
<LwlNM.50924$QShe.20423@fx11.iad> <ue4p5v$3truj$1@dont-email.me>
<ue4t6i$3um57$1@dont-email.me> <ue5sp2$7ms9$1@dont-email.me>
<ue7gb8$fumm$3@dont-email.me> <ue7gkn$g3o5$1@dont-email.me>
<20230917121015.206@kylheku.com> <ue7k2n$gmqv$1@dont-email.me>
<aJINM.23275$H8td.10140@fx10.iad> <ue8lv5$q25a$3@dont-email.me>
<uea82d$1tgqs$3@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 19 Sep 2023 03:11:32 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="85b9ebaf81ad877fb9605894b3bc8446";
logging-data="2297109"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+hPcmRTdlfAAm9jdmsmSLJV5Iv4qoGV5s="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:1WQNqOpGZg0mgyGlJcOjSSEAWdU=
In-Reply-To: <uea82d$1tgqs$3@dont-email.me>
Content-Language: de-DE
 by: Bonita Montero - Tue, 19 Sep 2023 03:11 UTC

Am 18.09.2023 um 21:22 schrieb Chris M. Thomasson:
> On 9/17/2023 10:07 PM, Bonita Montero wrote:
>> Am 17.09.2023 um 21:47 schrieb Richard Damon:
>>
>>> Why does it need to take into account that an BAD implementation
>>> might fail.
>>
>> With the deferred initialization of a C++ mutex the mutex
>> could fail on synchronization even without being bad.
>
> The impl must make sure to get it right wrt static initialization.

Idiot - I wasn't talking about static initialization at this point.

Re: Thread-safe initialization of static objects

<ueb3lp$2638l$4@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=1592&group=comp.lang.c%2B%2B#1592

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Bonita.Montero@gmail.com (Bonita Montero)
Newsgroups: comp.lang.c++
Subject: Re: Thread-safe initialization of static objects
Date: Tue, 19 Sep 2023 05:14:01 +0200
Organization: A noiseless patient Spider
Lines: 13
Message-ID: <ueb3lp$2638l$4@dont-email.me>
References: <udafjf$2joeq$1@dont-email.me> <udl0ti$lp5v$4@dont-email.me>
<udn883$135tl$1@dont-email.me> <udnqhc$160ia$3@dont-email.me>
<udoico$1d0tr$1@dont-email.me> <udotj5$1e8do$2@dont-email.me>
<udpbun$1gf8c$1@dont-email.me> <udqatg$1mar3$1@dont-email.me>
<udqbg3$1mdv6$1@dont-email.me> <udqq8u$1p3q6$1@dont-email.me>
<uds0qa$22qfj$1@dont-email.me> <udtg9s$2aqb5$1@dont-email.me>
<uduimg$2imqi$1@dont-email.me> <FUEMM.7469$ZkX3.6739@fx09.iad>
<ue3bhh$3l4s1$1@dont-email.me> <ue3nga$3ms5s$1@dont-email.me>
<eohNM.4832$3lL1.1360@fx47.iad> <ue4cqe$3rjfr$1@dont-email.me>
<LwlNM.50924$QShe.20423@fx11.iad> <ue4p5v$3truj$1@dont-email.me>
<EjoNM.17221$DXgc.9861@fx36.iad> <ue5tfc$7pns$1@dont-email.me>
<zPGNM.14021$BMnd.11871@fx04.iad> <ue7f6g$frod$2@dont-email.me>
<ue7gdm$fumm$4@dont-email.me> <ue7hc3$g7tm$1@dont-email.me>
<ue7r4j$i3u1$1@dont-email.me> <ue8mid$q534$2@dont-email.me>
<O9XNM.16067$JX2f.12159@fx13.iad> <ue9gao$1ousp$1@dont-email.me>
<ds6OM.29862$DXgc.27330@fx36.iad>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 19 Sep 2023 03:14:01 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="85b9ebaf81ad877fb9605894b3bc8446";
logging-data="2297109"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/sJ0+6JykGrjjZHqVNOWA88aKF+hot+C0="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:S+EI5FWFXIeBsSkbzHy9t6NZx1c=
Content-Language: de-DE
In-Reply-To: <ds6OM.29862$DXgc.27330@fx36.iad>
 by: Bonita Montero - Tue, 19 Sep 2023 03:14 UTC

Am 19.09.2023 um 03:04 schrieb Richard Damon:

> So implementions needs to be allowed to do the wrong thing?

It would be the right thing if this would be specified.

> Others have pointed out what the code of those functions ACTUALLY do,
> an it isn't what you are calling a "Mutex", and it can't fail.

You're as stupid as Chris - I wasn't talking about whether the code
can fail or not at this point, but just that there's actually a mutex
per static object.

Re: Thread-safe initialization of static objects

<ueb3q5$2638l$5@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=1593&group=comp.lang.c%2B%2B#1593

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Bonita.Montero@gmail.com (Bonita Montero)
Newsgroups: comp.lang.c++
Subject: Re: Thread-safe initialization of static objects
Date: Tue, 19 Sep 2023 05:16:21 +0200
Organization: A noiseless patient Spider
Lines: 33
Message-ID: <ueb3q5$2638l$5@dont-email.me>
References: <udafjf$2joeq$1@dont-email.me> <udn883$135tl$1@dont-email.me>
<udnqhc$160ia$3@dont-email.me> <udoico$1d0tr$1@dont-email.me>
<udotj5$1e8do$2@dont-email.me> <udpbun$1gf8c$1@dont-email.me>
<udqatg$1mar3$1@dont-email.me> <udqbg3$1mdv6$1@dont-email.me>
<udqq8u$1p3q6$1@dont-email.me> <uds0qa$22qfj$1@dont-email.me>
<udtg9s$2aqb5$1@dont-email.me> <uduimg$2imqi$1@dont-email.me>
<FUEMM.7469$ZkX3.6739@fx09.iad> <ue3bhh$3l4s1$1@dont-email.me>
<ue3nga$3ms5s$1@dont-email.me> <eohNM.4832$3lL1.1360@fx47.iad>
<ue4cqe$3rjfr$1@dont-email.me> <LwlNM.50924$QShe.20423@fx11.iad>
<ue4p5v$3truj$1@dont-email.me> <EjoNM.17221$DXgc.9861@fx36.iad>
<ue5tfc$7pns$1@dont-email.me> <zPGNM.14021$BMnd.11871@fx04.iad>
<ue7f6g$frod$2@dont-email.me> <ue7gdm$fumm$4@dont-email.me>
<ue7hc3$g7tm$1@dont-email.me> <ue7r4j$i3u1$1@dont-email.me>
<ue8mid$q534$2@dont-email.me> <O9XNM.16067$JX2f.12159@fx13.iad>
<20230918110147.326@kylheku.com> <uea42g$1sn0e$2@dont-email.me>
<20230918123203.723@kylheku.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 19 Sep 2023 03:16:21 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="85b9ebaf81ad877fb9605894b3bc8446";
logging-data="2297109"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+jplnsiTdvlj8rfMKMcAf+oMXjxkX0vDo="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:ZcwRMTDnHai8P5R5wMaC3TA9dN8=
Content-Language: de-DE
In-Reply-To: <20230918123203.723@kylheku.com>
 by: Bonita Montero - Tue, 19 Sep 2023 03:16 UTC

Am 18.09.2023 um 21:42 schrieb Kaz Kylheku:

>> Local static objects are initialized when the code comes across the
>> initialization. All other static local objects it refers to have been
>> declared before, otherwise the static object wouldn't be able to use
>> them. So there will be never a deadlock.

> That is false:
>
> struct static_thing
> {
> // constructor calls function pointer argument
> static_thing(void (*)(pfn))
> {
> pfn();
> }
> };
>
> void A(void)
> {
> static_thing o(B);
> }
>
> void B(void)
> {
> static_thing o(A);
> }
> ...

That doesn't make sense in the context since we talked about
a deadlock by the mutex included in static initialization and
not by mutexes you handle separarely - idiot.

Re: Thread-safe initialization of static objects

<ueb3sb$2638l$6@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=1594&group=comp.lang.c%2B%2B#1594

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Bonita.Montero@gmail.com (Bonita Montero)
Newsgroups: comp.lang.c++
Subject: Re: Thread-safe initialization of static objects
Date: Tue, 19 Sep 2023 05:17:31 +0200
Organization: A noiseless patient Spider
Lines: 10
Message-ID: <ueb3sb$2638l$6@dont-email.me>
References: <udafjf$2joeq$1@dont-email.me> <udigbv$6ddc$2@dont-email.me>
<0M4LM.170545$uEkc.43152@fx35.iad> <udk0hm$h1e9$3@dont-email.me>
<udl0ti$lp5v$4@dont-email.me> <udn883$135tl$1@dont-email.me>
<udnqhc$160ia$3@dont-email.me> <udoico$1d0tr$1@dont-email.me>
<udotj5$1e8do$2@dont-email.me> <udpbun$1gf8c$1@dont-email.me>
<udqatg$1mar3$1@dont-email.me> <udqbg3$1mdv6$1@dont-email.me>
<udqq8u$1p3q6$1@dont-email.me> <uds0qa$22qfj$1@dont-email.me>
<udtg9s$2aqb5$1@dont-email.me> <uduimg$2imqi$1@dont-email.me>
<FUEMM.7469$ZkX3.6739@fx09.iad> <ue3bhh$3l4s1$1@dont-email.me>
<ue3nga$3ms5s$1@dont-email.me> <eohNM.4832$3lL1.1360@fx47.iad>
<ue4cqe$3rjfr$1@dont-email.me> <LwlNM.50924$QShe.20423@fx11.iad>
<ue4p5v$3truj$1@dont-email.me> <EjoNM.17221$DXgc.9861@fx36.iad>
<ue5tfc$7pns$1@dont-email.me> <zPGNM.14021$BMnd.11871@fx04.iad>
<ue7f6g$frod$2@dont-email.me> <LWINM.13017$ZkX3.12109@fx09.iad>
<ue8mn0$q534$4@dont-email.me> <uY5OM.30730$Yxl8.13078@fx14.iad>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 19 Sep 2023 03:17:31 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="85b9ebaf81ad877fb9605894b3bc8446";
logging-data="2297109"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+paxjV+v6VMTbEQRWtWKkN/5uhh4+tzeM="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:1e7BZL6o27eZueNZn4SHIhtcAM8=
Content-Language: de-DE
In-Reply-To: <uY5OM.30730$Yxl8.13078@fx14.iad>
 by: Bonita Montero - Tue, 19 Sep 2023 03:17 UTC

Am 19.09.2023 um 02:30 schrieb Pavel:

>> Call it mutex or whatever: the standard requires that contenders
>> sleep in place, and that's only possible with something that works
>> like a mutex.

> Define "works like a mutex".

A lock which makes a thread to sleep on contention.

Re: Thread-safe initialization of static objects

<20230918205859.263@kylheku.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=1595&group=comp.lang.c%2B%2B#1595

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: 864-117-4973@kylheku.com (Kaz Kylheku)
Newsgroups: comp.lang.c++
Subject: Re: Thread-safe initialization of static objects
Date: Tue, 19 Sep 2023 04:05:25 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 65
Message-ID: <20230918205859.263@kylheku.com>
References: <udafjf$2joeq$1@dont-email.me> <udnqhc$160ia$3@dont-email.me>
<udoico$1d0tr$1@dont-email.me> <udotj5$1e8do$2@dont-email.me>
<udpbun$1gf8c$1@dont-email.me> <udqatg$1mar3$1@dont-email.me>
<udqbg3$1mdv6$1@dont-email.me> <udqq8u$1p3q6$1@dont-email.me>
<uds0qa$22qfj$1@dont-email.me> <udtg9s$2aqb5$1@dont-email.me>
<uduimg$2imqi$1@dont-email.me> <FUEMM.7469$ZkX3.6739@fx09.iad>
<ue3bhh$3l4s1$1@dont-email.me> <ue3nga$3ms5s$1@dont-email.me>
<eohNM.4832$3lL1.1360@fx47.iad> <ue4cqe$3rjfr$1@dont-email.me>
<LwlNM.50924$QShe.20423@fx11.iad> <ue4p5v$3truj$1@dont-email.me>
<EjoNM.17221$DXgc.9861@fx36.iad> <ue5tfc$7pns$1@dont-email.me>
<zPGNM.14021$BMnd.11871@fx04.iad> <ue7f6g$frod$2@dont-email.me>
<ue7gdm$fumm$4@dont-email.me> <ue7hc3$g7tm$1@dont-email.me>
<ue7r4j$i3u1$1@dont-email.me> <ue8mid$q534$2@dont-email.me>
<O9XNM.16067$JX2f.12159@fx13.iad> <20230918110147.326@kylheku.com>
<uea42g$1sn0e$2@dont-email.me> <20230918123203.723@kylheku.com>
<ueb3q5$2638l$5@dont-email.me>
Injection-Date: Tue, 19 Sep 2023 04:05:25 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="78a1cbf526ee5626f6ff8689cdc8787c";
logging-data="2311547"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+vOYfDmfavKv+1OhmBZFr/xMjz0eVgOb4="
User-Agent: slrn/pre1.0.4-9 (Linux)
Cancel-Lock: sha1:Er3tbUkWMf0XrwF/IkNrBNCiXOA=
 by: Kaz Kylheku - Tue, 19 Sep 2023 04:05 UTC

On 2023-09-19, Bonita Montero <Bonita.Montero@gmail.com> wrote:
> Am 18.09.2023 um 21:42 schrieb Kaz Kylheku:
>
>>> Local static objects are initialized when the code comes across the
>>> initialization. All other static local objects it refers to have been
>>> declared before, otherwise the static object wouldn't be able to use
>>> them. So there will be never a deadlock.
>
>> That is false:
>>
>> struct static_thing
>> {
>> // constructor calls function pointer argument
>> static_thing(void (*)(pfn))
>> {
>> pfn();
>> }
>> };
>>
>> void A(void)
>> {
>> static_thing o(B);
>> }
>>
>> void B(void)
>> {
>> static_thing o(A);
>> }
>> ...
>
> That doesn't make sense in the context since we talked about
> a deadlock by the mutex included in static initialization and
> not by mutexes you handle separarely - idiot.

The subject of the thread is "Thread-safe initialization of static
objects". This is what I'm writing about. I have static objects
above (which don't have mutexes, or any data members at all). I'm
assuming their initialization is made thread-safe via (hidden, not
explicitly visible) mutexes generated by the compiler.

You /seemed/ to be claiming that such an arrangement cannot deadlock.

Whether or not, I'm showing above how it can.

1. One static initialization can be nested inside another,
such that the calling thread momentarily owns both mutexes.

2. Two or more threads can execute initializations.

3. Thus, two threads can nest the same pair of initializations
in opposite order.

(Therefore, I agree with you; those hidden mutexes could run into
a situation which their lock operations could, in principle, detect
and turn into an exception.)

If you didn't claim that static initialization with hidden mutexes
cannot deadlock, please disregard this as a counterexample to anything
you said, but it still holds on its own.

--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
Mastodon: @Kazinator@mstdn.ca
NOTE: If you use Google Groups, I don't see you, unless you're whitelisted.

Re: Thread-safe initialization of static objects

<ueb9up$271en$2@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=1596&group=comp.lang.c%2B%2B#1596

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: chris.m.thomasson.1@gmail.com (Chris M. Thomasson)
Newsgroups: comp.lang.c++
Subject: Re: Thread-safe initialization of static objects
Date: Mon, 18 Sep 2023 22:01:13 -0700
Organization: A noiseless patient Spider
Lines: 19
Message-ID: <ueb9up$271en$2@dont-email.me>
References: <udafjf$2joeq$1@dont-email.me> <udnqhc$160ia$3@dont-email.me>
<udoico$1d0tr$1@dont-email.me> <udotj5$1e8do$2@dont-email.me>
<udpbun$1gf8c$1@dont-email.me> <udqatg$1mar3$1@dont-email.me>
<udqbg3$1mdv6$1@dont-email.me> <udqq8u$1p3q6$1@dont-email.me>
<uds0qa$22qfj$1@dont-email.me> <udtg9s$2aqb5$1@dont-email.me>
<uduimg$2imqi$1@dont-email.me> <FUEMM.7469$ZkX3.6739@fx09.iad>
<ue3bhh$3l4s1$1@dont-email.me> <ue3nga$3ms5s$1@dont-email.me>
<eohNM.4832$3lL1.1360@fx47.iad> <ue4cqe$3rjfr$1@dont-email.me>
<LwlNM.50924$QShe.20423@fx11.iad> <ue4p5v$3truj$1@dont-email.me>
<ue4t6i$3um57$1@dont-email.me> <ue5sp2$7ms9$1@dont-email.me>
<ue7gb8$fumm$3@dont-email.me> <ue7gkn$g3o5$1@dont-email.me>
<ue7hb6$g6eb$1@dont-email.me> <ue7hdn$g7tm$2@dont-email.me>
<ue7hps$g6eb$4@dont-email.me> <ue7htp$g7tm$6@dont-email.me>
<ue7idv$gach$4@dont-email.me> <ue7j3g$ggh4$1@dont-email.me>
<ue7lnd$h1b4$1@dont-email.me> <ue8lpq$q25a$1@dont-email.me>
<uea7vf$1tgqs$1@dont-email.me> <ueb3c7$2638l$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 19 Sep 2023 05:01:14 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="e823050642b27d6b26a63385ba2f7eca";
logging-data="2328023"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX195G8mw0ke/JUpLNA+VBYozUsdGaA8agkc="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.15.1
Cancel-Lock: sha1:MU6znsw5qzb/ig4TOqKbUV6X3hA=
In-Reply-To: <ueb3c7$2638l$1@dont-email.me>
Content-Language: en-US
 by: Chris M. Thomasson - Tue, 19 Sep 2023 05:01 UTC

On 9/18/2023 8:08 PM, Bonita Montero wrote:
> Am 18.09.2023 um 21:21 schrieb Chris M. Thomasson:
>> On 9/17/2023 10:05 PM, Bonita Montero wrote:
>>> Am 17.09.2023 um 21:57 schrieb Chris M. Thomasson:
>>>
>>>> I still don't think you know how they work.
>>>
>>> You didn't read the paper, not me.
>>>
>>
>> I already know how futexes work. In and out.
>
> You said that everythong happens in userspace. And you didn't notice
> that it isn't impossible to have a blocking thread this way ...
>
>

We can choose to use the kernel to wait, if we choose to. You are
bringing back memories... Thanks for that Bonita. :^)

Re: Thread-safe initialization of static objects

<ueb9vm$271en$3@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=1597&group=comp.lang.c%2B%2B#1597

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: chris.m.thomasson.1@gmail.com (Chris M. Thomasson)
Newsgroups: comp.lang.c++
Subject: Re: Thread-safe initialization of static objects
Date: Mon, 18 Sep 2023 22:01:41 -0700
Organization: A noiseless patient Spider
Lines: 15
Message-ID: <ueb9vm$271en$3@dont-email.me>
References: <udafjf$2joeq$1@dont-email.me> <udn883$135tl$1@dont-email.me>
<udnqhc$160ia$3@dont-email.me> <udoico$1d0tr$1@dont-email.me>
<udotj5$1e8do$2@dont-email.me> <udpbun$1gf8c$1@dont-email.me>
<udqatg$1mar3$1@dont-email.me> <udqbg3$1mdv6$1@dont-email.me>
<udqq8u$1p3q6$1@dont-email.me> <uds0qa$22qfj$1@dont-email.me>
<udtg9s$2aqb5$1@dont-email.me> <uduimg$2imqi$1@dont-email.me>
<FUEMM.7469$ZkX3.6739@fx09.iad> <ue3bhh$3l4s1$1@dont-email.me>
<ue3nga$3ms5s$1@dont-email.me> <eohNM.4832$3lL1.1360@fx47.iad>
<ue4cqe$3rjfr$1@dont-email.me> <LwlNM.50924$QShe.20423@fx11.iad>
<ue4p5v$3truj$1@dont-email.me> <ue4t6i$3um57$1@dont-email.me>
<ue5sp2$7ms9$1@dont-email.me> <ue7gb8$fumm$3@dont-email.me>
<ue7gkn$g3o5$1@dont-email.me> <20230917121015.206@kylheku.com>
<ue7k2n$gmqv$1@dont-email.me> <20230917123203.524@kylheku.com>
<ue8lst$q25a$2@dont-email.me> <20230918101705.91@kylheku.com>
<uea1rj$1saml$1@dont-email.me> <hK5OM.30729$Yxl8.9621@fx14.iad>
<ueb3f7$2638l$2@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 19 Sep 2023 05:01:42 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="e823050642b27d6b26a63385ba2f7eca";
logging-data="2328023"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/0Y1QmwLB+gGG6vgvynXkH+AMDGHVcq3g="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.15.1
Cancel-Lock: sha1:zujZnlnxjS87yll5nH0A9VNVYDw=
Content-Language: en-US
In-Reply-To: <ueb3f7$2638l$2@dont-email.me>
 by: Chris M. Thomasson - Tue, 19 Sep 2023 05:01 UTC

On 9/18/2023 8:10 PM, Bonita Montero wrote:
> Am 19.09.2023 um 02:15 schrieb Pavel:
>
>> Or, when there is nothing to create, there is nothing to defer,
>
> I've shown that static initialization actually uses a mutex per object.

Really?

> The runtimes for sure not pre-create a number of mutexes for that since
> static objects are just zeroed memory before initialization.
>

Re: Thread-safe initialization of static objects

<ueba14$271en$4@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=1598&group=comp.lang.c%2B%2B#1598

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!news.hispagatos.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: chris.m.thomasson.1@gmail.com (Chris M. Thomasson)
Newsgroups: comp.lang.c++
Subject: Re: Thread-safe initialization of static objects
Date: Mon, 18 Sep 2023 22:02:28 -0700
Organization: A noiseless patient Spider
Lines: 18
Message-ID: <ueba14$271en$4@dont-email.me>
References: <udafjf$2joeq$1@dont-email.me> <udk0hm$h1e9$3@dont-email.me>
<udl0ti$lp5v$4@dont-email.me> <udn883$135tl$1@dont-email.me>
<udnqhc$160ia$3@dont-email.me> <udoico$1d0tr$1@dont-email.me>
<udotj5$1e8do$2@dont-email.me> <udpbun$1gf8c$1@dont-email.me>
<udqatg$1mar3$1@dont-email.me> <udqbg3$1mdv6$1@dont-email.me>
<udqq8u$1p3q6$1@dont-email.me> <uds0qa$22qfj$1@dont-email.me>
<udtg9s$2aqb5$1@dont-email.me> <uduimg$2imqi$1@dont-email.me>
<FUEMM.7469$ZkX3.6739@fx09.iad> <ue3bhh$3l4s1$1@dont-email.me>
<ue3nga$3ms5s$1@dont-email.me> <eohNM.4832$3lL1.1360@fx47.iad>
<ue4cqe$3rjfr$1@dont-email.me> <LwlNM.50924$QShe.20423@fx11.iad>
<ue4p5v$3truj$1@dont-email.me> <ue4t6i$3um57$1@dont-email.me>
<ue5sp2$7ms9$1@dont-email.me> <ue7gb8$fumm$3@dont-email.me>
<ue7gkn$g3o5$1@dont-email.me> <20230917121015.206@kylheku.com>
<ue7k2n$gmqv$1@dont-email.me> <aJINM.23275$H8td.10140@fx10.iad>
<ue8lv5$q25a$3@dont-email.me> <uea82d$1tgqs$3@dont-email.me>
<ueb3h4$2638l$3@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 19 Sep 2023 05:02:29 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="e823050642b27d6b26a63385ba2f7eca";
logging-data="2328023"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18wsLHfwXIvt3aKxBxf1uKc7b3tW3CjCZk="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.15.1
Cancel-Lock: sha1:TfUSuaba1f2DX075W4AFAMNzImQ=
Content-Language: en-US
In-Reply-To: <ueb3h4$2638l$3@dont-email.me>
 by: Chris M. Thomasson - Tue, 19 Sep 2023 05:02 UTC

On 9/18/2023 8:11 PM, Bonita Montero wrote:
> Am 18.09.2023 um 21:22 schrieb Chris M. Thomasson:
>> On 9/17/2023 10:07 PM, Bonita Montero wrote:
>>> Am 17.09.2023 um 21:47 schrieb Richard Damon:
>>>
>>>> Why does it need to take into account that an BAD implementation
>>>> might fail.
>>>
>>> With the deferred initialization of a C++ mutex the mutex
>>> could fail on synchronization even without being bad.
>>
>> The impl must make sure to get it right wrt static initialization.
>
> Idiot - I wasn't talking about static initialization at this point.
>

Oh, I think you are. Are you now talking about how many mutexes can a
process create before it dies?

Re: Thread-safe initialization of static objects

<ueba94$271en$5@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=1599&group=comp.lang.c%2B%2B#1599

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: chris.m.thomasson.1@gmail.com (Chris M. Thomasson)
Newsgroups: comp.lang.c++
Subject: Re: Thread-safe initialization of static objects
Date: Mon, 18 Sep 2023 22:06:43 -0700
Organization: A noiseless patient Spider
Lines: 22
Message-ID: <ueba94$271en$5@dont-email.me>
References: <udafjf$2joeq$1@dont-email.me> <udn883$135tl$1@dont-email.me>
<udnqhc$160ia$3@dont-email.me> <udoico$1d0tr$1@dont-email.me>
<udotj5$1e8do$2@dont-email.me> <udpbun$1gf8c$1@dont-email.me>
<udqatg$1mar3$1@dont-email.me> <udqbg3$1mdv6$1@dont-email.me>
<udqq8u$1p3q6$1@dont-email.me> <uds0qa$22qfj$1@dont-email.me>
<udtg9s$2aqb5$1@dont-email.me> <uduimg$2imqi$1@dont-email.me>
<FUEMM.7469$ZkX3.6739@fx09.iad> <ue3bhh$3l4s1$1@dont-email.me>
<ue3nga$3ms5s$1@dont-email.me> <eohNM.4832$3lL1.1360@fx47.iad>
<ue4cqe$3rjfr$1@dont-email.me> <LwlNM.50924$QShe.20423@fx11.iad>
<ue4p5v$3truj$1@dont-email.me> <EjoNM.17221$DXgc.9861@fx36.iad>
<ue5tfc$7pns$1@dont-email.me> <zPGNM.14021$BMnd.11871@fx04.iad>
<ue7f6g$frod$2@dont-email.me> <ue7gdm$fumm$4@dont-email.me>
<ue7hc3$g7tm$1@dont-email.me> <ue7r4j$i3u1$1@dont-email.me>
<ue8mid$q534$2@dont-email.me> <O9XNM.16067$JX2f.12159@fx13.iad>
<ue9gao$1ousp$1@dont-email.me> <ds6OM.29862$DXgc.27330@fx36.iad>
<ueb3lp$2638l$4@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 19 Sep 2023 05:06:44 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="e823050642b27d6b26a63385ba2f7eca";
logging-data="2328023"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/j3TAO417iw7Nn0EEjXfn808DldBPxGOc="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.15.1
Cancel-Lock: sha1:jsQDtDbG7rbDcHtVk7XfHOw6VtU=
Content-Language: en-US
In-Reply-To: <ueb3lp$2638l$4@dont-email.me>
 by: Chris M. Thomasson - Tue, 19 Sep 2023 05:06 UTC

On 9/18/2023 8:14 PM, Bonita Montero wrote:
> Am 19.09.2023 um 03:04 schrieb Richard Damon:
>
>> So implementions needs to be allowed to do the wrong thing?
>
> It would be the right thing if this would be specified.
>
>> Others have pointed out what the code of those functions ACTUALLY do,
>> an it isn't what you are calling a "Mutex", and it can't fail.
>
> You're as stupid as Chris - I wasn't talking about whether the code
> can fail or not at this point,

Altering goal posts now, oh wonderful one?

> but just that there's actually a mutex
> per static object.
>

Really? Humm...

Re: Thread-safe initialization of static objects

<uebact$271en$6@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=1600&group=comp.lang.c%2B%2B#1600

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: chris.m.thomasson.1@gmail.com (Chris M. Thomasson)
Newsgroups: comp.lang.c++
Subject: Re: Thread-safe initialization of static objects
Date: Mon, 18 Sep 2023 22:08:45 -0700
Organization: A noiseless patient Spider
Lines: 66
Message-ID: <uebact$271en$6@dont-email.me>
References: <udafjf$2joeq$1@dont-email.me> <udoico$1d0tr$1@dont-email.me>
<udotj5$1e8do$2@dont-email.me> <udpbun$1gf8c$1@dont-email.me>
<udqatg$1mar3$1@dont-email.me> <udqbg3$1mdv6$1@dont-email.me>
<udqq8u$1p3q6$1@dont-email.me> <uds0qa$22qfj$1@dont-email.me>
<udtg9s$2aqb5$1@dont-email.me> <uduimg$2imqi$1@dont-email.me>
<FUEMM.7469$ZkX3.6739@fx09.iad> <ue3bhh$3l4s1$1@dont-email.me>
<ue3nga$3ms5s$1@dont-email.me> <eohNM.4832$3lL1.1360@fx47.iad>
<ue4cqe$3rjfr$1@dont-email.me> <LwlNM.50924$QShe.20423@fx11.iad>
<ue4p5v$3truj$1@dont-email.me> <EjoNM.17221$DXgc.9861@fx36.iad>
<ue5tfc$7pns$1@dont-email.me> <zPGNM.14021$BMnd.11871@fx04.iad>
<ue7f6g$frod$2@dont-email.me> <ue7gdm$fumm$4@dont-email.me>
<ue7hc3$g7tm$1@dont-email.me> <ue7r4j$i3u1$1@dont-email.me>
<ue8mid$q534$2@dont-email.me> <O9XNM.16067$JX2f.12159@fx13.iad>
<20230918110147.326@kylheku.com> <uea42g$1sn0e$2@dont-email.me>
<20230918123203.723@kylheku.com> <ueb3q5$2638l$5@dont-email.me>
<20230918205859.263@kylheku.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 19 Sep 2023 05:08:45 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="e823050642b27d6b26a63385ba2f7eca";
logging-data="2328023"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+usCeXu+XnO3ISOMtcN1SVG/y+HHPHut8="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.15.1
Cancel-Lock: sha1:h2B0HjGqhu9OBsF67DRuwngQpPE=
In-Reply-To: <20230918205859.263@kylheku.com>
Content-Language: en-US
 by: Chris M. Thomasson - Tue, 19 Sep 2023 05:08 UTC

On 9/18/2023 9:05 PM, Kaz Kylheku wrote:
> On 2023-09-19, Bonita Montero <Bonita.Montero@gmail.com> wrote:
>> Am 18.09.2023 um 21:42 schrieb Kaz Kylheku:
>>
>>>> Local static objects are initialized when the code comes across the
>>>> initialization. All other static local objects it refers to have been
>>>> declared before, otherwise the static object wouldn't be able to use
>>>> them. So there will be never a deadlock.
>>
>>> That is false:
>>>
>>> struct static_thing
>>> {
>>> // constructor calls function pointer argument
>>> static_thing(void (*)(pfn))
>>> {
>>> pfn();
>>> }
>>> };
>>>
>>> void A(void)
>>> {
>>> static_thing o(B);
>>> }
>>>
>>> void B(void)
>>> {
>>> static_thing o(A);
>>> }
>>> ...
>>
>> That doesn't make sense in the context since we talked about
>> a deadlock by the mutex included in static initialization and
>> not by mutexes you handle separarely - idiot.
>
> The subject of the thread is "Thread-safe initialization of static
> objects". This is what I'm writing about. I have static objects
> above (which don't have mutexes, or any data members at all). I'm
> assuming their initialization is made thread-safe via (hidden, not
> explicitly visible) mutexes generated by the compiler.
>
> You /seemed/ to be claiming that such an arrangement cannot deadlock.

If the impl can deadlock wrt satic init, then we might as well take an
infinite walk off a very short peer.

>
> Whether or not, I'm showing above how it can.
>
> 1. One static initialization can be nested inside another,
> such that the calling thread momentarily owns both mutexes.
>
> 2. Two or more threads can execute initializations.
>
> 3. Thus, two threads can nest the same pair of initializations
> in opposite order.
>
> (Therefore, I agree with you; those hidden mutexes could run into
> a situation which their lock operations could, in principle, detect
> and turn into an exception.)
>
> If you didn't claim that static initialization with hidden mutexes
> cannot deadlock, please disregard this as a counterexample to anything
> you said, but it still holds on its own.
>

Re: Thread-safe initialization of static objects

<uebahl$271en$7@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=1601&group=comp.lang.c%2B%2B#1601

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: chris.m.thomasson.1@gmail.com (Chris M. Thomasson)
Newsgroups: comp.lang.c++
Subject: Re: Thread-safe initialization of static objects
Date: Mon, 18 Sep 2023 22:11:16 -0700
Organization: A noiseless patient Spider
Lines: 72
Message-ID: <uebahl$271en$7@dont-email.me>
References: <udafjf$2joeq$1@dont-email.me> <udotj5$1e8do$2@dont-email.me>
<udpbun$1gf8c$1@dont-email.me> <udqatg$1mar3$1@dont-email.me>
<udqbg3$1mdv6$1@dont-email.me> <udqq8u$1p3q6$1@dont-email.me>
<uds0qa$22qfj$1@dont-email.me> <udtg9s$2aqb5$1@dont-email.me>
<uduimg$2imqi$1@dont-email.me> <FUEMM.7469$ZkX3.6739@fx09.iad>
<ue3bhh$3l4s1$1@dont-email.me> <ue3nga$3ms5s$1@dont-email.me>
<eohNM.4832$3lL1.1360@fx47.iad> <ue4cqe$3rjfr$1@dont-email.me>
<LwlNM.50924$QShe.20423@fx11.iad> <ue4p5v$3truj$1@dont-email.me>
<EjoNM.17221$DXgc.9861@fx36.iad> <ue5tfc$7pns$1@dont-email.me>
<zPGNM.14021$BMnd.11871@fx04.iad> <ue7f6g$frod$2@dont-email.me>
<ue7gdm$fumm$4@dont-email.me> <ue7hc3$g7tm$1@dont-email.me>
<ue7r4j$i3u1$1@dont-email.me> <ue8mid$q534$2@dont-email.me>
<O9XNM.16067$JX2f.12159@fx13.iad> <20230918110147.326@kylheku.com>
<uea42g$1sn0e$2@dont-email.me> <20230918123203.723@kylheku.com>
<ueb3q5$2638l$5@dont-email.me> <20230918205859.263@kylheku.com>
<uebact$271en$6@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Tue, 19 Sep 2023 05:11:17 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="e823050642b27d6b26a63385ba2f7eca";
logging-data="2328023"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19QflZFlt971l5FRjzbOPEbf0xewp6pnZ8="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.15.1
Cancel-Lock: sha1:kNr5QFUSCQ2CD3ylI+2vUA+vcvg=
Content-Language: en-US
In-Reply-To: <uebact$271en$6@dont-email.me>
 by: Chris M. Thomasson - Tue, 19 Sep 2023 05:11 UTC

On 9/18/2023 10:08 PM, Chris M. Thomasson wrote:
> On 9/18/2023 9:05 PM, Kaz Kylheku wrote:
>> On 2023-09-19, Bonita Montero <Bonita.Montero@gmail.com> wrote:
>>> Am 18.09.2023 um 21:42 schrieb Kaz Kylheku:
>>>
>>>>> Local static objects are initialized when the code comes across the
>>>>> initialization. All other static local objects it refers to have been
>>>>> declared before, otherwise the static object wouldn't be able to use
>>>>> them. So there will be never a deadlock.
>>>
>>>> That is false:
>>>>
>>>>     struct static_thing
>>>>     {
>>>>       // constructor calls function pointer argument
>>>>       static_thing(void (*)(pfn))
>>>>       {
>>>>          pfn();
>>>>       }
>>>>     };
>>>>
>>>>     void A(void)
>>>>     {
>>>>        static_thing o(B);
>>>>     }
>>>>
>>>>     void B(void)
>>>>     {
>>>>        static_thing o(A);
>>>>     }
>>>> ...
>>>
>>> That doesn't make sense in the context since we talked about
>>> a deadlock by the mutex included in static initialization and
>>> not by mutexes you handle separarely - idiot.
>>
>> The subject of the thread is "Thread-safe initialization of static
>> objects". This is what I'm writing about. I have static objects
>> above (which don't have mutexes, or any data members at all). I'm
>> assuming their initialization is made thread-safe via (hidden, not
>> explicitly visible) mutexes generated by the compiler.
>>
>> You /seemed/ to be claiming that such an arrangement cannot deadlock.
>
> If the impl can deadlock wrt satic init, then we might as well take an
> infinite walk off a very short peer.
>
>>
>> Whether or not, I'm showing above how it can.
>>
>> 1. One static initialization can be nested inside another,
>>     such that the calling thread momentarily owns both mutexes.

>>
>> 2. Two or more threads can execute initializations.
>>
>> 3. Thus, two threads can nest the same pair of initializations
>>     in opposite order.
>>
>> (Therefore, I agree with you; those hidden mutexes could run into
>> a situation which their lock operations could, in principle, detect
>> and turn into an exception.)
>>
>> If you didn't claim that static initialization with hidden mutexes
>> cannot deadlock, please disregard this as a counterexample to anything
>> you said, but it still holds on its own.
>>
>

The impl better sure make god damn sure that there is no deadlock on
static init of say, POD's.

Re: Thread-safe initialization of static objects

<uebaoh$271en$8@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=1602&group=comp.lang.c%2B%2B#1602

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: chris.m.thomasson.1@gmail.com (Chris M. Thomasson)
Newsgroups: comp.lang.c++
Subject: Re: Thread-safe initialization of static objects
Date: Mon, 18 Sep 2023 22:14:57 -0700
Organization: A noiseless patient Spider
Lines: 18
Message-ID: <uebaoh$271en$8@dont-email.me>
References: <udafjf$2joeq$1@dont-email.me> <udigbv$6ddc$2@dont-email.me>
<0M4LM.170545$uEkc.43152@fx35.iad> <udk0hm$h1e9$3@dont-email.me>
<udl0ti$lp5v$4@dont-email.me> <udn883$135tl$1@dont-email.me>
<udnqhc$160ia$3@dont-email.me> <udoico$1d0tr$1@dont-email.me>
<udotj5$1e8do$2@dont-email.me> <udpbun$1gf8c$1@dont-email.me>
<udqatg$1mar3$1@dont-email.me> <udqbg3$1mdv6$1@dont-email.me>
<udqq8u$1p3q6$1@dont-email.me> <uds0qa$22qfj$1@dont-email.me>
<udtg9s$2aqb5$1@dont-email.me> <uduimg$2imqi$1@dont-email.me>
<FUEMM.7469$ZkX3.6739@fx09.iad> <ue3bhh$3l4s1$1@dont-email.me>
<ue3nga$3ms5s$1@dont-email.me> <eohNM.4832$3lL1.1360@fx47.iad>
<ue4cqe$3rjfr$1@dont-email.me> <LwlNM.50924$QShe.20423@fx11.iad>
<ue4p5v$3truj$1@dont-email.me> <EjoNM.17221$DXgc.9861@fx36.iad>
<ue5tfc$7pns$1@dont-email.me> <zPGNM.14021$BMnd.11871@fx04.iad>
<ue7f6g$frod$2@dont-email.me> <LWINM.13017$ZkX3.12109@fx09.iad>
<ue8mn0$q534$4@dont-email.me> <uY5OM.30730$Yxl8.13078@fx14.iad>
<ueb3sb$2638l$6@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 19 Sep 2023 05:14:57 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="e823050642b27d6b26a63385ba2f7eca";
logging-data="2328023"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/luFfM6hmBwhI02vL4MZWgwNQhD0Cc2cA="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.15.1
Cancel-Lock: sha1:8ghgayTh7AajlqK2IgtCJjWCPKk=
In-Reply-To: <ueb3sb$2638l$6@dont-email.me>
Content-Language: en-US
 by: Chris M. Thomasson - Tue, 19 Sep 2023 05:14 UTC

On 9/18/2023 8:17 PM, Bonita Montero wrote:
> Am 19.09.2023 um 02:30 schrieb Pavel:
>
>>> Call it mutex or whatever: the standard requires that contenders
>>> sleep in place, and that's only possible with something that works
>>> like a mutex.
>
>> Define "works like a mutex".
>
> A lock which makes a thread to sleep on contention.
>

I assume going to "sleep" means waiting in the kernel on a slow path.
Otherwise, humm... Are you talking about user logic that sleeps for a
second or two? Why should that matter at all? The impl shall arrange
things such that there is no deadlock. Let me guess Bonita, you think
that user logic that waits for infinity while its trying to initialize
itself should be handled in the std? Humm... Not sure about you.

Re: Thread-safe initialization of static objects

<uebare$271en$9@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=1603&group=comp.lang.c%2B%2B#1603

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: chris.m.thomasson.1@gmail.com (Chris M. Thomasson)
Newsgroups: comp.lang.c++
Subject: Re: Thread-safe initialization of static objects
Date: Mon, 18 Sep 2023 22:16:29 -0700
Organization: A noiseless patient Spider
Lines: 23
Message-ID: <uebare$271en$9@dont-email.me>
References: <udafjf$2joeq$1@dont-email.me> <udnqhc$160ia$3@dont-email.me>
<udoico$1d0tr$1@dont-email.me> <udotj5$1e8do$2@dont-email.me>
<udpbun$1gf8c$1@dont-email.me> <udqatg$1mar3$1@dont-email.me>
<udqbg3$1mdv6$1@dont-email.me> <udqq8u$1p3q6$1@dont-email.me>
<uds0qa$22qfj$1@dont-email.me> <udtg9s$2aqb5$1@dont-email.me>
<uduimg$2imqi$1@dont-email.me> <FUEMM.7469$ZkX3.6739@fx09.iad>
<ue3bhh$3l4s1$1@dont-email.me> <ue3nga$3ms5s$1@dont-email.me>
<eohNM.4832$3lL1.1360@fx47.iad> <ue4cqe$3rjfr$1@dont-email.me>
<LwlNM.50924$QShe.20423@fx11.iad> <ue4p5v$3truj$1@dont-email.me>
<ue4t6i$3um57$1@dont-email.me> <ue5sp2$7ms9$1@dont-email.me>
<ue7gb8$fumm$3@dont-email.me> <ue7gkn$g3o5$1@dont-email.me>
<ue7hb6$g6eb$1@dont-email.me> <ue7hdn$g7tm$2@dont-email.me>
<ue7hps$g6eb$4@dont-email.me> <ue7htp$g7tm$6@dont-email.me>
<ue7idv$gach$4@dont-email.me> <ue7j3g$ggh4$1@dont-email.me>
<ue7lnd$h1b4$1@dont-email.me> <ue8lpq$q25a$1@dont-email.me>
<uea7vf$1tgqs$1@dont-email.me> <ueb3c7$2638l$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 19 Sep 2023 05:16:30 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="e823050642b27d6b26a63385ba2f7eca";
logging-data="2328023"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19o8bkx/am6ekJ2f2sJHdUm3382gc7s8N0="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.15.1
Cancel-Lock: sha1:62wWDNBRhZfBjt1o+HVeBm7vQlk=
In-Reply-To: <ueb3c7$2638l$1@dont-email.me>
Content-Language: en-US
 by: Chris M. Thomasson - Tue, 19 Sep 2023 05:16 UTC

On 9/18/2023 8:08 PM, Bonita Montero wrote:
> Am 18.09.2023 um 21:21 schrieb Chris M. Thomasson:
>> On 9/17/2023 10:05 PM, Bonita Montero wrote:
>>> Am 17.09.2023 um 21:57 schrieb Chris M. Thomasson:
>>>
>>>> I still don't think you know how they work.
>>>
>>> You didn't read the paper, not me.
>>>
>>
>> I already know how futexes work. In and out.
>
> You said that everythong happens in userspace.

Any user algorithm that needs to be able to wait on a predicate. Futex!

> And you didn't notice
> that it isn't impossible to have a blocking thread this way ...
>
>

Re: Thread-safe initialization of static objects

<20230918223630.407@kylheku.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=1604&group=comp.lang.c%2B%2B#1604

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: 864-117-4973@kylheku.com (Kaz Kylheku)
Newsgroups: comp.lang.c++
Subject: Re: Thread-safe initialization of static objects
Date: Tue, 19 Sep 2023 05:50:20 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 34
Message-ID: <20230918223630.407@kylheku.com>
References: <udafjf$2joeq$1@dont-email.me> <udpbun$1gf8c$1@dont-email.me>
<udqatg$1mar3$1@dont-email.me> <udqbg3$1mdv6$1@dont-email.me>
<udqq8u$1p3q6$1@dont-email.me> <uds0qa$22qfj$1@dont-email.me>
<udtg9s$2aqb5$1@dont-email.me> <uduimg$2imqi$1@dont-email.me>
<FUEMM.7469$ZkX3.6739@fx09.iad> <ue3bhh$3l4s1$1@dont-email.me>
<ue3nga$3ms5s$1@dont-email.me> <eohNM.4832$3lL1.1360@fx47.iad>
<ue4cqe$3rjfr$1@dont-email.me> <LwlNM.50924$QShe.20423@fx11.iad>
<ue4p5v$3truj$1@dont-email.me> <EjoNM.17221$DXgc.9861@fx36.iad>
<ue5tfc$7pns$1@dont-email.me> <zPGNM.14021$BMnd.11871@fx04.iad>
<ue7f6g$frod$2@dont-email.me> <ue7gdm$fumm$4@dont-email.me>
<ue7hc3$g7tm$1@dont-email.me> <ue7r4j$i3u1$1@dont-email.me>
<ue8mid$q534$2@dont-email.me> <O9XNM.16067$JX2f.12159@fx13.iad>
<20230918110147.326@kylheku.com> <uea42g$1sn0e$2@dont-email.me>
<20230918123203.723@kylheku.com> <ueb3q5$2638l$5@dont-email.me>
<20230918205859.263@kylheku.com> <uebact$271en$6@dont-email.me>
<uebahl$271en$7@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Tue, 19 Sep 2023 05:50:20 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="78a1cbf526ee5626f6ff8689cdc8787c";
logging-data="2342468"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+UID3nFufEDa+7Yr5pPa8nOPHMLDwi1aI="
User-Agent: slrn/pre1.0.4-9 (Linux)
Cancel-Lock: sha1:vj6Dw8zmfW1G39RNgiQVRYFUFyQ=
 by: Kaz Kylheku - Tue, 19 Sep 2023 05:50 UTC

On 2023-09-19, Chris M. Thomasson <chris.m.thomasson.1@gmail.com> wrote:
> The impl better sure make god damn sure that there is no deadlock on
> static init of say, POD's.

PODs aren't a special category. Never mind that, how about scalars?

The problem is that the static initializer expressions in C++ can call
functions.

int B();

int A()
{
    static int a = B();
}

void B()
{
static int b = A();
}

What prevents a deadlock here, in mutex-guarded static initialization
logic, if one thread calls A at the same time as another calls B?

Here is one way a deadlock could be prevented, at least in a program
which doesn't mix its own explicit mutexes with static initializations:
just have one global mutex (a recursive one) for all lazy static
initializations.

--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
Mastodon: @Kazinator@mstdn.ca
NOTE: If you use Google Groups, I don't see you, unless you're whitelisted.

Re: Thread-safe initialization of static objects

<uebegu$27mou$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=1605&group=comp.lang.c%2B%2B#1605

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: chris.m.thomasson.1@gmail.com (Chris M. Thomasson)
Newsgroups: comp.lang.c++
Subject: Re: Thread-safe initialization of static objects
Date: Mon, 18 Sep 2023 23:19:09 -0700
Organization: A noiseless patient Spider
Lines: 32
Message-ID: <uebegu$27mou$1@dont-email.me>
References: <udafjf$2joeq$1@dont-email.me> <udqatg$1mar3$1@dont-email.me>
<udqbg3$1mdv6$1@dont-email.me> <udqq8u$1p3q6$1@dont-email.me>
<uds0qa$22qfj$1@dont-email.me> <udtg9s$2aqb5$1@dont-email.me>
<uduimg$2imqi$1@dont-email.me> <FUEMM.7469$ZkX3.6739@fx09.iad>
<ue3bhh$3l4s1$1@dont-email.me> <ue3nga$3ms5s$1@dont-email.me>
<eohNM.4832$3lL1.1360@fx47.iad> <ue4cqe$3rjfr$1@dont-email.me>
<LwlNM.50924$QShe.20423@fx11.iad> <ue4p5v$3truj$1@dont-email.me>
<EjoNM.17221$DXgc.9861@fx36.iad> <ue5tfc$7pns$1@dont-email.me>
<zPGNM.14021$BMnd.11871@fx04.iad> <ue7f6g$frod$2@dont-email.me>
<ue7gdm$fumm$4@dont-email.me> <ue7hc3$g7tm$1@dont-email.me>
<ue7r4j$i3u1$1@dont-email.me> <ue8mid$q534$2@dont-email.me>
<O9XNM.16067$JX2f.12159@fx13.iad> <20230918110147.326@kylheku.com>
<uea42g$1sn0e$2@dont-email.me> <20230918123203.723@kylheku.com>
<ueb3q5$2638l$5@dont-email.me> <20230918205859.263@kylheku.com>
<uebact$271en$6@dont-email.me> <uebahl$271en$7@dont-email.me>
<20230918223630.407@kylheku.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Tue, 19 Sep 2023 06:19:10 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="e823050642b27d6b26a63385ba2f7eca";
logging-data="2349854"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/R4pOa7XGh0VdqoyFW+h4YP4oy4qPH6Jg="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.15.1
Cancel-Lock: sha1:dzKWT/WKZcsLJdnKWrwv5P+ap/k=
Content-Language: en-US
In-Reply-To: <20230918223630.407@kylheku.com>
 by: Chris M. Thomasson - Tue, 19 Sep 2023 06:19 UTC

On 9/18/2023 10:50 PM, Kaz Kylheku wrote:
> On 2023-09-19, Chris M. Thomasson <chris.m.thomasson.1@gmail.com> wrote:
>> The impl better sure make god damn sure that there is no deadlock on
>> static init of say, POD's.
>
> PODs aren't a special category. Never mind that, how about scalars?
>
> The problem is that the static initializer expressions in C++ can call
> functions.
>
> int B();
>
> int A()
> {
>     static int a = B();
> }
>
> void B()
> {
> static int b = A();
> }
>
> What prevents a deadlock here, in mutex-guarded static initialization
> logic, if one thread calls A at the same time as another calls B?
>
> Here is one way a deadlock could be prevented, at least in a program
> which doesn't mix its own explicit mutexes with static initializations:
> just have one global mutex (a recursive one) for all lazy static
> initializations.
>

A allowing recursion would work, but I tend to try to avoid those suckers.

Re: Thread-safe initialization of static objects

<uebejb$27mot$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=1606&group=comp.lang.c%2B%2B#1606

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: chris.m.thomasson.1@gmail.com (Chris M. Thomasson)
Newsgroups: comp.lang.c++
Subject: Re: Thread-safe initialization of static objects
Date: Mon, 18 Sep 2023 23:20:27 -0700
Organization: A noiseless patient Spider
Lines: 35
Message-ID: <uebejb$27mot$1@dont-email.me>
References: <udafjf$2joeq$1@dont-email.me> <udqatg$1mar3$1@dont-email.me>
<udqbg3$1mdv6$1@dont-email.me> <udqq8u$1p3q6$1@dont-email.me>
<uds0qa$22qfj$1@dont-email.me> <udtg9s$2aqb5$1@dont-email.me>
<uduimg$2imqi$1@dont-email.me> <FUEMM.7469$ZkX3.6739@fx09.iad>
<ue3bhh$3l4s1$1@dont-email.me> <ue3nga$3ms5s$1@dont-email.me>
<eohNM.4832$3lL1.1360@fx47.iad> <ue4cqe$3rjfr$1@dont-email.me>
<LwlNM.50924$QShe.20423@fx11.iad> <ue4p5v$3truj$1@dont-email.me>
<EjoNM.17221$DXgc.9861@fx36.iad> <ue5tfc$7pns$1@dont-email.me>
<zPGNM.14021$BMnd.11871@fx04.iad> <ue7f6g$frod$2@dont-email.me>
<ue7gdm$fumm$4@dont-email.me> <ue7hc3$g7tm$1@dont-email.me>
<ue7r4j$i3u1$1@dont-email.me> <ue8mid$q534$2@dont-email.me>
<O9XNM.16067$JX2f.12159@fx13.iad> <20230918110147.326@kylheku.com>
<uea42g$1sn0e$2@dont-email.me> <20230918123203.723@kylheku.com>
<ueb3q5$2638l$5@dont-email.me> <20230918205859.263@kylheku.com>
<uebact$271en$6@dont-email.me> <uebahl$271en$7@dont-email.me>
<20230918223630.407@kylheku.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Tue, 19 Sep 2023 06:20:28 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="e823050642b27d6b26a63385ba2f7eca";
logging-data="2349853"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+X9lzJgJ0fGiLfnPBx9MfRDpyc6ZatBzU="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.15.1
Cancel-Lock: sha1:ImwPmbnRb4GZC+TuI6vB5IBARtU=
In-Reply-To: <20230918223630.407@kylheku.com>
Content-Language: en-US
 by: Chris M. Thomasson - Tue, 19 Sep 2023 06:20 UTC

On 9/18/2023 10:50 PM, Kaz Kylheku wrote:
> On 2023-09-19, Chris M. Thomasson <chris.m.thomasson.1@gmail.com> wrote:
>> The impl better sure make god damn sure that there is no deadlock on
>> static init of say, POD's.
>
> PODs aren't a special category. Never mind that, how about scalars?
>
> The problem is that the static initializer expressions in C++ can call
> functions.
>
> int B();
>
> int A()
> {
>     static int a = B();
> }
>
> void B()
> {
> static int b = A();
> }

Would that go into infinite recursion?

>
> What prevents a deadlock here, in mutex-guarded static initialization
> logic, if one thread calls A at the same time as another calls B?
>
> Here is one way a deadlock could be prevented, at least in a program
> which doesn't mix its own explicit mutexes with static initializations:
> just have one global mutex (a recursive one) for all lazy static
> initializations.
>

Re: Thread-safe initialization of static objects

<20230919003006.611@kylheku.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=1607&group=comp.lang.c%2B%2B#1607

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: 864-117-4973@kylheku.com (Kaz Kylheku)
Newsgroups: comp.lang.c++
Subject: Re: Thread-safe initialization of static objects
Date: Tue, 19 Sep 2023 07:59:11 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 46
Message-ID: <20230919003006.611@kylheku.com>
References: <udafjf$2joeq$1@dont-email.me> <udqbg3$1mdv6$1@dont-email.me>
<udqq8u$1p3q6$1@dont-email.me> <uds0qa$22qfj$1@dont-email.me>
<udtg9s$2aqb5$1@dont-email.me> <uduimg$2imqi$1@dont-email.me>
<FUEMM.7469$ZkX3.6739@fx09.iad> <ue3bhh$3l4s1$1@dont-email.me>
<ue3nga$3ms5s$1@dont-email.me> <eohNM.4832$3lL1.1360@fx47.iad>
<ue4cqe$3rjfr$1@dont-email.me> <LwlNM.50924$QShe.20423@fx11.iad>
<ue4p5v$3truj$1@dont-email.me> <EjoNM.17221$DXgc.9861@fx36.iad>
<ue5tfc$7pns$1@dont-email.me> <zPGNM.14021$BMnd.11871@fx04.iad>
<ue7f6g$frod$2@dont-email.me> <ue7gdm$fumm$4@dont-email.me>
<ue7hc3$g7tm$1@dont-email.me> <ue7r4j$i3u1$1@dont-email.me>
<ue8mid$q534$2@dont-email.me> <O9XNM.16067$JX2f.12159@fx13.iad>
<20230918110147.326@kylheku.com> <uea42g$1sn0e$2@dont-email.me>
<20230918123203.723@kylheku.com> <ueb3q5$2638l$5@dont-email.me>
<20230918205859.263@kylheku.com> <uebact$271en$6@dont-email.me>
<uebahl$271en$7@dont-email.me> <20230918223630.407@kylheku.com>
<uebejb$27mot$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Tue, 19 Sep 2023 07:59:11 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="78a1cbf526ee5626f6ff8689cdc8787c";
logging-data="2380812"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+KLVkpWCWVuJPv9XKQh0aL7bpKsfS1ZNc="
User-Agent: slrn/pre1.0.4-9 (Linux)
Cancel-Lock: sha1:sc5IAqaAmuWMY2SfPZRJrQiYcRo=
 by: Kaz Kylheku - Tue, 19 Sep 2023 07:59 UTC

On 2023-09-19, Chris M. Thomasson <chris.m.thomasson.1@gmail.com> wrote:
> On 9/18/2023 10:50 PM, Kaz Kylheku wrote:
>> On 2023-09-19, Chris M. Thomasson <chris.m.thomasson.1@gmail.com> wrote:
>>> The impl better sure make god damn sure that there is no deadlock on
>>> static init of say, POD's.
>>
>> PODs aren't a special category. Never mind that, how about scalars?
>>
>> The problem is that the static initializer expressions in C++ can call
>> functions.
>>
>> int B();
>>
>> int A()
>> {
>>     static int a = B();
>> }
>>
>> void B()
>> {
>> static int b = A();
>> }
>
> Would that go into infinite recursion?

Firstly, I also wanted an int return on B() and return statements.

Yes; even in a single threaded situation, we have a recursion problem.
So that's the overriding problem, not whether we get deadlock with
multiple threads.

If the one and only thread calls A(), it will re-enter A() without
the initialization having completed which is bad.

Can you think of some static init scenario that works fine single
threaded, but potentially deadlocks when threads are present?

Even if not, be that as it may, the mutex deadlock detection could
debug the situation, whether just one thread triggers it, or
several.

--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
Mastodon: @Kazinator@mstdn.ca
NOTE: If you use Google Groups, I don't see you, unless you're whitelisted.

Re: Thread-safe initialization of static objects

<uebn0a$293m3$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=1608&group=comp.lang.c%2B%2B#1608

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Bonita.Montero@gmail.com (Bonita Montero)
Newsgroups: comp.lang.c++
Subject: Re: Thread-safe initialization of static objects
Date: Tue, 19 Sep 2023 10:43:54 +0200
Organization: A noiseless patient Spider
Lines: 9
Message-ID: <uebn0a$293m3$1@dont-email.me>
References: <udafjf$2joeq$1@dont-email.me> <udoico$1d0tr$1@dont-email.me>
<udotj5$1e8do$2@dont-email.me> <udpbun$1gf8c$1@dont-email.me>
<udqatg$1mar3$1@dont-email.me> <udqbg3$1mdv6$1@dont-email.me>
<udqq8u$1p3q6$1@dont-email.me> <uds0qa$22qfj$1@dont-email.me>
<udtg9s$2aqb5$1@dont-email.me> <uduimg$2imqi$1@dont-email.me>
<FUEMM.7469$ZkX3.6739@fx09.iad> <ue3bhh$3l4s1$1@dont-email.me>
<ue3nga$3ms5s$1@dont-email.me> <eohNM.4832$3lL1.1360@fx47.iad>
<ue4cqe$3rjfr$1@dont-email.me> <LwlNM.50924$QShe.20423@fx11.iad>
<ue4p5v$3truj$1@dont-email.me> <ue4t6i$3um57$1@dont-email.me>
<ue5sp2$7ms9$1@dont-email.me> <ue7gb8$fumm$3@dont-email.me>
<ue7gkn$g3o5$1@dont-email.me> <ue7hb6$g6eb$1@dont-email.me>
<ue7hdn$g7tm$2@dont-email.me> <ue7hps$g6eb$4@dont-email.me>
<ue7htp$g7tm$6@dont-email.me> <ue7idv$gach$4@dont-email.me>
<ue7j3g$ggh4$1@dont-email.me> <ue7lnd$h1b4$1@dont-email.me>
<ue8lpq$q25a$1@dont-email.me> <uea7vf$1tgqs$1@dont-email.me>
<ueb3c7$2638l$1@dont-email.me> <ueb9up$271en$2@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 19 Sep 2023 08:43:54 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="85b9ebaf81ad877fb9605894b3bc8446";
logging-data="2395843"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/s3fD2n8EfPggSf7nDE77NXA0dKipoNco="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:ZvSwQFhVVva3lNkrCpgw3Sk96Cc=
Content-Language: de-DE
In-Reply-To: <ueb9up$271en$2@dont-email.me>
 by: Bonita Montero - Tue, 19 Sep 2023 08:43 UTC

Am 19.09.2023 um 07:01 schrieb Chris M. Thomasson:

> We can choose to use the kernel to wait, if we choose to.
> You are bringing back memories... Thanks for that Bonita. :^)

The futex part of a mutex is for the slow path. It appears that
this is done with a kernel intervention since there's no explicit
kernel call.

Re: Thread-safe initialization of static objects

<uebn4f$293m3$2@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=1609&group=comp.lang.c%2B%2B#1609

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Bonita.Montero@gmail.com (Bonita Montero)
Newsgroups: comp.lang.c++
Subject: Re: Thread-safe initialization of static objects
Date: Tue, 19 Sep 2023 10:46:07 +0200
Organization: A noiseless patient Spider
Lines: 46
Message-ID: <uebn4f$293m3$2@dont-email.me>
References: <udafjf$2joeq$1@dont-email.me> <udnqhc$160ia$3@dont-email.me>
<udoico$1d0tr$1@dont-email.me> <udotj5$1e8do$2@dont-email.me>
<udpbun$1gf8c$1@dont-email.me> <udqatg$1mar3$1@dont-email.me>
<udqbg3$1mdv6$1@dont-email.me> <udqq8u$1p3q6$1@dont-email.me>
<uds0qa$22qfj$1@dont-email.me> <udtg9s$2aqb5$1@dont-email.me>
<uduimg$2imqi$1@dont-email.me> <FUEMM.7469$ZkX3.6739@fx09.iad>
<ue3bhh$3l4s1$1@dont-email.me> <ue3nga$3ms5s$1@dont-email.me>
<eohNM.4832$3lL1.1360@fx47.iad> <ue4cqe$3rjfr$1@dont-email.me>
<LwlNM.50924$QShe.20423@fx11.iad> <ue4p5v$3truj$1@dont-email.me>
<ue4t6i$3um57$1@dont-email.me> <ue5sp2$7ms9$1@dont-email.me>
<ue7gb8$fumm$3@dont-email.me> <ue7gkn$g3o5$1@dont-email.me>
<20230917121015.206@kylheku.com> <ue7k2n$gmqv$1@dont-email.me>
<20230917123203.524@kylheku.com> <ue8lst$q25a$2@dont-email.me>
<20230918101705.91@kylheku.com> <uea1rj$1saml$1@dont-email.me>
<hK5OM.30729$Yxl8.9621@fx14.iad> <ueb3f7$2638l$2@dont-email.me>
<ueb9vm$271en$3@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 19 Sep 2023 08:46:07 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="85b9ebaf81ad877fb9605894b3bc8446";
logging-data="2395843"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+C9fpO0ogL7OyIrIeiWVJrM69+4drHH3U="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:LYFHf11D/YJMsEEwoYM8G7gKUlQ=
In-Reply-To: <ueb9vm$271en$3@dont-email.me>
Content-Language: de-DE
 by: Bonita Montero - Tue, 19 Sep 2023 08:46 UTC

Am 19.09.2023 um 07:01 schrieb Chris M. Thomasson:

>> I've shown that static initialization actually uses a mutex per object.

> Really?

Here, a third time the code for you:

#include <iostream>
#include <utility>
#include <vector>
#include <thread>

using namespace std;

int main()
{ struct InitSleep
{
InitSleep()
{
this_thread::sleep_for( 1s );
}
};
constexpr unsigned N_THREADS = 100;
auto unroll = []<size_t ... Indices>( index_sequence<Indices ...>, auto
fn )
{
(fn.template operator ()<Indices>(), ...);
};
vector<jthread> threads;
threads.reserve( N_THREADS );
unroll( make_index_sequence<N_THREADS>(),
[&]<size_t T>()
{
threads.emplace_back( []( auto )
{
static InitSleep is;
}, integral_constant<size_t, T>() );
} );
}

The lambda's calling operator is instantiated N_THREADS time, thereby
having a static object per calling operator. If there would be a central
mutex for all static initializations the code would run about 100s, but
it actually finishes after one second.

Re: Thread-safe initialization of static objects

<uebn7l$293m3$3@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=1610&group=comp.lang.c%2B%2B#1610

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Bonita.Montero@gmail.com (Bonita Montero)
Newsgroups: comp.lang.c++
Subject: Re: Thread-safe initialization of static objects
Date: Tue, 19 Sep 2023 10:47:49 +0200
Organization: A noiseless patient Spider
Lines: 17
Message-ID: <uebn7l$293m3$3@dont-email.me>
References: <udafjf$2joeq$1@dont-email.me> <udoico$1d0tr$1@dont-email.me>
<udotj5$1e8do$2@dont-email.me> <udpbun$1gf8c$1@dont-email.me>
<udqatg$1mar3$1@dont-email.me> <udqbg3$1mdv6$1@dont-email.me>
<udqq8u$1p3q6$1@dont-email.me> <uds0qa$22qfj$1@dont-email.me>
<udtg9s$2aqb5$1@dont-email.me> <uduimg$2imqi$1@dont-email.me>
<FUEMM.7469$ZkX3.6739@fx09.iad> <ue3bhh$3l4s1$1@dont-email.me>
<ue3nga$3ms5s$1@dont-email.me> <eohNM.4832$3lL1.1360@fx47.iad>
<ue4cqe$3rjfr$1@dont-email.me> <LwlNM.50924$QShe.20423@fx11.iad>
<ue4p5v$3truj$1@dont-email.me> <EjoNM.17221$DXgc.9861@fx36.iad>
<ue5tfc$7pns$1@dont-email.me> <zPGNM.14021$BMnd.11871@fx04.iad>
<ue7f6g$frod$2@dont-email.me> <ue7gdm$fumm$4@dont-email.me>
<ue7hc3$g7tm$1@dont-email.me> <ue7r4j$i3u1$1@dont-email.me>
<ue8mid$q534$2@dont-email.me> <O9XNM.16067$JX2f.12159@fx13.iad>
<20230918110147.326@kylheku.com> <uea42g$1sn0e$2@dont-email.me>
<20230918123203.723@kylheku.com> <ueb3q5$2638l$5@dont-email.me>
<20230918205859.263@kylheku.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 19 Sep 2023 08:47:49 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="85b9ebaf81ad877fb9605894b3bc8446";
logging-data="2395843"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+ZDgv/Bxa73mbd6dj08uIXk29/Sw+oDBY="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:3cHFePnBUCDpdiIdbeK8g1UnB9g=
Content-Language: de-DE
In-Reply-To: <20230918205859.263@kylheku.com>
 by: Bonita Montero - Tue, 19 Sep 2023 08:47 UTC

Am 19.09.2023 um 06:05 schrieb Kaz Kylheku:

> You /seemed/ to be claiming that such an arrangement cannot deadlock.
> Whether or not, I'm showing above how it can.
> 1. One static initialization can be nested inside another,
> such that the calling thread momentarily owns both mutexes.

Then two mutexes are used.

> 3. Thus, two threads can nest the same pair of initializations
> in opposite order.

If multiple mutexes are used that's actually not a problem.
And as I've shown there's a mutex per static initialization.

Rest unread.

Re: Thread-safe initialization of static objects

<uebnaa$293m3$4@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=1611&group=comp.lang.c%2B%2B#1611

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Bonita.Montero@gmail.com (Bonita Montero)
Newsgroups: comp.lang.c++
Subject: Re: Thread-safe initialization of static objects
Date: Tue, 19 Sep 2023 10:49:15 +0200
Organization: A noiseless patient Spider
Lines: 9
Message-ID: <uebnaa$293m3$4@dont-email.me>
References: <udafjf$2joeq$1@dont-email.me> <udotj5$1e8do$2@dont-email.me>
<udpbun$1gf8c$1@dont-email.me> <udqatg$1mar3$1@dont-email.me>
<udqbg3$1mdv6$1@dont-email.me> <udqq8u$1p3q6$1@dont-email.me>
<uds0qa$22qfj$1@dont-email.me> <udtg9s$2aqb5$1@dont-email.me>
<uduimg$2imqi$1@dont-email.me> <FUEMM.7469$ZkX3.6739@fx09.iad>
<ue3bhh$3l4s1$1@dont-email.me> <ue3nga$3ms5s$1@dont-email.me>
<eohNM.4832$3lL1.1360@fx47.iad> <ue4cqe$3rjfr$1@dont-email.me>
<LwlNM.50924$QShe.20423@fx11.iad> <ue4p5v$3truj$1@dont-email.me>
<EjoNM.17221$DXgc.9861@fx36.iad> <ue5tfc$7pns$1@dont-email.me>
<zPGNM.14021$BMnd.11871@fx04.iad> <ue7f6g$frod$2@dont-email.me>
<ue7gdm$fumm$4@dont-email.me> <ue7hc3$g7tm$1@dont-email.me>
<ue7r4j$i3u1$1@dont-email.me> <ue8mid$q534$2@dont-email.me>
<O9XNM.16067$JX2f.12159@fx13.iad> <20230918110147.326@kylheku.com>
<uea42g$1sn0e$2@dont-email.me> <20230918123203.723@kylheku.com>
<ueb3q5$2638l$5@dont-email.me> <20230918205859.263@kylheku.com>
<uebact$271en$6@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 19 Sep 2023 08:49:14 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="85b9ebaf81ad877fb9605894b3bc8446";
logging-data="2395843"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/VaiZOJSvCYL3N6EVUZ4lSeUDt37QmIXE="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:sWt8eRhJMgUPKlURnOzCILJ9rY8=
Content-Language: de-DE
In-Reply-To: <uebact$271en$6@dont-email.me>
 by: Bonita Montero - Tue, 19 Sep 2023 08:49 UTC

Am 19.09.2023 um 07:08 schrieb Chris M. Thomasson:

> If the impl can deadlock wrt satic init, then we might as well take an
> infinite walk off a very short peer.

If one object depens on an initialization of another before there's
no dependent locking. If one static inizialization is nested inside
another there's also no dependent locking since the nested object
has its own mutex.


devel / comp.lang.c++ / Re: Thread-safe initialization of static objects

Pages:123456789101112131415161718192021222324252627
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor