Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

"Never face facts; if you do, you'll never get up in the morning." -- Marlo Thomas


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

<aJINM.23275$H8td.10140@fx10.iad>

  copy mid

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

  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!fx10.iad.POSTED!not-for-mail
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
Subject: Re: Thread-safe initialization of static objects
Content-Language: en-US
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> <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>
From: Rich...@Damon-Family.org (Richard Damon)
In-Reply-To: <ue7k2n$gmqv$1@dont-email.me>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Lines: 22
Message-ID: <aJINM.23275$H8td.10140@fx10.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: Sun, 17 Sep 2023 15:47:18 -0400
X-Received-Bytes: 2520
 by: Richard Damon - Sun, 17 Sep 2023 19:47 UTC

On 9/17/23 3:29 PM, Bonita Montero wrote:
> Am 17.09.2023 um 21:20 schrieb Kaz Kylheku:
>
>> Locking a page is just a state change, not a resource allocation.
>
> That's a completely different discussion. The standard should not
> be based on individual implementations, but should allow for the
> possibility that the failure of synchronization or the synchroni-
> zation itself fails. The standard also provides for this with a
> std::mutex, why not for the initialization of statically local
> objects ?
>
> Rest unread.
>

Why does it need to take into account that an BAD implementation might fail.

Since it HAS been shown that you can do the operation correctly without
failure, then allowing failure is just pandering to bad implementations.

The Standard is written so it is useful for programmers, and achievable
by implementations.

Re: Thread-safe initialization of static objects

<20230917124810.497@kylheku.com>

  copy mid

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

  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-...@kylheku.com (Kaz Kylheku)
Newsgroups: comp.lang.c++
Subject: Re: Thread-safe initialization of static objects
Date: Sun, 17 Sep 2023 19:49:33 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 19
Message-ID: <20230917124810.497@kylheku.com>
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> <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>
Injection-Date: Sun, 17 Sep 2023 19:49:33 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="5639c8ba62cd0d10bf2c7b8f7812f3b5";
logging-data="555249"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18ocWIwOvJOlFMtoY10uSTCHrw3mONIfpU="
User-Agent: slrn/pre1.0.4-9 (Linux)
Cancel-Lock: sha1:wFCo48P+0OwSXlOx9mHM8z8+F0g=
 by: Kaz Kylheku - Sun, 17 Sep 2023 19:49 UTC

On 2023-09-17, Bonita Montero <Bonita.Montero@gmail.com> wrote:
> Am 17.09.2023 um 21:20 schrieb Kaz Kylheku:
>
>> Locking a page is just a state change, not a resource allocation.
>
> That's a completely different discussion.

It's one that you started where you made false claims that futex
operations have to acquire resources, such as wait queues, which can
fail.

I spent about two minutes of looking at kernel source to trivially
discover that it's false.

--
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

<gMINM.23276$H8td.1261@fx10.iad>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!usenet.goja.nl.eu.org!3.eu.feeder.erje.net!feeder.erje.net!newsreader4.netcologne.de!news.netcologne.de!peer03.ams1!peer.ams1.xlned.com!news.xlned.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx10.iad.POSTED!not-for-mail
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
Subject: Re: Thread-safe initialization of static objects
Content-Language: en-US
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> <DjENM.51886$8XGa.26896@fx17.iad>
<ue77ul$eiv3$1@dont-email.me> <8SGNM.4844$3lL1.4797@fx47.iad>
<ue7f3i$frod$1@dont-email.me> <20230917112958.807@kylheku.com>
<ue7hsb$g7tm$5@dont-email.me>
From: Rich...@Damon-Family.org (Richard Damon)
In-Reply-To: <ue7hsb$g7tm$5@dont-email.me>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Lines: 25
Message-ID: <gMINM.23276$H8td.1261@fx10.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: Sun, 17 Sep 2023 15:50:36 -0400
X-Received-Bytes: 2623
 by: Richard Damon - Sun, 17 Sep 2023 19:50 UTC

On 9/17/23 2:51 PM, Bonita Montero wrote:
> Am 17.09.2023 um 20:49 schrieb Kaz Kylheku:
>
>> When mutexes fail, it is due to bugs in the application.  In that case,
>> if that happens at global init time, the program can just abort.
>
> C++ mutexes always have a delayed initialitation since the constructor
> is noexcept. So the semaphore behind the mutex which backs contention
> is created on synchonzation, which may fail.
>
>> In POSIX, ..
>
> It doesn't matter what a specific operating system says about that,
> the standard should honour a failure in this case, even more if you
> have deferred initialization with C++ mutexes.
>
> Rest unread.
>

So, you say that it doesn't matter what a specific operating system
says, except then you think it should.

Make up your mind.

Re: Thread-safe initialization of static objects

<ue7lnd$h1b4$1@dont-email.me>

  copy mid

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

  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....@gmail.com (Chris M. Thomasson)
Newsgroups: comp.lang.c++
Subject: Re: Thread-safe initialization of static objects
Date: Sun, 17 Sep 2023 12:57:32 -0700
Organization: A noiseless patient Spider
Lines: 25
Message-ID: <ue7lnd$h1b4$1@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> <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>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 17 Sep 2023 19:57:33 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="6b320f169d519ca75c05ccb6aa9b5206";
logging-data="558436"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19R6niAy8XzmB0OnLAlAwsqbc02lD9hxNA="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.15.1
Cancel-Lock: sha1:wcHZhx6eNxqzrZDaJavlS+rzGmM=
Content-Language: en-US
In-Reply-To: <ue7j3g$ggh4$1@dont-email.me>
 by: Chris M. Thomasson - Sun, 17 Sep 2023 19:57 UTC

On 9/17/2023 12:12 PM, Bonita Montero wrote:
> Am 17.09.2023 um 21:01 schrieb Chris M. Thomasson:
>
>> A slow-path in a synchronization algorithm can cause it to choose to
>> wait in the kernel, ...
>
> Futexes are a substitute for a semaphore, which in turn is a part of
> a mutex.

Yawn.

> There must be a way to get a thread sleeping when there's
> contention. So there must be kernel-support of a futex.
> If you say that everything on that futex happens in userspace this
> does just mean that there's no explicit kernel call from userspace,
> but the kernel-transition is done through a MMU-trap, wich is usually
> faster on most CPUs than a explicit kernel call.
>
>> No. Bonita. You need to study up.
>
> I've read the paper, you didn't understand or you didn't read it.
>

I still don't think you know how they work.

Re: Thread-safe initialization of static objects

<LWINM.13017$ZkX3.12109@fx09.iad>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx09.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>
From: pauldont...@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: <ue7f6g$frod$2@dont-email.me>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Lines: 18
Message-ID: <LWINM.13017$ZkX3.12109@fx09.iad>
X-Complaints-To: https://www.astraweb.com/aup
NNTP-Posting-Date: Sun, 17 Sep 2023 20:01:47 UTC
Date: Sun, 17 Sep 2023 16:01:47 -0400
X-Received-Bytes: 2224
 by: Pavel - Sun, 17 Sep 2023 20:01 UTC

Bonita Montero wrote:
> Am 17.09.2023 um 19:37 schrieb Pavel:
>
>> Bonita Montero wrote:
>>> As I've shown with my program MSVC, libstdc++ (g++) and libc++ (clang++)
>>> have per object mutexes.
>
>> No your program does not show this. ...
>
> Of course I show this. I've got a generic lambda and each thread
> gets its own instantiation of the calling operator of that lambda,
> thereby having _individual_ static objects per calling operator.
>
Of course you don't show that the synchronization primitives that are
used for static initialization are mutexes.

And of course you don't show that the synchronization primitives are
used in a way that they may fail.

Re: Thread-safe initialization of static objects

<ue7m0i$h1b4$2@dont-email.me>

  copy mid

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

  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....@gmail.com (Chris M. Thomasson)
Newsgroups: comp.lang.c++
Subject: Re: Thread-safe initialization of static objects
Date: Sun, 17 Sep 2023 13:02:25 -0700
Organization: A noiseless patient Spider
Lines: 42
Message-ID: <ue7m0i$h1b4$2@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> <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>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 17 Sep 2023 20:02:26 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="6b320f169d519ca75c05ccb6aa9b5206";
logging-data="558436"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+vQ4eOW5IDOiN7dojqLdlJ2GFfcKKW3Xw="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.15.1
Cancel-Lock: sha1:VVQ9weeY4mHQyHAGsVimvv2Wvbs=
Content-Language: en-US
In-Reply-To: <20230917121015.206@kylheku.com>
 by: Chris M. Thomasson - Sun, 17 Sep 2023 20:02 UTC

On 9/17/2023 12:20 PM, Kaz Kylheku wrote:
> On 2023-09-17, Bonita Montero <Bonita.Montero@gmail.com> wrote:
>> Am 17.09.2023 um 20:25 schrieb Chris M. Thomasson:
>>
>>> Getting WAIT_FAILED means something really bad has hit the fan.
>>> WAIT_ABANDONED is fine and can be handled, akin to EOWNERDEAD.
>>> This is for inter-process robust sync.
>>
>> It's unspecified why this happens.
>>
>>> A futex does not need to create new kernel resources on demand.
>>> They are already there.
>>
>> Read the Linux futex paper. The page which holds the futex is locked
>> and there's a wating queue for contenders inside the kernel.
>
> Locking a page is just a state change, not a resource allocation.
>
> Waiting on wait queues doesn't require external resources; Linux wait
> queue nodes are allocated and initialized on the stack. The enqueueing
> and dequeueing is just pointer operations.
>
> Wait queues themselves have to be allocated somewhere. The Linux futex
> subsystem pre-allocated a big hash table containing queues. A futex
> is hashed and then arbitrarily mapped to a queue which already exists.
> The operation does not fail; there is no error checking or handling in
> that code path at all. The futex hash allows unrelated futexes to map to
> the same wait queue. That means that when a futex is woken up, tasks
> waiting for a different futex may be woken as a side effect.
>
> A page which holds a futex might be initially not present and have
> to be swapped in. That's a resource allocation that can fail due to OOM.
> However, that threat exists for any not-present page in an overcommitted
> VM system; it's not a futex problem. You can malloc a block of memory,
> get a non-null pointer, only to have it fail on access later.
>

Afaict, and iirc, you are right on par here. Thanks. :^)

Iirc, a futex tends to broadcast to get around hash collisions. Thus the
user algorithm must be based on a predicate that it can loop around and
check _before_ it decides to wait again in the kernel via futex.

Re: Thread-safe initialization of static objects

<z3JNM.67165$hmAd.42882@fx12.iad>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!newsreader4.netcologne.de!news.netcologne.de!peer02.ams1!peer.ams1.xlned.com!news.xlned.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx12.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> <oHHNM.23271$H8td.1529@fx10.iad>
<ue7hnl$g7tm$4@dont-email.me>
From: pauldont...@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: <ue7hnl$g7tm$4@dont-email.me>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Lines: 33
Message-ID: <z3JNM.67165$hmAd.42882@fx12.iad>
X-Complaints-To: https://www.astraweb.com/aup
NNTP-Posting-Date: Sun, 17 Sep 2023 20:11:11 UTC
Date: Sun, 17 Sep 2023 16:11:10 -0400
X-Received-Bytes: 2961
 by: Pavel - Sun, 17 Sep 2023 20:11 UTC

Bonita Montero wrote:
> Am 17.09.2023 um 20:37 schrieb Richard Damon:
>
>> You haven't actually looked at HOW the code actually does what it
>> does, so you haven't shown anything (except your own limitations in
>> understanding code).
>
> I don't need to check that. I've proven that each static local
> object has its own initialization and not a shared mutex because
> the code runs exactly one second.
so far so good

> So if you have an indivivual
> mutex
how do your result show that this was a mutex?

> per static local object this synchronization may fail.
Even if it were a mutex (which you did not prove) if it is a statically
constant-initialized individual mutex, why would it fail?

> A pre-allocated global mutex for all static local initialization
> may not fail,
And in exactly same way, an individual per-static variable mutex does
not have to have code path to fail.

> but the standard should honour platforms where
> this actually can happen.
The standard does not have to honor any platform. Many platforms cannot
fully implement C++ standard; it is not the standard's fault (and often
not the platform's fault if the platform does not need the full
implementation or it would come at unreasonable cost).

Re: Thread-safe initialization of static objects

<ue7n7p$hc5g$1@dont-email.me>

  copy mid

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

  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....@gmail.com (Chris M. Thomasson)
Newsgroups: comp.lang.c++
Subject: Re: Thread-safe initialization of static objects
Date: Sun, 17 Sep 2023 13:23:18 -0700
Organization: A noiseless patient Spider
Lines: 47
Message-ID: <ue7n7p$hc5g$1@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> <EjoNM.17221$DXgc.9861@fx36.iad>
<ue5tfc$7pns$1@dont-email.me> <DjENM.51886$8XGa.26896@fx17.iad>
<ue77ul$eiv3$1@dont-email.me> <8SGNM.4844$3lL1.4797@fx47.iad>
<ue7f3i$frod$1@dont-email.me> <20230917112958.807@kylheku.com>
<ue7hsb$g7tm$5@dont-email.me> <ue7hvn$gach$3@dont-email.me>
<ue7ib9$gcfr$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Sun, 17 Sep 2023 20:23:21 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="6b320f169d519ca75c05ccb6aa9b5206";
logging-data="569520"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/TCEwNUDuSDBcVXCJF9xlRvOKbrxYBrsM="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.15.1
Cancel-Lock: sha1:n0OrVLMf8ZMo8dRdRjM6KA92k/I=
Content-Language: en-US
In-Reply-To: <ue7ib9$gcfr$1@dont-email.me>
 by: Chris M. Thomasson - Sun, 17 Sep 2023 20:23 UTC

On 9/17/2023 11:59 AM, Bonita Montero wrote:
> Am 17.09.2023 um 20:53 schrieb Chris M. Thomasson:
>> On 9/17/2023 11:51 AM, Bonita Montero wrote:
>>> Am 17.09.2023 um 20:49 schrieb Kaz Kylheku:
>>>
>>>> When mutexes fail, it is due to bugs in the application.  In that case,
>>>> if that happens at global init time, the program can just abort.
>>>
>>> C++ mutexes always have a delayed initialitation since the constructor
>>> is noexcept. So the semaphore behind the mutex which backs contention
>>> is created on synchonzation, which may fail.
>>
>> Wtf are you rambling on about!
>
> You alleged me to not understand futexes and you don't understand
> that yourself.

I only wrote that I think you are totally misunderstanding (or have a
rather _limited_ experience with them, Bonita) futexes because I read
what _you_ wrote here in this thread. See?

For some damn reason, you seem to think that A must be implemented in
the way _you_ think it should be. Then _you_ proclaim that as the "only
one way", so to speak. Strange to me. Anyway... You need to learn more
about futexes, the difference between a fast-path and a slow-path,
basically, synchronization in general...

You code attacking a straw man is cruel to all scarecrows. ;^o

> Ask yourself how a mutex handles contention so that
> a thread sleeps while another is processing.

I personally consider contention to be a so-called slow-path. A mutex
can try to spin a couple times on its atomic predicate to see if it can
successfully lock _before_ actually waiting in the kernel... If it spins
a couples times and acquires the mutex, well, it just avoided a kernel
call! Good. Adaptive mutexes are a tradeoff wrt their spin count
thresholds, another story in and of itself... Anyway, if it (a contended
mutex) failed enough times, it can finally decide to wait on a futex, a
binary semaphore, ect...

I have implemented many different ways that a mutex can be created. A
fun one uses a bakery algorithm and is 100% loop free in its logic.

Bonita, you need to study up.

Re: Thread-safe initialization of static objects

<ue7phh$hmk6$1@dont-email.me>

  copy mid

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

  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....@gmail.com (Chris M. Thomasson)
Newsgroups: comp.lang.c++
Subject: Re: Thread-safe initialization of static objects
Date: Sun, 17 Sep 2023 14:02:40 -0700
Organization: A noiseless patient Spider
Lines: 187
Message-ID: <ue7phh$hmk6$1@dont-email.me>
References: <udafjf$2joeq$1@dont-email.me> <1h7KM.66324$Wk53.59929@fx01.iad>
<udbe19$2rk0p$2@dont-email.me> <2acKM.719164$U3w1.269152@fx09.iad>
<udbjfo$2s7cn$1@dont-email.me> <RllKM.1028889$SuUf.692033@fx14.iad>
<udcubm$325k4$1@dont-email.me> <wguKM.698884$xMqa.357246@fx12.iad>
<udebu2$3bknb$1@dont-email.me> <X5KKM.218705$ftCb.30173@fx34.iad>
<udgpnl$3tuni$1@dont-email.me> <udi0vu$488m$1@dont-email.me>
<udi9s5$5f8c$1@dont-email.me> <q82LM.1449511$GMN3.1347862@fx16.iad>
<udig8l$6ddc$1@dont-email.me> <zI4LM.170544$uEkc.45136@fx35.iad>
<udk0do$h1e9$1@dont-email.me> <hRjLM.1455228$GMN3.816986@fx16.iad>
<fLrLM.1141591$mPI2.986632@fx15.iad> <udm5rf$u6g6$1@dont-email.me>
<VlRLM.1202$HpPd.216@fx03.iad>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Sun, 17 Sep 2023 21:02:42 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="6b320f169d519ca75c05ccb6aa9b5206";
logging-data="580230"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/gicjKdupIy8jLb88VO0F+56zOHJ9QOtA="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.15.1
Cancel-Lock: sha1:ayaFo+Gkr1A8XwlD4HNrRn29G/4=
Content-Language: en-US
In-Reply-To: <VlRLM.1202$HpPd.216@fx03.iad>
 by: Chris M. Thomasson - Sun, 17 Sep 2023 21:02 UTC

On 9/11/2023 8:58 PM, Pavel wrote:
> Chris M. Thomasson wrote:
>> On 9/10/2023 3:50 PM, Pavel wrote:
>>> Richard Damon wrote:
>>>> On 9/10/23 1:57 AM, Bonita Montero wrote:
>>>>> Am 09.09.2023 um 22:37 schrieb Richard Damon:
>>>>>
>>>>>> The Standard defines the final results that must happen
>>>>>> (or possibilities that can happen in some cases).
>>>>>
>>>>> The standards also should consider side effects as in this example
>>>>> when a static initialization would fail because of a synchronization
>>>>> error.
>>>>>
>>>> You don't seem to understand that sincd it CAN be done in a way that
>>>> always works, any method that doesn't always work is just WRONG and
>>>> non-conforming.
>>>>
>>>> I guess you think that 1 + 1 must be allowed to be 1 in case of
>>>> "synchronization errors".
>>>>
>>>> Static Initialization has DEFINED behavior, and that behavior must
>>>> be honored, and the implementation do what is need to make that happen.
>>>>
>>>> Methods have been shown to do it (perhaps less performant than this
>>>> is some conditions),
>>> Actually, I think there should be always a better-performing method
>>> to implement C++ static initialization than using windows or pthread
>>> mutex -- e.g. using a specialized control like those used for
>>> call_once implementation -- at least on UNIX or Windows.
>>>
>>> This is because IMHO mutex API is a textbook case of feature bloat on
>>> both platforms.
>>>
>>> E.g. in standard UNIX (former POSIX), you can have recursive / robust
>>> / shared / errorcheck mutex (not all mutually exclusive) and who
>>> knows what else. pthread_mutex_lock shall be able to deal with either
>>> combination and the feature-check code makes (at least the current)
>>> implementation quite messy, with multiple dispatches on the same
>>> condition.
>>>
>>> On Windows, the number of options is less; but, to compensate for
>>> that :-), a mutex is always recursive plus wait functions have to
>>> know how to deal with inter-process mutexes because any handle passed
>>> to them can turn out to be of an inter-process mutex (or even not a
>>> mutex at all). Therefore, I do not think their use for static
>>> initialization (that does not require either recursive or
>>> inter-process lock) even could be optimal.
>>
>> I might be missing your point here. Humm... Even though POSIX has all
>> of these different types of mutexs, we can use them by organization.
> The point is that, even assuming that all types of mutices are very well
> organized in the implementation, some dispatch of control still has to
> occur when one calls "pthread_mutex_lock" because it is a single entry
> point for locking a mutex with any combination of features. Given that
> locking of a non-contended mutex is supposed to be (and in fact is, on
> current Linux) very cheap (but not necessarily same-cheap if the mutex
> is recursive :-) ), the relative cost of this dispatch is not guaranteed
> to be negligible (even if that dispatch is implemented via a single
> extra level of indirection).
>
> Further, I am unsure if these features actually *can* be very well
> organized because not all features of mutices are mutually exclusive (no
> pun intended) so a single extra level of indirection might not be enugh.
> As an example, mutexattr type can be one of
>
>  PTHREAD_MUTEX_NORMAL PTHREAD_MUTEX_ERRORCHECK PTHREAD_MUTEX_RECURSIVE
> PTHREAD_MUTEX_DEFAULT

Yeah. It's up to us programmers to make sure everything is right on our
end. What about:

intra_process_mutex_recursive m_mutex_recurive;

I find that a more descriptive name can help wrt reading code created by
somebody else. Humm... Actaly, I do not like to use recursive mutexes
very much (if at all) because I have had to debug some other peoples
"nightmare" code that recursed, and caused a deadlock around four locks
deep.... It technically was not the fault of the recursion ability, but
it was an error on the programmers side. The name of the lock was
something like (object.m_lock), it was vague and I did not even know it
recursed until I took a deeper look at the damn "nightmare" code. So,
iirc, I said out loud, name it something else... How about:

object.m_lock_recusive__never__use__

and got a laugh from the room. :^)

>
> but each of these can be additionally either robust or non-robust (and,
> pthread_mutex_lock is supposed to behave differently for some
> combinations of type and robustness). Unless of course we dispatch to a
> cartesian product of options (which is not impossible, but see below).
>
> And, lastly, the above are all hypotheticals and the actual code (see
> e.g. https://codebrowser.dev/glibc/glibc/nptl/pthread_mutex_lock.c.html
> ) is slightly messier than the best organized implementation possible.
> From practical perspective, I would expect that someone implementing a
> thread-safe static initialization in a C++ compiler has their mouth full
> with the tasks other than improving the existing pthread_mutex (or
> pthread_once) implementation as a distraction; at most (I would
> speculate), they would take a quick (~5 min) look into the API and the
> available code of the existing established synchronization primitives
> and decide which one is likely to better fit their spec and be faster
> as-is to use to implement that pesky initialization spec. In this
> scenario, I would guess that pthread_once_t would win the beauty contest
> and get selected.
>
> And, sure enough, (likely due to no feature bloat) the *existing*
> pthread_once implementation code is much cleaner (see
> https://codebrowser.dev/glibc/glibc/nptl/pthread_once.c.html) and at
> first glance should be measurably faster.
>
> I guess, instead of guessing, (no pun untended again), we could just
> disassemble some static initialization and see how it's done in, say,
> gcc. Maybe later...
>
>> So, wrt windows, an intra-process mutex can be a CRITICAL_SECTION. Or
>> an inter-process as a mutex HANDLE.
>>
>> https://learn.microsoft.com/en-us/windows/win32/api/synchapi/nf-synchapi-createmutexexa
>>
>> Wrt the inter-process route we may need to deal with WAIT_ABANDONED,
>> or EOWNERDEAD wrt POSIX. So we create different types:
>>
>>
>> struct intra_process_mutex
>> {
>>      CRITICAL_SECTION m_os_lock;
>> };
>>
>>
>> struct inter_process_mutex
>> {
>>      HANDLE m_os_lock;
>> };
>>
>> struct inter_process_mutex_robust
>> {
>>      HANDLE m_os_lock;
>> };
>>
>>
>>
>> These simple types can be rather easy to reason about. Wrt POSIX, the
>> different types would be:
>>
>>
>> struct intra_process_mutex
>> {
>>      pthread_mutex_t m_os_lock;
>> };
>>
>>
>> struct inter_process_mutex
>> {
>>      pthread_mutex_t m_os_lock;
>> };
>>
>> struct inter_process_mutex_robust
>> {
>>      pthread_mutex_t m_os_lock;
>> };
>>
>>
>> The point is trying to organize things a bit here.
>>
>> Sound somewhat decent?
>>
>>
>>>
>>>> so it is possible, so you can't say the Standard is asking for
>>>> impossible behavior, thus any "optimizations" that don't meet that
>>>> defined behavior are just WRONG.
>>>>
>>>> Saying something wrong must be made right is just WRONG, so you are
>>>> WRONG in your claim.
>>>>
>>>> PERIOD.
>>>
>>
>

Re: Thread-safe initialization of static objects

<ue7r4j$i3u1$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: eesn...@osa.pri.ee (Paavo Helde)
Newsgroups: comp.lang.c++
Subject: Re: Thread-safe initialization of static objects
Date: Mon, 18 Sep 2023 00:29:55 +0300
Organization: A noiseless patient Spider
Lines: 23
Message-ID: <ue7r4j$i3u1$1@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> <ue7gdm$fumm$4@dont-email.me>
<ue7hc3$g7tm$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 17 Sep 2023 21:29:55 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="dc03e5ec78c271b818d291e5d0205a96";
logging-data="593857"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX180WU3fJRxEMUHTXttFGR5jGdfTb12guQA="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:z8ljrh3l4xtWRBbaHfbbGo7Kc9c=
In-Reply-To: <ue7hc3$g7tm$1@dont-email.me>
Content-Language: en-US
 by: Paavo Helde - Sun, 17 Sep 2023 21:29 UTC

17.09.2023 21:43 Bonita Montero kirjutas:

[...]

> The calling operator of the theads's function object is generic
> and instantited once per T. So the static is object is individual
> per each instantiation of the calling operator. The above code
> takes about one second with MSVC, g++ (libstdc++) and clan++
> (libc++), so there's an individual mutex per calling operator
> of the above lambda.

Studying the actual code shows MSVC is using a critical section and
libstc++ is using a futex. These are both single-process only facilities
which cannot fail in a way an inter-process fully-kernel mutex could
fail. Moreover, as the C++ standard does not allow the static
initialization to fail for synchronization reasons, a conforming
implementation could not use a general mutex anyway because it could fail.

I guess that's a big part of why the implementations are using the
mechanisms they are using, and these are not general mutexes.

Re: Thread-safe initialization of static objects

<ue8lpq$q25a$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Bonita.M...@gmail.com (Bonita Montero)
Newsgroups: comp.lang.c++
Subject: Re: Thread-safe initialization of static objects
Date: Mon, 18 Sep 2023 07:05:00 +0200
Organization: A noiseless patient Spider
Lines: 6
Message-ID: <ue8lpq$q25a$1@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> <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>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 18 Sep 2023 05:04:58 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="1faee559a96e8a282152d3a155665a0a";
logging-data="854186"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18IdYTacPtZ8xIgUUhssYA2/jWTfY3enWg="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:s0S23V5AxxuAJd/I9l5kUorUNrI=
Content-Language: de-DE
In-Reply-To: <ue7lnd$h1b4$1@dont-email.me>
 by: Bonita Montero - Mon, 18 Sep 2023 05:05 UTC

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.

Re: Thread-safe initialization of static objects

<ue8lst$q25a$2@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Bonita.M...@gmail.com (Bonita Montero)
Newsgroups: comp.lang.c++
Subject: Re: Thread-safe initialization of static objects
Date: Mon, 18 Sep 2023 07:06:38 +0200
Organization: A noiseless patient Spider
Lines: 9
Message-ID: <ue8lst$q25a$2@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> <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>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 18 Sep 2023 05:06:37 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="1faee559a96e8a282152d3a155665a0a";
logging-data="854186"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/G9HFjIE20wJF0FiyGbJ4BJHzgr7g2TB4="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:Z+/uEb9BS5ebxwj/pTOR7+shA6M=
In-Reply-To: <20230917123203.524@kylheku.com>
Content-Language: de-DE
 by: Bonita Montero - Mon, 18 Sep 2023 05:06 UTC

Am 17.09.2023 um 21:36 schrieb Kaz Kylheku:

> No it shouldn't. Synchronization that fails for reasons other than
> a bug in the program (deadlock, unlocking un-owned mutex, recursively
> acquiring non-recursive mutex, ...) is a wrongheaded idea, ...

And why could a mutex throw a system_error on synchonization.
According to what you say everything could be noexcept.

Re: Thread-safe initialization of static objects

<ue8lv5$q25a$3@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Bonita.M...@gmail.com (Bonita Montero)
Newsgroups: comp.lang.c++
Subject: Re: Thread-safe initialization of static objects
Date: Mon, 18 Sep 2023 07:07:50 +0200
Organization: A noiseless patient Spider
Lines: 7
Message-ID: <ue8lv5$q25a$3@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> <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>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 18 Sep 2023 05:07:49 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="1faee559a96e8a282152d3a155665a0a";
logging-data="854186"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+hSmBlj3tAL93OyvIu8aQy65JC3BAPegI="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:jIQck2I4aOGyE1I9hzqjCUIrf2s=
In-Reply-To: <aJINM.23275$H8td.10140@fx10.iad>
Content-Language: de-DE
 by: Bonita Montero - Mon, 18 Sep 2023 05:07 UTC

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.

Re: Thread-safe initialization of static objects

<ue8m2d$q25a$4@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Bonita.M...@gmail.com (Bonita Montero)
Newsgroups: comp.lang.c++
Subject: Re: Thread-safe initialization of static objects
Date: Mon, 18 Sep 2023 07:09:34 +0200
Organization: A noiseless patient Spider
Lines: 6
Message-ID: <ue8m2d$q25a$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>
<DjENM.51886$8XGa.26896@fx17.iad> <ue77ul$eiv3$1@dont-email.me>
<8SGNM.4844$3lL1.4797@fx47.iad> <ue7f3i$frod$1@dont-email.me>
<20230917112958.807@kylheku.com> <ue7hsb$g7tm$5@dont-email.me>
<ue7hvn$gach$3@dont-email.me> <ue7ib9$gcfr$1@dont-email.me>
<ue7n7p$hc5g$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 18 Sep 2023 05:09:33 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="1faee559a96e8a282152d3a155665a0a";
logging-data="854186"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19h2kRwbupY3Cnqo9gixvnB2gEuXjOfDUc="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:u0eILRJ0hSEuzvcxQh0OskmH4W4=
Content-Language: de-DE
In-Reply-To: <ue7n7p$hc5g$1@dont-email.me>
 by: Bonita Montero - Mon, 18 Sep 2023 05:09 UTC

Am 17.09.2023 um 22:23 schrieb Chris M. Thomasson:

> I personally consider contention to be a so-called slow-path. ...

The futex part is to make the slow path faster.

Re: Thread-safe initialization of static objects

<ue8mff$q534$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Bonita.M...@gmail.com (Bonita Montero)
Newsgroups: comp.lang.c++
Subject: Re: Thread-safe initialization of static objects
Date: Mon, 18 Sep 2023 07:16:32 +0200
Organization: A noiseless patient Spider
Lines: 9
Message-ID: <ue8mff$q534$1@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> <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> <20230917124810.497@kylheku.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 18 Sep 2023 05:16:31 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="1faee559a96e8a282152d3a155665a0a";
logging-data="857188"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+rC2ILeVkYektMdvfI0yF2tzI4PTuqNZk="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:iZsakewI6UZ4mVSAm+6ZQCN+nws=
In-Reply-To: <20230917124810.497@kylheku.com>
Content-Language: de-DE
 by: Bonita Montero - Mon, 18 Sep 2023 05:16 UTC

Am 17.09.2023 um 21:49 schrieb Kaz Kylheku:

> It's one that you started ...

No, I didn't start it, Chris did. And at this point it was
no longer a question of whether synchronization could fail.

Rest unread.

Re: Thread-safe initialization of static objects

<ue8mid$q534$2@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Bonita.M...@gmail.com (Bonita Montero)
Newsgroups: comp.lang.c++
Subject: Re: Thread-safe initialization of static objects
Date: Mon, 18 Sep 2023 07:18:07 +0200
Organization: A noiseless patient Spider
Lines: 9
Message-ID: <ue8mid$q534$2@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> <ue7gdm$fumm$4@dont-email.me>
<ue7hc3$g7tm$1@dont-email.me> <ue7r4j$i3u1$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 18 Sep 2023 05:18:05 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="1faee559a96e8a282152d3a155665a0a";
logging-data="857188"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+jAg759SK89s/5p/8/H69E/IpzL4T7bt4="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:zPSvrQkq6FTe8tACmGai0u6D2oU=
Content-Language: de-DE
In-Reply-To: <ue7r4j$i3u1$1@dont-email.me>
 by: Bonita Montero - Mon, 18 Sep 2023 05:18 UTC

Am 17.09.2023 um 23:29 schrieb Paavo Helde:

> Studying the actual code shows MSVC is using a critical section and
> libstc++ is using a futex. These are both single-process only facilities
> which cannot fail in ...

Specific implementations don't matter because the point is that
C++ should honor implementations that can theoretically fail.

Re: Thread-safe initialization of static objects

<ue8mju$q534$3@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Bonita.M...@gmail.com (Bonita Montero)
Newsgroups: comp.lang.c++
Subject: Re: Thread-safe initialization of static objects
Date: Mon, 18 Sep 2023 07:18:55 +0200
Organization: A noiseless patient Spider
Lines: 6
Message-ID: <ue8mju$q534$3@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> <oHHNM.23271$H8td.1529@fx10.iad>
<ue7hnl$g7tm$4@dont-email.me> <kFINM.23274$H8td.18289@fx10.iad>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 18 Sep 2023 05:18:54 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="1faee559a96e8a282152d3a155665a0a";
logging-data="857188"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+Ahehr/TsVvnYT/nt27YbkU4LTyl18Mx4="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:YbR5OvlBxmbuxeD6LOBMOI/yA4Y=
Content-Language: de-DE
In-Reply-To: <kFINM.23274$H8td.18289@fx10.iad>
 by: Bonita Montero - Mon, 18 Sep 2023 05:18 UTC

Am 17.09.2023 um 21:43 schrieb Richard Damon:

> Nope, you shown that it can't be a single mutex held for the entire time
> of the constructor.

That's what I said.

Re: Thread-safe initialization of static objects

<ue8mn0$q534$4@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Bonita.M...@gmail.com (Bonita Montero)
Newsgroups: comp.lang.c++
Subject: Re: Thread-safe initialization of static objects
Date: Mon, 18 Sep 2023 07:20:34 +0200
Organization: A noiseless patient Spider
Lines: 9
Message-ID: <ue8mn0$q534$4@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>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 18 Sep 2023 05:20:32 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="1faee559a96e8a282152d3a155665a0a";
logging-data="857188"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+rzwI8d5qetDVUda/++KCPJ8tgvml+HZo="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:LnK2AmQdDpYJNlNcL9n4XP+VaR0=
Content-Language: de-DE
In-Reply-To: <LWINM.13017$ZkX3.12109@fx09.iad>
 by: Bonita Montero - Mon, 18 Sep 2023 05:20 UTC

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.

Re: Thread-safe initialization of static objects

<H7XNM.16066$JX2f.9443@fx13.iad>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx13.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> <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> <oHHNM.23271$H8td.1529@fx10.iad>
<ue7hnl$g7tm$4@dont-email.me> <kFINM.23274$H8td.18289@fx10.iad>
<ue8mju$q534$3@dont-email.me>
From: Rich...@Damon-Family.org (Richard Damon)
Content-Language: en-US
In-Reply-To: <ue8mju$q534$3@dont-email.me>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Lines: 18
Message-ID: <H7XNM.16066$JX2f.9443@fx13.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 08:11:19 -0400
X-Received-Bytes: 2296
 by: Richard Damon - Mon, 18 Sep 2023 12:11 UTC

On 9/18/23 1:18 AM, Bonita Montero wrote:
> Am 17.09.2023 um 21:43 schrieb Richard Damon:
>
>> Nope, you shown that it can't be a single mutex held for the entire
>> time of the constructor.
>
> That's what I said.

No, you said it was a Mutex per object, which is different than not a
single Mutex.

You are assuming is uses the object the OS is calling a "Mutex", which
is an object that works inter-process, but we don't need anything that
powerful.

So, the alternative to using a Windows Mutex is using something else.

Something which can't fail.

Re: Thread-safe initialization of static objects

<O9XNM.16067$JX2f.12159@fx13.iad>

  copy mid

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

  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!fx13.iad.POSTED!not-for-mail
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
Subject: Re: Thread-safe initialization of static objects
Content-Language: en-US
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> <ue7gdm$fumm$4@dont-email.me>
<ue7hc3$g7tm$1@dont-email.me> <ue7r4j$i3u1$1@dont-email.me>
<ue8mid$q534$2@dont-email.me>
From: Rich...@Damon-Family.org (Richard Damon)
In-Reply-To: <ue8mid$q534$2@dont-email.me>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Lines: 21
Message-ID: <O9XNM.16067$JX2f.12159@fx13.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 08:13:34 -0400
X-Received-Bytes: 2466
 by: Richard Damon - Mon, 18 Sep 2023 12:13 UTC

On 9/18/23 1:18 AM, Bonita Montero wrote:
> Am 17.09.2023 um 23:29 schrieb Paavo Helde:
>
>> Studying the actual code shows MSVC is using a critical section and
>> libstc++ is using a futex. These are both single-process only
>> facilities which cannot fail in ...
>
> Specific implementations don't matter because the point is that
> C++ should honor implementations that can theoretically fail.
>

Why?

Since it can be done without ever failing, why should the Standard allow
for failure.

I guess you think all programs must have Undefined Behavior, or that it
is ok for x = 1 + 1; to set x to 1.

You just are showing you are too ignorant of how to do things that your
mind is stuck on things that don't actually work.

Re: Thread-safe initialization of static objects

<ue9gao$1ousp$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Bonita.M...@gmail.com (Bonita Montero)
Newsgroups: comp.lang.c++
Subject: Re: Thread-safe initialization of static objects
Date: Mon, 18 Sep 2023 14:37:45 +0200
Organization: A noiseless patient Spider
Lines: 14
Message-ID: <ue9gao$1ousp$1@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>
<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>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 18 Sep 2023 12:37:44 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="1faee559a96e8a282152d3a155665a0a";
logging-data="1866649"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19cWHX8kB6detEcf5holE7d0MtOyaRnr00="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:LS/OFCIQ0wWQBmPNjMPmOAdPIsk=
In-Reply-To: <O9XNM.16067$JX2f.12159@fx13.iad>
Content-Language: de-DE
 by: Bonita Montero - Mon, 18 Sep 2023 12:37 UTC

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.

> 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.

Re: Thread-safe initialization of static objects

<ue9gq5$1ousp$2@dont-email.me>

  copy mid

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

  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: Bonita.M...@gmail.com (Bonita Montero)
Newsgroups: comp.lang.c++
Subject: Re: Thread-safe initialization of static objects
Date: Mon, 18 Sep 2023 14:45:59 +0200
Organization: A noiseless patient Spider
Lines: 29
Message-ID: <ue9gq5$1ousp$2@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>
<EjoNM.17221$DXgc.9861@fx36.iad> <ue5tfc$7pns$1@dont-email.me>
<zPGNM.14021$BMnd.11871@fx04.iad> <ue7f6g$frod$2@dont-email.me>
<oHHNM.23271$H8td.1529@fx10.iad> <ue7hnl$g7tm$4@dont-email.me>
<kFINM.23274$H8td.18289@fx10.iad> <ue8mju$q534$3@dont-email.me>
<H7XNM.16066$JX2f.9443@fx13.iad>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 18 Sep 2023 12:45:57 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="1faee559a96e8a282152d3a155665a0a";
logging-data="1866649"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19+m9Ll3vVp6K2J4rZWmq0PWsd6PtDEoVo="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:QfG/qOtuK1I5c145f0JP75PYyk8=
Content-Language: de-DE
In-Reply-To: <H7XNM.16066$JX2f.9443@fx13.iad>
 by: Bonita Montero - Mon, 18 Sep 2023 12:45 UTC

Am 18.09.2023 um 14:11 schrieb Richard Damon:

> You are assuming is uses the object the OS is calling a "Mutex", which
> is an object that works inter-process, but we don't need anything that
> powerful.

When I talk about a mutex in the context of C++, especially when
it comes to static initialization, it should be clear that I don't
mean mutexes that are "inter-process".

> So, the alternative to using a Windows Mutex is using something else.
> Something which can't fail.

At least the creation of the kernel resource for the slow path of
the mutex can fail. And under Windows even a WaitForSingleObject(),
which usually is used for the slow path, can fail for not entirely
specified reasons.

I had the same discussion on Stack Overflow and had the same objections,
but lastly the people with these objections saw that what I was saying
made sense. Here, however, there are only idiots.

I don't know what the fuss is about: if waiting for a std::mutex
can fail, the people who developed the standard figured that the
operating system part could fail. Accordingly, there is an exception
for std::mutex if you lock it. If you look at this consistently,
static initialization should also be able to throw an exception
for the same reason because the same kernel mechanisms are behind
it.

Re: Thread-safe initialization of static objects

<mBZNM.58210$8XGa.27400@fx17.iad>

  copy mid

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

  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!fx17.iad.POSTED!not-for-mail
X-newsreader: xrn 9.03-beta-14-64bit
Sender: scott@dragon.sl.home (Scott Lurndal)
From: sco...@slp53.sl.home (Scott Lurndal)
Reply-To: slp53@pacbell.net
Subject: Re: Thread-safe initialization of static objects
Newsgroups: comp.lang.c++
References: <udafjf$2joeq$1@dont-email.me> <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>
Lines: 15
Message-ID: <mBZNM.58210$8XGa.27400@fx17.iad>
X-Complaints-To: abuse@usenetserver.com
NNTP-Posting-Date: Mon, 18 Sep 2023 14:59:30 UTC
Organization: UsenetServer - www.usenetserver.com
Date: Mon, 18 Sep 2023 14:59:30 GMT
X-Received-Bytes: 1665
 by: Scott Lurndal - Mon, 18 Sep 2023 14:59 UTC

Bonita Montero <Bonita.Montero@gmail.com> writes:
>Am 17.09.2023 um 23:29 schrieb Paavo Helde:
>
>> Studying the actual code shows MSVC is using a critical section and
>> libstc++ is using a futex. These are both single-process only facilities
>> which cannot fail in ...
>
>Specific implementations don't matter because the point is that
>C++ should honor implementations that can theoretically fail.

Feel free to submit a proposal to the C++ standard committee.

Since everyone particpating in this discussion on comp.lang.c++
seems to take the opposite view that you do, I don't believe you'll
have much success in your proposal.

Re: Thread-safe initialization of static objects

<ue9pp8$1qnu3$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Bonita.M...@gmail.com (Bonita Montero)
Newsgroups: comp.lang.c++
Subject: Re: Thread-safe initialization of static objects
Date: Mon, 18 Sep 2023 17:19:03 +0200
Organization: A noiseless patient Spider
Lines: 15
Message-ID: <ue9pp8$1qnu3$1@dont-email.me>
References: <udafjf$2joeq$1@dont-email.me> <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> <mBZNM.58210$8XGa.27400@fx17.iad>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 18 Sep 2023 15:19:04 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="1faee559a96e8a282152d3a155665a0a";
logging-data="1925059"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/czHPkOGz1XUqJyobeYchOLwA+cMBDaZ4="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:Ua0a9pGnwhKOgLvrEWGVdJm52EM=
In-Reply-To: <mBZNM.58210$8XGa.27400@fx17.iad>
Content-Language: de-DE
 by: Bonita Montero - Mon, 18 Sep 2023 15:19 UTC

Am 18.09.2023 um 16:59 schrieb Scott Lurndal:

> Feel free to submit a proposal to the C++ standard committee.

That would make sense for me, but it's not that extremely important
for me since I terminate on synchronization failures anyway for the
code I write so far.

> Since everyone particpating in this discussion on comp.lang.c++
> seems to take the opposite view that you do, I don't believe you'll
> have much success in your proposal.

The people on Stack Overflow agreed to me at last.
But here are only n00bs.

Re: Thread-safe initialization of static objects

<20230918101705.91@kylheku.com>

  copy mid

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

  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-...@kylheku.com (Kaz Kylheku)
Newsgroups: comp.lang.c++
Subject: Re: Thread-safe initialization of static objects
Date: Mon, 18 Sep 2023 17:30:30 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 25
Message-ID: <20230918101705.91@kylheku.com>
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> <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>
Injection-Date: Mon, 18 Sep 2023 17:30:30 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="6bfaa870470b0ebd2b50ab678df28ccf";
logging-data="1976174"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19M6RiIe7zeqo721fP7AInxoaslclIpKws="
User-Agent: slrn/pre1.0.4-9 (Linux)
Cancel-Lock: sha1:z8Ghzqo+IVctd9L+Hot6dsb6d+0=
 by: Kaz Kylheku - Mon, 18 Sep 2023 17:30 UTC

On 2023-09-18, Bonita Montero <Bonita.Montero@gmail.com> wrote:
> Am 17.09.2023 um 21:36 schrieb Kaz Kylheku:
>
>> No it shouldn't. Synchronization that fails for reasons other than
>> a bug in the program (deadlock, unlocking un-owned mutex, recursively
>> acquiring non-recursive mutex, ...) is a wrongheaded idea, ...
>
> And why could a mutex throw a system_error on synchonization.
> According to what you say everything could be noexcept.

It could be, but a C++ API that does not throw exceptions or return
error indications wouldn't be able to express support for mutex
debugging, and would not be extensible to situations like process-shared
robust mutexes.

Just because the API says that it can throw exceptions doesn't mean that
we expect them in a correct program that has not misused the mutex in
any way or caused a deadlock, such that we have to put try blocks
everywhere and handle something.

--
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.


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

Pages:123456789101112131415161718192021222324252627
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor