Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

I've noticed several design suggestions in your code.


devel / comp.lang.c++ / 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

<FUEMM.7469$ZkX3.6739@fx09.iad>

  copy mid

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

  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
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> <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>
Lines: 9
Message-ID: <FUEMM.7469$ZkX3.6739@fx09.iad>
X-Complaints-To: abuse@usenetserver.com
NNTP-Posting-Date: Thu, 14 Sep 2023 14:37:25 UTC
Organization: UsenetServer - www.usenetserver.com
Date: Thu, 14 Sep 2023 14:37:25 GMT
X-Received-Bytes: 1431
 by: Scott Lurndal - Thu, 14 Sep 2023 14:37 UTC

Bonita Montero <Bonita.Montero@gmail.com> writes:
>Am 14.09.2023 um 01:23 schrieb Chris M. Thomasson:
>
>> How do you think futexes work when they are completely addressed based?
>> Nothing to create. I guess you are not that familiar with them. So be it.
>
>Why should a futex be uses on static initializaton,

Because throwing an error on static initialization is a stupid idea.

Re: Thread-safe initialization of static objects

<udv6na$2ljt1$1@dont-email.me>

  copy mid

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

  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: Thu, 14 Sep 2023 16:52:27 +0200
Organization: A noiseless patient Spider
Lines: 20
Message-ID: <udv6na$2ljt1$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>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 14 Sep 2023 14:52:26 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="35912dbc17c9d5e20044546162754b78";
logging-data="2805665"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+K/PNxV9ImKxzZ7Ho2YRJMaLo2QjpxR7c="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:6qlg8XEmLITBNPu+8elUAPnVQps=
Content-Language: de-DE
In-Reply-To: <FUEMM.7469$ZkX3.6739@fx09.iad>
 by: Bonita Montero - Thu, 14 Sep 2023 14:52 UTC

Am 14.09.2023 um 16:37 schrieb Scott Lurndal:
> Bonita Montero <Bonita.Montero@gmail.com> writes:
>> Am 14.09.2023 um 01:23 schrieb Chris M. Thomasson:
>>
>>> How do you think futexes work when they are completely addressed based?
>>> Nothing to create. I guess you are not that familiar with them. So be it.
>>
>> Why should a futex be uses on static initializaton,

> Because throwing an error on static initialization is a stupid idea.

The objection doesn't make sense here, but perhaps elsewhere in the
thread.
The constructor that initializes statically can throw an exception
itself. If this takes place in the functional context, it can also
be caught and the object is attempted to be created in the next run.
Likewise, synchronization could throw an exception during static
initialization and the way it is handled does not change compared
to the case where the constructor itself is.

Re: Thread-safe initialization of static objects

<ue3bhh$3l4s1$1@dont-email.me>

  copy mid

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

  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: Fri, 15 Sep 2023 21:39:12 -0700
Organization: A noiseless patient Spider
Lines: 12
Message-ID: <ue3bhh$3l4s1$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>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sat, 16 Sep 2023 04:39:13 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="39a60ef8404c0ffff7b9e923a65e3fab";
logging-data="3838849"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1864bQCzvCh5kdStEspONA+QOwYqCOyaoc="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.15.1
Cancel-Lock: sha1:idlomwvtt4Zc9ZWnDGOZ0dSXUpw=
Content-Language: en-US
In-Reply-To: <FUEMM.7469$ZkX3.6739@fx09.iad>
 by: Chris M. Thomasson - Sat, 16 Sep 2023 04:39 UTC

On 9/14/2023 7:37 AM, Scott Lurndal wrote:
> Bonita Montero <Bonita.Montero@gmail.com> writes:
>> Am 14.09.2023 um 01:23 schrieb Chris M. Thomasson:
>>
>>> How do you think futexes work when they are completely addressed based?
>>> Nothing to create. I guess you are not that familiar with them. So be it.
>>
>> Why should a futex be uses on static initializaton,
>
> Because throwing an error on static initialization is a stupid idea.

Ding! Agreed.

Re: Thread-safe initialization of static objects

<ue3nga$3ms5s$1@dont-email.me>

  copy mid

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

  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: Sat, 16 Sep 2023 10:03:23 +0200
Organization: A noiseless patient Spider
Lines: 11
Message-ID: <ue3nga$3ms5s$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>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sat, 16 Sep 2023 08:03:22 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="389b07a4da6a937063f24401df7a4bf5";
logging-data="3895484"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18ypjv/u+SGwpryZWrSgQUa/hJLALxFFPE="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:cg6Zkh/UK7KoMZnZ+nlkIdG10V0=
In-Reply-To: <ue3bhh$3l4s1$1@dont-email.me>
Content-Language: de-DE
 by: Bonita Montero - Sat, 16 Sep 2023 08:03 UTC

Am 16.09.2023 um 06:39 schrieb Chris M. Thomasson:

>> Because throwing an error on static initialization is a stupid idea.

> Ding! Agreed.

Why ? If synchronization through a std::mutex could fail the
synchronization part of static initialization could also fail.
So it would be nice if an appropriate exception would be thrown
in this case.

Re: Thread-safe initialization of static objects

<eohNM.4832$3lL1.1360@fx47.iad>

  copy mid

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

  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!fx47.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>
From: Rich...@Damon-Family.org (Richard Damon)
Content-Language: en-US
In-Reply-To: <ue3nga$3ms5s$1@dont-email.me>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Lines: 19
Message-ID: <eohNM.4832$3lL1.1360@fx47.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: Sat, 16 Sep 2023 05:41:45 -0700
X-Received-Bytes: 2038
 by: Richard Damon - Sat, 16 Sep 2023 12:41 UTC

On 9/16/23 1:03 AM, Bonita Montero wrote:
> Am 16.09.2023 um 06:39 schrieb Chris M. Thomasson:
>
>>> Because throwing an error on static initialization is a stupid idea.
>
>> Ding! Agreed.
>
> Why ? If synchronization through a std::mutex could fail the
> synchronization part of static initialization could also fail.
> So it would be nice if an appropriate exception would be thrown
> in this case.
>

Because the synchronization (which doesn't need to be through a
std::mutex) isn't allowed to fail.

The C++ Standard doesn't allow the implementation to use a method to
synchronize that can fail. At best, the implementation needs to generate
code that handles the error and retries.

Re: Thread-safe initialization of static objects

<ue4cqe$3rjfr$1@dont-email.me>

  copy mid

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

  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: Sat, 16 Sep 2023 16:07:11 +0200
Organization: A noiseless patient Spider
Lines: 18
Message-ID: <ue4cqe$3rjfr$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>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sat, 16 Sep 2023 14:07:10 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="389b07a4da6a937063f24401df7a4bf5";
logging-data="4050427"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+kUGUDMcdxK3TE8yqMXv6mANOjvkNsAV8="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:M8xAF3YeiLl9oVghnElLTZEi4xc=
Content-Language: de-DE
In-Reply-To: <eohNM.4832$3lL1.1360@fx47.iad>
 by: Bonita Montero - Sat, 16 Sep 2023 14:07 UTC

Am 16.09.2023 um 14:41 schrieb Richard Damon:

> Because the synchronization (which doesn't need to be through
> a std::mutex) isn't allowed to fail.

This is a requirement that could just as pointlessly be placed
on a mutex.

> The C++ Standard doesn't allow the implementation to use a
> method to synchronize that can fail. At best, the implementation
> needs to generate code that handles the error and retries.

There is actually no need for this property if synchronization
elsewhere fails with an exception. The most appropriate solution
would be to have a system_error on a synchronization exception
as with a mutex and this exception would have the same effect
as if the constructor of the object throws.

Re: Thread-safe initialization of static objects

<ue4g9l$3s8j6$1@dont-email.me>

  copy mid

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

  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: Sat, 16 Sep 2023 17:06:30 +0200
Organization: A noiseless patient Spider
Lines: 11
Message-ID: <ue4g9l$3s8j6$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>
<udkoc6$kdis$1@dont-email.me> <udkpmo$knnn$1@dont-email.me>
<udkq3u$koun$1@dont-email.me> <udl2fv$m1ie$1@dont-email.me>
<udn5jc$12oal$1@dont-email.me> <udn5sm$12qs5$1@dont-email.me>
<udnb84$13n78$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sat, 16 Sep 2023 15:06:29 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="389b07a4da6a937063f24401df7a4bf5";
logging-data="4072038"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19kUkUbWqTtccCGdj0tsnLYPmxxFeniIHc="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:k9fMdf1w2jnnkMDekavvg7b+Blo=
Content-Language: de-DE
In-Reply-To: <udnb84$13n78$1@dont-email.me>
 by: Bonita Montero - Sat, 16 Sep 2023 15:06 UTC

Am 11.09.2023 um 17:20 schrieb Paavo Helde:

> Good, finally some code! Alas, this is not very relevant as it demoes a
> local static object, my post which you replied to started with "Dynamic
> initialization of a non-local variable with static storage duration..."

One thing just occurred to me: with global objects, the initialization
could theoretically be carried out with a delay, and this would then
happen in the functional context. This would primarily solve the static
initialization order fiasco. Maybe C++ could introduce an [[attribute]]
for that for global objects.

Re: Thread-safe initialization of static objects

<LwlNM.50924$QShe.20423@fx11.iad>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx11.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>
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: <ue4cqe$3rjfr$1@dont-email.me>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Lines: 31
Message-ID: <LwlNM.50924$QShe.20423@fx11.iad>
X-Complaints-To: https://www.astraweb.com/aup
NNTP-Posting-Date: Sat, 16 Sep 2023 17:23:55 UTC
Date: Sat, 16 Sep 2023 13:23:44 -0400
X-Received-Bytes: 2600
 by: Pavel - Sat, 16 Sep 2023 17:23 UTC

Bonita Montero wrote:
> Am 16.09.2023 um 14:41 schrieb Richard Damon:
>
>> Because the synchronization (which doesn't need to be through
>> a std::mutex) isn't allowed to fail.
>
> This is a requirement that could just as pointlessly be placed
> on a mutex.
Locking mutex is allowed, but not required, to fail.

Nothing in the C++ standard prevents the implementation of the static
initialization from relying on a mutex of type that cannot fail.

Moreover, nothing in the C++ standard prevents the implementation of the
static initialization from not relying on mutex.

Therefore, the C++ standard is correct to not define any special
protocol for processing synchronization exception during static
initialization.
>
>> The C++ Standard doesn't allow the implementation to use a
>> method to synchronize that can fail. At best, the implementation
>> needs to generate code that handles the error and retries.
>
> There is actually no need for this property if synchronization
> elsewhere fails with an exception. The most appropriate solution
> would be to have a system_error on a synchronization exception
> as with a mutex and this exception would have the same effect
> as if the constructor of the object throws.
>

Re: Thread-safe initialization of static objects

<ue4p5v$3truj$1@dont-email.me>

  copy mid

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

  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: Sat, 16 Sep 2023 19:38:07 +0200
Organization: A noiseless patient Spider
Lines: 25
Message-ID: <ue4p5v$3truj$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>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sat, 16 Sep 2023 17:38:07 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="389b07a4da6a937063f24401df7a4bf5";
logging-data="4124627"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18Eq1pqydJwIj9Ya2xo4rrYpw4nrM18KWk="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:14rD87xh6AJoP6QTMPMpbKTJ7uo=
Content-Language: de-DE
In-Reply-To: <LwlNM.50924$QShe.20423@fx11.iad>
 by: Bonita Montero - Sat, 16 Sep 2023 17:38 UTC

Am 16.09.2023 um 19:23 schrieb Pavel:

> Locking mutex is allowed, but not required, to fail.

Yes, but you have to expect an exception
and the implementation can throw it.

> Nothing in the C++ standard prevents the implementation of the static
> initialization from relying on a mutex of type that cannot fail.

But C++ should take platforms into account where this can happen.

> Moreover, nothing in the C++ standard prevents the implementation
> of the static initialization from not relying on mutex.

It doesn't matter whether it's called mutex or something
else. Ultimately, resource allocation and synchronization
can theoretically fail.

> Therefore, the C++ standard is correct to not define any special
> protocol for processing synchronization exception during static
> initialization.

Absolutely not because there are different platforms.

Re: Thread-safe initialization of static objects

<ue4t6i$3um57$1@dont-email.me>

  copy mid

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

  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: Sat, 16 Sep 2023 11:46:39 -0700
Organization: A noiseless patient Spider
Lines: 48
Message-ID: <ue4t6i$3um57$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>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Sat, 16 Sep 2023 18:46:42 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="39a60ef8404c0ffff7b9e923a65e3fab";
logging-data="4151463"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/ew0jtfq7yvrv0w8hq+G/wsCADAMMM02c="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.15.1
Cancel-Lock: sha1:2NQlwh4ioPAhMntIna3hT8dV558=
Content-Language: en-US
In-Reply-To: <ue4p5v$3truj$1@dont-email.me>
 by: Chris M. Thomasson - Sat, 16 Sep 2023 18:46 UTC

On 9/16/2023 10:38 AM, Bonita Montero wrote:
> Am 16.09.2023 um 19:23 schrieb Pavel:
>
>> Locking mutex is allowed, but not required, to fail.
>
> Yes, but you have to expect an exception
> and the implementation can throw it.
>
>> Nothing in the C++ standard prevents the implementation of the static
>> initialization from relying on a mutex of type that cannot fail.
>
> But C++ should take platforms into account where this can happen.
>
>> Moreover, nothing in the C++ standard prevents the implementation
>> of the static initialization from not relying on mutex.
>
> It doesn't matter whether it's called mutex or something
> else. Ultimately, resource allocation and synchronization
> can  theoretically fail.

Well, there are many different methods. For instance, one way is that
all of the resource allocation can be created in the kernel wrt futexes
up front. OS startup, or even create a futex sync table on a per-process
basis. They are address based. So, if you have a pointer to some data,
alignment issues aside for a moment, you can use it with a futex.

Now synchronization failing is a horrible bug in the sync algorithm
itself. How do you envision synchronization failing? The failure to
create a std::mutex is one thing, a std::mutex failing to lock is a
completely different issue.

Also, why do you seem to think that an impl _must_ create a std::mutex
for each static initialization?

By the way, std::mutex can be based on a futex. So, the mutex does not
need to create anything wrt kernel resources. It can be based on an
std::uintptr_t. No need to create any kernel sync objects. Did you read
about the way Windows does futexes? :^)

>
>> Therefore, the C++ standard is correct to not define any special
>> protocol for processing synchronization exception during static
>> initialization.
>
> Absolutely not because there are different platforms.
>

Re: Thread-safe initialization of static objects

<EjoNM.17221$DXgc.9861@fx36.iad>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx36.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>
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: <ue4p5v$3truj$1@dont-email.me>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Lines: 57
Message-ID: <EjoNM.17221$DXgc.9861@fx36.iad>
X-Complaints-To: https://www.astraweb.com/aup
NNTP-Posting-Date: Sat, 16 Sep 2023 20:34:44 UTC
Date: Sat, 16 Sep 2023 16:34:43 -0400
X-Received-Bytes: 3505
 by: Pavel - Sat, 16 Sep 2023 20:34 UTC

Bonita Montero wrote:
> Am 16.09.2023 um 19:23 schrieb Pavel:
>
>> Locking mutex is allowed, but not required, to fail.
>
> Yes, but you have to expect an exception
> and the implementation can throw it.
>
>> Nothing in the C++ standard prevents the implementation of the static
>> initialization from relying on a mutex of type that cannot fail.
>
> But C++ should take platforms into account where this can happen.
>
>> Moreover, nothing in the C++ standard prevents the implementation
>> of the static initialization from not relying on mutex.
>
> It doesn't matter whether it's called mutex or something
> else. Ultimately, resource allocation
For many synchronization primitives, resource allocation for static
instances of the primitives can be done entirely at the time when
program is loaded to memory. Static initialization can be done with only
such instances. This static constant initialization of such primitives
cannot fail. Incidentally, intra-process POSIX mutexes can be
initialized like this, e.g.:

static pthread_mutex_t m = PTHREAD_MUTEX_INITIALIZER;

And this cannot fail, either theoretically or practically.

or, a non-mutex primitive can be initialized like this

static pthread_once_t once_control = PTHREAD_ONCE_INIT;

And this cannot fail, either theoretically or practically.

> and synchronization

pthread_once on properly initialized once control cannot fail, either
theoretically or practically (assuming the function it calls does not
fail -- but that case is covered by the C++ standard).

> can  theoretically fail.

No.

>
>> Therefore, the C++ standard is correct to not define any special
>> protocol for processing synchronization exception during static
>> initialization.
>
> Absolutely not because there are different platforms.

There have only been platforms where C++ Standard could not be
implemented. EPOC32 / Symbian comes to mind. This is old news. It is not
the goal of the standard to be implementable at any platform and, if it
were, it would not be a realistic one.

Re: Thread-safe initialization of static objects

<ue5sp2$7ms9$1@dont-email.me>

  copy mid

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

  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: Sun, 17 Sep 2023 05:45:38 +0200
Organization: A noiseless patient Spider
Lines: 20
Message-ID: <ue5sp2$7ms9$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>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 17 Sep 2023 03:45:38 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="4d19cbe8f4ab8301b5e4da4d4d3821bf";
logging-data="252809"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+og4eeJg291C+wWNInLOG8htCM7WnREbM="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:vznd7KxNzmI/hV4X7M5Ne0zX6Fc=
In-Reply-To: <ue4t6i$3um57$1@dont-email.me>
Content-Language: de-DE
 by: Bonita Montero - Sun, 17 Sep 2023 03:45 UTC

Am 16.09.2023 um 20:46 schrieb Chris M. Thomasson:

> Well, there are many different methods. ...

But all acceptable include allocating a resource whose
allocation might fail.

> Now synchronization failing is a horrible bug in the sync algorithm
> itself. ...

It doesn't matter how this happens because sth. like
WaitForSingleObject() has an error code you have to honor.

> By the way, std::mutex can be based on a futex. So, the mutex does not
> need to create anything wrt kernel resources. ...

A futex also has kernel resources, it's just a semaphore which is
trapped by the MMU, which is a faster way to get into the kernel.

Re: Thread-safe initialization of static objects

<ue5tfc$7pns$1@dont-email.me>

  copy mid

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

  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: Sun, 17 Sep 2023 05:57:33 +0200
Organization: A noiseless patient Spider
Lines: 15
Message-ID: <ue5tfc$7pns$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>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 17 Sep 2023 03:57:32 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="4d19cbe8f4ab8301b5e4da4d4d3821bf";
logging-data="255740"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+5vtwMyd8DC5v9dD4HksCR4dwIAvcwfMw="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:p3JPy/00klqxNNeD+picZEMzLD4=
Content-Language: de-DE
In-Reply-To: <EjoNM.17221$DXgc.9861@fx36.iad>
 by: Bonita Montero - Sun, 17 Sep 2023 03:57 UTC

Am 16.09.2023 um 22:34 schrieb Pavel:

> For many synchronization primitives, resource allocation for static
> instances of the primitives can be done entirely at the time when
> program is loaded to memory. Static initialization can be done with
> only such instances. This static constant initialization of such
> primitives cannot fail. Incidentally, intra-process POSIX mutexes
> can be initialized like this, e.g.:

As I've shown with my program MSVC, libstdc++ (g++) and libc++ (clang++)
have per object mutexes. And the runtime should be able to support that
to have maximum parallelism while initializing. So the standard should
support that.

Re: Thread-safe initialization of static objects

<DjENM.51886$8XGa.26896@fx17.iad>

  copy mid

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

  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!fx17.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>
From: Rich...@Damon-Family.org (Richard Damon)
In-Reply-To: <ue5tfc$7pns$1@dont-email.me>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Lines: 29
Message-ID: <DjENM.51886$8XGa.26896@fx17.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 10:46:59 -0400
X-Received-Bytes: 2699
 by: Richard Damon - Sun, 17 Sep 2023 14:46 UTC

On 9/16/23 11:57 PM, Bonita Montero wrote:
> Am 16.09.2023 um 22:34 schrieb Pavel:
>
>> For many synchronization primitives, resource allocation for static
>> instances of the primitives can be done entirely at the time when
>> program is loaded to memory. Static initialization can be done with
>> only such instances. This static constant initialization of such
>> primitives cannot fail. Incidentally, intra-process POSIX mutexes
>> can be initialized like this, e.g.:
>
> As I've shown with my program MSVC, libstdc++ (g++) and libc++ (clang++)
> have per object mutexes. And the runtime should be able to support that
> to have maximum parallelism while initializing. So the standard should
> support that.
>
>

Why?

Do you REALLY want you programs to be able to die for undetectable reasons?

It would be ok to default to such a method, as long as there is a
fall-back to a fallback that always works.

Microsoft has a history of not being fully conforming on aspects, so
just because Microsoft does it doesn't make it right.

You just don't seem to understand the concept of being able to expect
that valid code should just work.

Re: Thread-safe initialization of static objects

<ue77ul$eiv3$1@dont-email.me>

  copy mid

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

  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: Sun, 17 Sep 2023 18:02:30 +0200
Organization: A noiseless patient Spider
Lines: 8
Message-ID: <ue77ul$eiv3$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> <DjENM.51886$8XGa.26896@fx17.iad>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 17 Sep 2023 16:02:29 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="4d19cbe8f4ab8301b5e4da4d4d3821bf";
logging-data="478179"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/z+Kd7CJvh2qnn+LevxA2rhZaoMXj58co="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:WOaYUHFbgNZ5clI0EZ+P91jf7XY=
Content-Language: de-DE
In-Reply-To: <DjENM.51886$8XGa.26896@fx17.iad>
 by: Bonita Montero - Sun, 17 Sep 2023 16:02 UTC

Am 17.09.2023 um 16:46 schrieb Richard Damon:

> You just don't seem to understand the concept of being able to
> expect that valid code should just work.

You simply understand the problem. Specifying exceptions on
static local variables initialization would make software more
reliable, not less.

Re: Thread-safe initialization of static objects

<zPGNM.14021$BMnd.11871@fx04.iad>

  copy mid

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

  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!fx04.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>
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: <ue5tfc$7pns$1@dont-email.me>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Lines: 28
Message-ID: <zPGNM.14021$BMnd.11871@fx04.iad>
X-Complaints-To: https://www.astraweb.com/aup
NNTP-Posting-Date: Sun, 17 Sep 2023 17:37:35 UTC
Date: Sun, 17 Sep 2023 13:37:27 -0400
X-Received-Bytes: 2633
 by: Pavel - Sun, 17 Sep 2023 17:37 UTC

Bonita Montero wrote:
> Am 16.09.2023 um 22:34 schrieb Pavel:
>
>> For many synchronization primitives, resource allocation for static
>> instances of the primitives can be done entirely at the time when
>> program is loaded to memory. Static initialization can be done with
>> only such instances. This static constant initialization of such
>> primitives cannot fail. Incidentally, intra-process POSIX mutexes
>> can be initialized like this, e.g.:
>
> As I've shown with my program MSVC, libstdc++ (g++) and libc++ (clang++)
> have per object mutexes.
No your program does not show this. All it alludes to is that there is
no single static synchronization primitive instance for all statically
initialized variables.

In particular, your program did not show that mutexes are used at all
for static initialization on any of those platforms.

Even if you proved mutexes are used (which you did not), they still
could be used in a way that they cannot fail as shown in my example.

> And the runtime should be able to support that
> to have maximum parallelism while initializing. So the standard should
> support that.
>
>

Re: Thread-safe initialization of static objects

<8SGNM.4844$3lL1.4797@fx47.iad>

  copy mid

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

  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!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx47.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>
From: Rich...@Damon-Family.org (Richard Damon)
In-Reply-To: <ue77ul$eiv3$1@dont-email.me>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Lines: 32
Message-ID: <8SGNM.4844$3lL1.4797@fx47.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 13:40:20 -0400
X-Received-Bytes: 3038
 by: Richard Damon - Sun, 17 Sep 2023 17:40 UTC

On 9/17/23 12:02 PM, Bonita Montero wrote:
> Am 17.09.2023 um 16:46 schrieb Richard Damon:
>
>> You just don't seem to understand the concept of being able to
>> expect that valid code should just work.
>
> You simply understand the problem. Specifying exceptions on
> static local variables initialization would make software more
> reliable, not less.

No, since teh ONLY exceptions that are ALLOWED for static local
variables, are those actually thrown by the constructor itself, and NOT
the required "syncronization" (and for file scope variable, such
exceptions are fatal) giving conforming implementations the latitude to
just FAIL is a LOSS in reliablity.

How is allowing a program to just fail to run, without an ability to do
anything about it, make it more reliable?

All you are arguing is that non-conforming implementations should be
allowed to claim conformance.

By the Standard, static initialization isn't allowed to have a
"syncronization issue", the implementation MUST be able to make it work.
If it can't, it just isn't conforming.

It is possible to do it on any operating system that can actually handle
multiple threads reliably, so any optimization that gives an incorrect
result is just WRONG.

It is just as wrong as an optimization that "optimizes" 1+1 and gives
the value of 1 sometimes.

Re: Thread-safe initialization of static objects

<ue7f3i$frod$1@dont-email.me>

  copy mid

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

  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: Sun, 17 Sep 2023 20:04:35 +0200
Organization: A noiseless patient Spider
Lines: 9
Message-ID: <ue7f3i$frod$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> <DjENM.51886$8XGa.26896@fx17.iad>
<ue77ul$eiv3$1@dont-email.me> <8SGNM.4844$3lL1.4797@fx47.iad>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 17 Sep 2023 18:04:34 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="4d19cbe8f4ab8301b5e4da4d4d3821bf";
logging-data="519949"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18fX+emeHBt147zWmN4X8CC3XR4VNP2h0g="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:pskzP1vKeSA2sfiEq+WDI08FWSA=
In-Reply-To: <8SGNM.4844$3lL1.4797@fx47.iad>
Content-Language: de-DE
 by: Bonita Montero - Sun, 17 Sep 2023 18:04 UTC

Am 17.09.2023 um 19:40 schrieb Richard Damon:

> By the Standard, static initialization isn't allowed to have a
> "syncronization issue", ...

If you implement it that way like MSVC, libc++ and libstdc++ with
a mutex per object synchronization can fail. And the standard should
define what happens then.

Re: Thread-safe initialization of static objects

<ue7f6g$frod$2@dont-email.me>

  copy mid

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

  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: Sun, 17 Sep 2023 20:06:09 +0200
Organization: A noiseless patient Spider
Lines: 12
Message-ID: <ue7f6g$frod$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>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 17 Sep 2023 18:06:08 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="4d19cbe8f4ab8301b5e4da4d4d3821bf";
logging-data="519949"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/oKEw0/uzx1uMseuLBqTgb6u7+8H5U/7k="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:JPPB801UQW+3pG9BWv7b97rTe/k=
Content-Language: de-DE
In-Reply-To: <zPGNM.14021$BMnd.11871@fx04.iad>
 by: Bonita Montero - Sun, 17 Sep 2023 18:06 UTC

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.

Re: Thread-safe initialization of static objects

<ue7gb8$fumm$3@dont-email.me>

  copy mid

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

  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 11:25:43 -0700
Organization: A noiseless patient Spider
Lines: 27
Message-ID: <ue7gb8$fumm$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>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 17 Sep 2023 18:25:44 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="6b320f169d519ca75c05ccb6aa9b5206";
logging-data="522966"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18pjiBsdeu9SBiBArl5Se2MjNnSbffJFi4="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.15.1
Cancel-Lock: sha1:fRLLD23fsTpH14IpLg4npa4iKt0=
In-Reply-To: <ue5sp2$7ms9$1@dont-email.me>
Content-Language: en-US
 by: Chris M. Thomasson - Sun, 17 Sep 2023 18:25 UTC

On 9/16/2023 8:45 PM, Bonita Montero wrote:
> Am 16.09.2023 um 20:46 schrieb Chris M. Thomasson:
>
>> Well, there are many different methods. ...
>
> But all acceptable include allocating a resource whose
> allocation might fail.
>
>> Now synchronization failing is a horrible bug in the sync algorithm
>> itself. ...
>
> It doesn't matter how this happens because sth. like
> WaitForSingleObject() has an error code you have to honor.

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.

>> By the way, std::mutex can be based on a futex. So, the mutex does not
>> need to create anything wrt kernel resources. ...
>
> A futex also has kernel resources, it's just a semaphore which is
> trapped by the MMU, which is a faster way to get into the kernel.
>
A futex does not need to create new kernel resources on demand. They are
already there.

Re: Thread-safe initialization of static objects

<xxHNM.70742$i1yc.39429@fx15.iad>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx15.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>
From: Rich...@Damon-Family.org (Richard Damon)
In-Reply-To: <ue7f3i$frod$1@dont-email.me>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Lines: 18
Message-ID: <xxHNM.70742$i1yc.39429@fx15.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 14:26:37 -0400
X-Received-Bytes: 2279
 by: Richard Damon - Sun, 17 Sep 2023 18:26 UTC

On 9/17/23 2:04 PM, Bonita Montero wrote:
> Am 17.09.2023 um 19:40 schrieb Richard Damon:
>
>> By the Standard, static initialization isn't allowed to have a
>> "syncronization issue", ...
>
> If you implement it that way like MSVC, libc++ and libstdc++ with
> a mutex per object synchronization can fail. And the standard should
> define what happens then.
>

You have it backwards. If the mutex object actually CAN fail, than any
implementation that uses them, and don'y handle the failure, is incorrect.

The Standard defines What Must Happen, if it doesn't, the implementation
in non-conforming.

Re: Thread-safe initialization of static objects

<ue7gdm$fumm$4@dont-email.me>

  copy mid

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

  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 11:27:01 -0700
Organization: A noiseless patient Spider
Lines: 15
Message-ID: <ue7gdm$fumm$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>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 17 Sep 2023 18:27:02 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="6b320f169d519ca75c05ccb6aa9b5206";
logging-data="522966"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+75h2iKdftdzug+xYKzK3S8Nj4Zdif3w8="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.15.1
Cancel-Lock: sha1:4e3F1pj25hWVHjU+CWzzuBebi68=
In-Reply-To: <ue7f6g$frod$2@dont-email.me>
Content-Language: en-US
 by: Chris M. Thomasson - Sun, 17 Sep 2023 18:27 UTC

On 9/17/2023 11:06 AM, 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.
>

Sigh.

Re: Thread-safe initialization of static objects

<ue7gen$fumm$5@dont-email.me>

  copy mid

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

  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 11:27:35 -0700
Organization: A noiseless patient Spider
Lines: 12
Message-ID: <ue7gen$fumm$5@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> <DjENM.51886$8XGa.26896@fx17.iad>
<ue77ul$eiv3$1@dont-email.me> <8SGNM.4844$3lL1.4797@fx47.iad>
<ue7f3i$frod$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 18:27:36 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="6b320f169d519ca75c05ccb6aa9b5206";
logging-data="522966"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/HGQmNtfRsFXg/iXoikcoljz/8i8Bz9CQ="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.15.1
Cancel-Lock: sha1:UFmM95xOh2joAdh2QqEtB0EgAPk=
Content-Language: en-US
In-Reply-To: <ue7f3i$frod$1@dont-email.me>
 by: Chris M. Thomasson - Sun, 17 Sep 2023 18:27 UTC

On 9/17/2023 11:04 AM, Bonita Montero wrote:
> Am 17.09.2023 um 19:40 schrieb Richard Damon:
>
>> By the Standard, static initialization isn't allowed to have a
>> "syncronization issue", ...
>
> If you implement it that way like MSVC, libc++ and libstdc++ with
> a mutex per object synchronization can fail. And the standard should
> define what happens then.
>

Sigh.

Re: Thread-safe initialization of static objects

<ue7gkn$g3o5$1@dont-email.me>

  copy mid

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

  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: Sun, 17 Sep 2023 20:30:48 +0200
Organization: A noiseless patient Spider
Lines: 15
Message-ID: <ue7gkn$g3o5$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>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 17 Sep 2023 18:30:47 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="4d19cbe8f4ab8301b5e4da4d4d3821bf";
logging-data="528133"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19DssVH1AnlwSddb5M7U0E9WeXqg2C7kPg="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:ZujRyy7sFaHlpypc7VoonOb2IDg=
Content-Language: de-DE
In-Reply-To: <ue7gb8$fumm$3@dont-email.me>
 by: Bonita Montero - Sun, 17 Sep 2023 18:30 UTC

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.

Re: Thread-safe initialization of static objects

<ue7gmv$g3o5$2@dont-email.me>

  copy mid

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

  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: Sun, 17 Sep 2023 20:32:01 +0200
Organization: A noiseless patient Spider
Lines: 8
Message-ID: <ue7gmv$g3o5$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> <DjENM.51886$8XGa.26896@fx17.iad>
<ue77ul$eiv3$1@dont-email.me> <8SGNM.4844$3lL1.4797@fx47.iad>
<ue7f3i$frod$1@dont-email.me> <xxHNM.70742$i1yc.39429@fx15.iad>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 17 Sep 2023 18:31:59 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="4d19cbe8f4ab8301b5e4da4d4d3821bf";
logging-data="528133"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX193XPPPbCLjYkNqSJxAFvlF7gX3oe0/gLo="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:4PB1noHtTUPpkRVUPiRDL/CJWhY=
In-Reply-To: <xxHNM.70742$i1yc.39429@fx15.iad>
Content-Language: de-DE
 by: Bonita Montero - Sun, 17 Sep 2023 18:32 UTC

Am 17.09.2023 um 20:26 schrieb Richard Damon:

> You have it backwards. If the mutex object actually CAN fail, than any
> implementation that uses them, and don'y handle the failure, is incorrect.

The standard should allow an implementation that fails and have
a way to handle that; a system_error would be the most appropiate
way.


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

Pages:123456789101112131415161718192021222324252627
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor