Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

To err is human, to forgive, beyond the scope of the Operating System.


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

<8F3SM.42015$ugs.38358@fx36.iad>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!feeder1.feed.usenet.farm!feed.usenet.farm!peer03.ams4!peer.am4.highwinds-media.com!peer02.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> <MTUPM.158223$Hih7.125749@fx11.iad>
<uep6pj$1b36d$1@dont-email.me> <byVPM.165856$Hih7.109980@fx11.iad>
<uep8vu$1bect$1@dont-email.me> <PKZPM.232647$ZXz4.71820@fx18.iad>
<ueqfkl$1i6un$2@dont-email.me> <Fa5QM.124660$1B%c.102962@fx09.iad>
<uerem0$1qg8s$1@dont-email.me> <ZYdQM.67167$3vM.17655@fx37.iad>
<uerv9b$1tqis$1@dont-email.me> <LJoQM.19137$EIy4.5875@fx48.iad>
<uetn46$2bkun$1@dont-email.me> <3bzQM.36476$q0k.14387@fx34.iad>
<ueuj9u$2gdqk$3@dont-email.me> <eJCQM.35600$ugs.8334@fx36.iad>
<ueutjo$2ii89$2@dont-email.me> <S%pRM.268878$2ph4.195852@fx14.iad>
<uf6ecm$8rfg$1@dont-email.me> <n0NRM.30341$NkG.4566@fx41.iad>
<uf8dve$nt9u$1@dont-email.me> <20230930120011.66@kylheku.com>
<fe50c473-df9e-4738-819b-56fd06540a4dn@googlegroups.com>
<ufa061$13ggj$3@dont-email.me>
From: pauldontspamtolk@removeyourself.dontspam.yahoo (Pavel)
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
Firefox/91.0 SeaMonkey/2.53.17.1
MIME-Version: 1.0
In-Reply-To: <ufa061$13ggj$3@dont-email.me>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Lines: 62
Message-ID: <8F3SM.42015$ugs.38358@fx36.iad>
X-Complaints-To: https://www.astraweb.com/aup
NNTP-Posting-Date: Sun, 01 Oct 2023 01:09:24 UTC
Date: Sat, 30 Sep 2023 21:09:01 -0400
X-Received-Bytes: 3966
 by: Pavel - Sun, 1 Oct 2023 01:09 UTC

Chris M. Thomasson wrote:
> On 9/30/2023 12:32 PM, Michael S wrote:
>> On Saturday, September 30, 2023 at 10:07:57 PM UTC+3, Kaz Kylheku wrote:
>>> On 2023-09-30, Bonita Montero <Bonita....@gmail.com> wrote:
>>>> Am 30.09.2023 um 05:57 schrieb Pavel:
>>>>> Bonita Montero wrote:
>>>>>> Am 29.09.2023 um 03:46 schrieb Pavel:
>>>>>>
>>>>>>> see my or Kaz's explanation for how it is done without allocating
>>>>>>> any
>>>>>>> kernel resource on either initialization or locking, either fast or
>>>>>>> slow path.
>>>>>>
>>>>>> ... on Linux with signals.
>>>>>>
>>>>> With user-space sync primitives on any system.
>>>>
>>>> A mutex may lead to a sleeping thread, that's only possible with
>>>> the help of the kernel.
>>> You keep returning to this in circles, forgetting that the argument
>>> isn't that help from the kernel isn't required.
>>>
>>> The argument is that there is no need to allocate a kernel
>>> object per mutex. That is only one point in the design space,
>>> and not a very good one.
>>>
>>> Do *you* have ADHD is the question.
>>> --
>>> TXR Programming Language: http://nongnu.org/txr
>>> Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
>>> Mastodon: @Kazi...@mstdn.ca
>>> NOTE: If you use Google Groups, I don't see you, unless you're
>>> whitelisted.
>>
>> Another point is that "one user-mode lock per one local static object"
>> is also only one point in the design space. Possibly, not a bad point, if
>> you have user-mode lock as small as futex on Linux or  or even as
>> (slightly
>> bigger) SRW Lock on Windows's, but it seems that none of major C++
>> toolsets
>> had chosen this particular design point. I don't know why.
>>
>
> Actually, one of my rw mutex algorithms allocates all of its kernel
> resources up front wrt the object itself. So, the rwmutex can report
> this condition wrt failure to create a kernel semaphore, in its
> constructor, not on a damn lock() op wrt contention.
>
> Fwiw, a person was kind enough to use my rwmutex work here: Notice it
> has no loops? :^)
Neat.

Just curious: why do you sometimes use fetch_add with negative addend
and sometimes fetch_sub?

>
> https://vorbrodt.blog/2019/02/14/read-write-mutex/
> (check it out...)
>
> Btw, I have modeled this using several race detectors even though I know
> it works. :^)

Re: Thread-safe initialization of static objects

<ufaqet$1csrm$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: chris.m.thomasson.1@gmail.com (Chris M. Thomasson)
Newsgroups: comp.lang.c++
Subject: Re: Thread-safe initialization of static objects
Date: Sat, 30 Sep 2023 20:52:58 -0700
Organization: A noiseless patient Spider
Lines: 119
Message-ID: <ufaqet$1csrm$1@dont-email.me>
References: <udafjf$2joeq$1@dont-email.me> <MTUPM.158223$Hih7.125749@fx11.iad>
<uep6pj$1b36d$1@dont-email.me> <byVPM.165856$Hih7.109980@fx11.iad>
<uep8vu$1bect$1@dont-email.me> <PKZPM.232647$ZXz4.71820@fx18.iad>
<ueqfkl$1i6un$2@dont-email.me> <Fa5QM.124660$1B%c.102962@fx09.iad>
<uerem0$1qg8s$1@dont-email.me> <ZYdQM.67167$3vM.17655@fx37.iad>
<uerv9b$1tqis$1@dont-email.me> <LJoQM.19137$EIy4.5875@fx48.iad>
<uetn46$2bkun$1@dont-email.me> <3bzQM.36476$q0k.14387@fx34.iad>
<ueuj9u$2gdqk$3@dont-email.me> <eJCQM.35600$ugs.8334@fx36.iad>
<ueutjo$2ii89$2@dont-email.me> <S%pRM.268878$2ph4.195852@fx14.iad>
<uf6ecm$8rfg$1@dont-email.me> <n0NRM.30341$NkG.4566@fx41.iad>
<uf8dve$nt9u$1@dont-email.me> <20230930120011.66@kylheku.com>
<fe50c473-df9e-4738-819b-56fd06540a4dn@googlegroups.com>
<ufa061$13ggj$3@dont-email.me> <8F3SM.42015$ugs.38358@fx36.iad>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Sun, 1 Oct 2023 03:53:01 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="c78e7227798d66ad1b1ff329f287812c";
logging-data="1471350"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX199qrh+XMsyhRJxoNyjqD4CrKL0r6LRQwk="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.15.1
Cancel-Lock: sha1:k3PfTfiFDl+jIiSfLcA0mVx1Mbo=
Content-Language: en-US
In-Reply-To: <8F3SM.42015$ugs.38358@fx36.iad>
 by: Chris M. Thomasson - Sun, 1 Oct 2023 03:52 UTC

On 9/30/2023 6:09 PM, Pavel wrote:
> Chris M. Thomasson wrote:
>> On 9/30/2023 12:32 PM, Michael S wrote:
>>> On Saturday, September 30, 2023 at 10:07:57 PM UTC+3, Kaz Kylheku wrote:
>>>> On 2023-09-30, Bonita Montero <Bonita....@gmail.com> wrote:
>>>>> Am 30.09.2023 um 05:57 schrieb Pavel:
>>>>>> Bonita Montero wrote:
>>>>>>> Am 29.09.2023 um 03:46 schrieb Pavel:
>>>>>>>
>>>>>>>> see my or Kaz's explanation for how it is done without
>>>>>>>> allocating any
>>>>>>>> kernel resource on either initialization or locking, either fast or
>>>>>>>> slow path.
>>>>>>>
>>>>>>> ... on Linux with signals.
>>>>>>>
>>>>>> With user-space sync primitives on any system.
>>>>>
>>>>> A mutex may lead to a sleeping thread, that's only possible with
>>>>> the help of the kernel.
>>>> You keep returning to this in circles, forgetting that the argument
>>>> isn't that help from the kernel isn't required.
>>>>
>>>> The argument is that there is no need to allocate a kernel
>>>> object per mutex. That is only one point in the design space,
>>>> and not a very good one.
>>>>
>>>> Do *you* have ADHD is the question.
>>>> --
>>>> TXR Programming Language: http://nongnu.org/txr
>>>> Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
>>>> Mastodon: @Kazi...@mstdn.ca
>>>> NOTE: If you use Google Groups, I don't see you, unless you're
>>>> whitelisted.
>>>
>>> Another point is that "one user-mode lock per one local static object"
>>> is also only one point in the design space. Possibly, not a bad
>>> point, if
>>> you have user-mode lock as small as futex on Linux or  or even as
>>> (slightly
>>> bigger) SRW Lock on Windows's, but it seems that none of major C++
>>> toolsets
>>> had chosen this particular design point. I don't know why.
>>>
>>
>> Actually, one of my rw mutex algorithms allocates all of its kernel
>> resources up front wrt the object itself. So, the rwmutex can report
>> this condition wrt failure to create a kernel semaphore, in its
>> constructor, not on a damn lock() op wrt contention.
>>
>> Fwiw, a person was kind enough to use my rwmutex work here: Notice it
>> has no loops? :^)
> Neat.
>
> Just curious: why do you sometimes use fetch_add with negative addend
> and sometimes fetch_sub?

Good question. Well, iirc, way back when I was experimenting and
designing it I wanted to test fetch_add _and_ fetch_sub with Relacy
which was in its fairly early stages then. I had _pure_ loopless bakery
algorithms on my mind for some other interesting reasons... Anyway, my
original code used all fetch_add, but I altered it to use fetch_sub into
the unit testing.

I was originally building this on an x86, and using all LOCK XADD's.

When I presented it, iirc, I accidentally showed my Relacy code that had
fetch_sub. This is not exactly consistent! But I just said, ahhh okay,
it still works. Sorry about that. It's me forgetting that I used
fetch_sub in one of my unit tests, and forgot to change them back
_before_ I presented it. Argh! ;^o

Actually, I can kind of remember when I actually altered a single
fetch_add to fetch_sub in one place:
_____________
[...]
if (m_wrstate.fetch_sub(1, std::memory_order_acquire) < 1)
[...]
_____________

Which can be replaced with:
_____________
[...]
if (m_wrstate.fetch_add(-1, std::memory_order_acquire) < 1)
[...]
_____________

It's nice that you noticed it! Bringing back memories.

Just one of my bakery algorithm experiments. I posted it way back over
on the intel threading forums, but that group does not seem to exist or
has changed over the years. Thanks for the memories, Pavel! Thanks for
taking an interesting interest. :^)

Fwiw, this also brings back memories about strong CAS and weak CAS.
Strong CAA can be used in a loopless bakery algorithm, but not
necessarily with weak. Weak can fail spuriously and require a loop. This
loop would break my loopless requirements. Also, I remember putting a
restriction on myself that I have to do it without using CAS at all,
weak or strong! :^)

Btw, my rwmutex has a pretty decent and rather slim read lock/unlock...

:^D

Weak vs Strong CAS is an interesting topic in and of itself.

>
>>
>> https://vorbrodt.blog/2019/02/14/read-write-mutex/
>> (check it out...)
>>
>> Btw, I have modeled this using several race detectors even though I
>> know it works. :^)
>

Re: Thread-safe initialization of static objects

<ufaudd$1dfn9$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Bonita.Montero@gmail.com (Bonita Montero)
Newsgroups: comp.lang.c++
Subject: Re: Thread-safe initialization of static objects
Date: Sun, 1 Oct 2023 07:00:30 +0200
Organization: A noiseless patient Spider
Lines: 9
Message-ID: <ufaudd$1dfn9$1@dont-email.me>
References: <udafjf$2joeq$1@dont-email.me> <MTUPM.158223$Hih7.125749@fx11.iad>
<uep6pj$1b36d$1@dont-email.me> <byVPM.165856$Hih7.109980@fx11.iad>
<uep8vu$1bect$1@dont-email.me> <PKZPM.232647$ZXz4.71820@fx18.iad>
<ueqfkl$1i6un$2@dont-email.me> <Fa5QM.124660$1B%c.102962@fx09.iad>
<uerem0$1qg8s$1@dont-email.me> <ZYdQM.67167$3vM.17655@fx37.iad>
<uerv9b$1tqis$1@dont-email.me> <LJoQM.19137$EIy4.5875@fx48.iad>
<uetn46$2bkun$1@dont-email.me> <3bzQM.36476$q0k.14387@fx34.iad>
<ueuj9u$2gdqk$3@dont-email.me> <eJCQM.35600$ugs.8334@fx36.iad>
<ueutjo$2ii89$2@dont-email.me> <S%pRM.268878$2ph4.195852@fx14.iad>
<uf6ecm$8rfg$1@dont-email.me> <n0NRM.30341$NkG.4566@fx41.iad>
<uf8dve$nt9u$1@dont-email.me> <ssZRM.206761$1B%c.192431@fx09.iad>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 1 Oct 2023 05:00:29 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="444974eee266e55b5946331d4c49d420";
logging-data="1490665"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19Rc128UDwzJlP3yawFy8BkjxJ/M491idc="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:wG6H4qFlkr8buy0O6zN/V92z+ow=
Content-Language: de-DE
In-Reply-To: <ssZRM.206761$1B%c.192431@fx09.iad>
 by: Bonita Montero - Sun, 1 Oct 2023 05:00 UTC

Am 30.09.2023 um 20:06 schrieb Pavel:

> This does not prove that the kernel call to acquire the primitive may
> fail. ...

This has not to be proven, but this has to be assumed by the standard.
mutex::lock() can throw system_error for that:

Rest unread.

Re: Thread-safe initialization of static objects

<ufauf8$1dfn9$2@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Bonita.Montero@gmail.com (Bonita Montero)
Newsgroups: comp.lang.c++
Subject: Re: Thread-safe initialization of static objects
Date: Sun, 1 Oct 2023 07:01:29 +0200
Organization: A noiseless patient Spider
Lines: 7
Message-ID: <ufauf8$1dfn9$2@dont-email.me>
References: <udafjf$2joeq$1@dont-email.me> <MTUPM.158223$Hih7.125749@fx11.iad>
<uep6pj$1b36d$1@dont-email.me> <byVPM.165856$Hih7.109980@fx11.iad>
<uep8vu$1bect$1@dont-email.me> <PKZPM.232647$ZXz4.71820@fx18.iad>
<ueqfkl$1i6un$2@dont-email.me> <Fa5QM.124660$1B%c.102962@fx09.iad>
<uerem0$1qg8s$1@dont-email.me> <ZYdQM.67167$3vM.17655@fx37.iad>
<uerv9b$1tqis$1@dont-email.me> <LJoQM.19137$EIy4.5875@fx48.iad>
<uetn46$2bkun$1@dont-email.me> <3bzQM.36476$q0k.14387@fx34.iad>
<ueuj9u$2gdqk$3@dont-email.me> <eJCQM.35600$ugs.8334@fx36.iad>
<ueutjo$2ii89$2@dont-email.me> <S%pRM.268878$2ph4.195852@fx14.iad>
<uf6ecm$8rfg$1@dont-email.me> <n0NRM.30341$NkG.4566@fx41.iad>
<uf8dve$nt9u$1@dont-email.me> <20230930120011.66@kylheku.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 1 Oct 2023 05:01:28 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="444974eee266e55b5946331d4c49d420";
logging-data="1490665"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19fqexzJ82pbAMKchrlNc8aPc/nlT5SGkA="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:PTWIaay1sqbcObK/sj2RKJ+VU1s=
In-Reply-To: <20230930120011.66@kylheku.com>
Content-Language: de-DE
 by: Bonita Montero - Sun, 1 Oct 2023 05:01 UTC

Am 30.09.2023 um 21:07 schrieb Kaz Kylheku:

> You keep returning to this in circles, forgetting that the argument
> isn't that help from the kernel isn't required.

On Linux. On Windows the kernel handle for the thread might have been
closed so you have no other way to sleep than for an event or semaphore.

Re: Thread-safe initialization of static objects

<20231001093836.174@kylheku.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: 864-117-4973@kylheku.com (Kaz Kylheku)
Newsgroups: comp.lang.c++
Subject: Re: Thread-safe initialization of static objects
Date: Sun, 1 Oct 2023 16:41:17 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 22
Message-ID: <20231001093836.174@kylheku.com>
References: <udafjf$2joeq$1@dont-email.me>
<MTUPM.158223$Hih7.125749@fx11.iad> <uep6pj$1b36d$1@dont-email.me>
<byVPM.165856$Hih7.109980@fx11.iad> <uep8vu$1bect$1@dont-email.me>
<PKZPM.232647$ZXz4.71820@fx18.iad> <ueqfkl$1i6un$2@dont-email.me>
<Fa5QM.124660$1B%c.102962@fx09.iad> <uerem0$1qg8s$1@dont-email.me>
<ZYdQM.67167$3vM.17655@fx37.iad> <uerv9b$1tqis$1@dont-email.me>
<LJoQM.19137$EIy4.5875@fx48.iad> <uetn46$2bkun$1@dont-email.me>
<3bzQM.36476$q0k.14387@fx34.iad> <ueuj9u$2gdqk$3@dont-email.me>
<eJCQM.35600$ugs.8334@fx36.iad> <ueutjo$2ii89$2@dont-email.me>
<S%pRM.268878$2ph4.195852@fx14.iad> <uf6ecm$8rfg$1@dont-email.me>
<n0NRM.30341$NkG.4566@fx41.iad> <uf8dve$nt9u$1@dont-email.me>
<20230930120011.66@kylheku.com> <ufauf8$1dfn9$2@dont-email.me>
Injection-Date: Sun, 1 Oct 2023 16:41:17 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="ee44f205ccae354c39f7ae203d1e98c0";
logging-data="1741301"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+pTnutjU8gJmbN/vfTVc9zNPNl6f0l+Ao="
User-Agent: slrn/pre1.0.4-9 (Linux)
Cancel-Lock: sha1:4d0bWeYhZuigmPmSTgPgDSY4LuM=
 by: Kaz Kylheku - Sun, 1 Oct 2023 16:41 UTC

On 2023-10-01, Bonita Montero <Bonita.Montero@gmail.com> wrote:
> Am 30.09.2023 um 21:07 schrieb Kaz Kylheku:
>
>> You keep returning to this in circles, forgetting that the argument
>> isn't that help from the kernel isn't required.
>
> On Linux.

What on Linux? The argument isn't that help from the kernel isn't
required. It is, on Linux and Windows.

> On Windows the kernel handle for the thread might have been
> closed so you have no other way to sleep than for an event or semaphore.

What? Who said anything about a thread handle? How does this relate
to anything? A "handle per thread" isn't a handle to the thread.

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

<ufc8j7$1lfoh$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Bonita.Montero@gmail.com (Bonita Montero)
Newsgroups: comp.lang.c++
Subject: Re: Thread-safe initialization of static objects
Date: Sun, 1 Oct 2023 19:00:24 +0200
Organization: A noiseless patient Spider
Lines: 8
Message-ID: <ufc8j7$1lfoh$1@dont-email.me>
References: <udafjf$2joeq$1@dont-email.me> <MTUPM.158223$Hih7.125749@fx11.iad>
<uep6pj$1b36d$1@dont-email.me> <byVPM.165856$Hih7.109980@fx11.iad>
<uep8vu$1bect$1@dont-email.me> <PKZPM.232647$ZXz4.71820@fx18.iad>
<ueqfkl$1i6un$2@dont-email.me> <Fa5QM.124660$1B%c.102962@fx09.iad>
<uerem0$1qg8s$1@dont-email.me> <ZYdQM.67167$3vM.17655@fx37.iad>
<uerv9b$1tqis$1@dont-email.me> <LJoQM.19137$EIy4.5875@fx48.iad>
<uetn46$2bkun$1@dont-email.me> <3bzQM.36476$q0k.14387@fx34.iad>
<ueuj9u$2gdqk$3@dont-email.me> <eJCQM.35600$ugs.8334@fx36.iad>
<ueutjo$2ii89$2@dont-email.me> <S%pRM.268878$2ph4.195852@fx14.iad>
<uf6ecm$8rfg$1@dont-email.me> <n0NRM.30341$NkG.4566@fx41.iad>
<uf8dve$nt9u$1@dont-email.me> <20230930120011.66@kylheku.com>
<ufauf8$1dfn9$2@dont-email.me> <20231001093836.174@kylheku.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 1 Oct 2023 17:00:23 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="444974eee266e55b5946331d4c49d420";
logging-data="1752849"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+EJW5g/rR++mbx9g9gTnYcgTRAZbDw414="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:M+C6XHf2izxFA57Fg9gD+8Jthyw=
Content-Language: de-DE
In-Reply-To: <20231001093836.174@kylheku.com>
 by: Bonita Montero - Sun, 1 Oct 2023 17:00 UTC

Am 01.10.2023 um 18:41 schrieb Kaz Kylheku:

> What on Linux? The argument isn't that help from the kernel isn't
> required. It is, on Linux and Windows.

If you want to go to sleep while another contender holds the lock
you need the kernel.

Re: Thread-safe initialization of static objects

<20231001100335.821@kylheku.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: 864-117-4973@kylheku.com (Kaz Kylheku)
Newsgroups: comp.lang.c++
Subject: Re: Thread-safe initialization of static objects
Date: Sun, 1 Oct 2023 17:04:16 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 18
Message-ID: <20231001100335.821@kylheku.com>
References: <udafjf$2joeq$1@dont-email.me>
<MTUPM.158223$Hih7.125749@fx11.iad> <uep6pj$1b36d$1@dont-email.me>
<byVPM.165856$Hih7.109980@fx11.iad> <uep8vu$1bect$1@dont-email.me>
<PKZPM.232647$ZXz4.71820@fx18.iad> <ueqfkl$1i6un$2@dont-email.me>
<Fa5QM.124660$1B%c.102962@fx09.iad> <uerem0$1qg8s$1@dont-email.me>
<ZYdQM.67167$3vM.17655@fx37.iad> <uerv9b$1tqis$1@dont-email.me>
<LJoQM.19137$EIy4.5875@fx48.iad> <uetn46$2bkun$1@dont-email.me>
<3bzQM.36476$q0k.14387@fx34.iad> <ueuj9u$2gdqk$3@dont-email.me>
<eJCQM.35600$ugs.8334@fx36.iad> <ueutjo$2ii89$2@dont-email.me>
<S%pRM.268878$2ph4.195852@fx14.iad> <uf6ecm$8rfg$1@dont-email.me>
<n0NRM.30341$NkG.4566@fx41.iad> <uf8dve$nt9u$1@dont-email.me>
<20230930120011.66@kylheku.com> <ufauf8$1dfn9$2@dont-email.me>
<20231001093836.174@kylheku.com> <ufc8j7$1lfoh$1@dont-email.me>
Injection-Date: Sun, 1 Oct 2023 17:04:16 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="ee44f205ccae354c39f7ae203d1e98c0";
logging-data="1756043"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/GzUGmj1rCal6mOMgv1Cq4Evja1vDzOq4="
User-Agent: slrn/pre1.0.4-9 (Linux)
Cancel-Lock: sha1:FxNZZ8/S+85jI/1zcgKvVdX6qow=
 by: Kaz Kylheku - Sun, 1 Oct 2023 17:04 UTC

On 2023-10-01, Bonita Montero <Bonita.Montero@gmail.com> wrote:
> Am 01.10.2023 um 18:41 schrieb Kaz Kylheku:
>
>> What on Linux? The argument isn't that help from the kernel isn't
>> required. It is, on Linux and Windows.
>
> If you want to go to sleep while another contender holds the lock
> you need the kernel.

I have no idea why you're repeating my point, but okay.

Maybe the double negative in that first sentence went over your head?

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

<2ShSM.259308$vMO8.78214@fx16.iad>

  copy mid

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

  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!fx16.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> <MTUPM.158223$Hih7.125749@fx11.iad>
<uep6pj$1b36d$1@dont-email.me> <byVPM.165856$Hih7.109980@fx11.iad>
<uep8vu$1bect$1@dont-email.me> <PKZPM.232647$ZXz4.71820@fx18.iad>
<ueqfkl$1i6un$2@dont-email.me> <Fa5QM.124660$1B%c.102962@fx09.iad>
<uerem0$1qg8s$1@dont-email.me> <ZYdQM.67167$3vM.17655@fx37.iad>
<uerv9b$1tqis$1@dont-email.me> <LJoQM.19137$EIy4.5875@fx48.iad>
<uetn46$2bkun$1@dont-email.me> <3bzQM.36476$q0k.14387@fx34.iad>
<ueuj9u$2gdqk$3@dont-email.me> <eJCQM.35600$ugs.8334@fx36.iad>
<ueutjo$2ii89$2@dont-email.me> <S%pRM.268878$2ph4.195852@fx14.iad>
<uf6ecm$8rfg$1@dont-email.me> <n0NRM.30341$NkG.4566@fx41.iad>
<uf8dve$nt9u$1@dont-email.me> <ssZRM.206761$1B%c.192431@fx09.iad>
<ufaudd$1dfn9$1@dont-email.me>
From: Richard@Damon-Family.org (Richard Damon)
Content-Language: en-US
In-Reply-To: <ufaudd$1dfn9$1@dont-email.me>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Lines: 23
Message-ID: <2ShSM.259308$vMO8.78214@fx16.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, 1 Oct 2023 13:18:54 -0400
X-Received-Bytes: 2330
 by: Richard Damon - Sun, 1 Oct 2023 17:18 UTC

On 10/1/23 1:00 AM, Bonita Montero wrote:
> Am 30.09.2023 um 20:06 schrieb Pavel:
>
>> This does not prove that the kernel call to acquire the primitive may
>> fail. ...
>
> This has not to be proven, but this has to be assumed by the standard.
> mutex::lock() can throw system_error for that:

No, the Standard establishes the rules, and the standard say that the
static initialization synchronization can't fail, so if std::mutex might
fail for this sort of lock, the implementation can't use a std::mutex to
do that synchronization.

Until you can show an actual case of an inplementation which has the
power to actually correctly run threaded code, that can't achieve this
syncronization, you are just proving you don't beleive code should be
correct.

>
> Rest unread.

Which just proves your stupidity.

Re: Thread-safe initialization of static objects

<ufcfpo$2f5v7$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Bonita.Montero@gmail.com (Bonita Montero)
Newsgroups: comp.lang.c++
Subject: Re: Thread-safe initialization of static objects
Date: Sun, 1 Oct 2023 21:03:22 +0200
Organization: A noiseless patient Spider
Lines: 12
Message-ID: <ufcfpo$2f5v7$1@dont-email.me>
References: <udafjf$2joeq$1@dont-email.me> <MTUPM.158223$Hih7.125749@fx11.iad>
<uep6pj$1b36d$1@dont-email.me> <byVPM.165856$Hih7.109980@fx11.iad>
<uep8vu$1bect$1@dont-email.me> <PKZPM.232647$ZXz4.71820@fx18.iad>
<ueqfkl$1i6un$2@dont-email.me> <Fa5QM.124660$1B%c.102962@fx09.iad>
<uerem0$1qg8s$1@dont-email.me> <ZYdQM.67167$3vM.17655@fx37.iad>
<uerv9b$1tqis$1@dont-email.me> <LJoQM.19137$EIy4.5875@fx48.iad>
<uetn46$2bkun$1@dont-email.me> <3bzQM.36476$q0k.14387@fx34.iad>
<ueuj9u$2gdqk$3@dont-email.me> <eJCQM.35600$ugs.8334@fx36.iad>
<ueutjo$2ii89$2@dont-email.me> <S%pRM.268878$2ph4.195852@fx14.iad>
<uf6ecm$8rfg$1@dont-email.me> <n0NRM.30341$NkG.4566@fx41.iad>
<uf8dve$nt9u$1@dont-email.me> <ssZRM.206761$1B%c.192431@fx09.iad>
<ufaudd$1dfn9$1@dont-email.me> <2ShSM.259308$vMO8.78214@fx16.iad>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 1 Oct 2023 19:03:20 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="444974eee266e55b5946331d4c49d420";
logging-data="2594791"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18atB5QzQXLGt85TWeTiZNEZwrfShxUVAQ="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:bVDL4tUIqukRKnyOApRgJFlYEK4=
Content-Language: de-DE
In-Reply-To: <2ShSM.259308$vMO8.78214@fx16.iad>
 by: Bonita Montero - Sun, 1 Oct 2023 19:03 UTC

Am 01.10.2023 um 19:18 schrieb Richard Damon:

> No, the Standard establishes the rules, and the standard say that the
> static initialization synchronization can't fail, so if std::mutex might
> fail for this sort of lock, the implementation can't use a std::mutex to
> do that synchronization.

But the standard should mandate that this might fail and throw
a system_error to work with any conditions.

Rest unread.

Re: Thread-safe initialization of static objects

<I%jSM.193899$noZ7.183010@fx13.iad>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!newsreader4.netcologne.de!news.netcologne.de!peer03.ams1!peer.ams1.xlned.com!news.xlned.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
Content-Language: en-US
Newsgroups: comp.lang.c++
References: <udafjf$2joeq$1@dont-email.me> <MTUPM.158223$Hih7.125749@fx11.iad>
<uep6pj$1b36d$1@dont-email.me> <byVPM.165856$Hih7.109980@fx11.iad>
<uep8vu$1bect$1@dont-email.me> <PKZPM.232647$ZXz4.71820@fx18.iad>
<ueqfkl$1i6un$2@dont-email.me> <Fa5QM.124660$1B%c.102962@fx09.iad>
<uerem0$1qg8s$1@dont-email.me> <ZYdQM.67167$3vM.17655@fx37.iad>
<uerv9b$1tqis$1@dont-email.me> <LJoQM.19137$EIy4.5875@fx48.iad>
<uetn46$2bkun$1@dont-email.me> <3bzQM.36476$q0k.14387@fx34.iad>
<ueuj9u$2gdqk$3@dont-email.me> <eJCQM.35600$ugs.8334@fx36.iad>
<ueutjo$2ii89$2@dont-email.me> <S%pRM.268878$2ph4.195852@fx14.iad>
<uf6ecm$8rfg$1@dont-email.me> <n0NRM.30341$NkG.4566@fx41.iad>
<uf8dve$nt9u$1@dont-email.me> <ssZRM.206761$1B%c.192431@fx09.iad>
<ufaudd$1dfn9$1@dont-email.me> <2ShSM.259308$vMO8.78214@fx16.iad>
<ufcfpo$2f5v7$1@dont-email.me>
From: Richard@Damon-Family.org (Richard Damon)
In-Reply-To: <ufcfpo$2f5v7$1@dont-email.me>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Lines: 28
Message-ID: <I%jSM.193899$noZ7.183010@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: Sun, 1 Oct 2023 15:45:44 -0400
X-Received-Bytes: 2717
 by: Richard Damon - Sun, 1 Oct 2023 19:45 UTC

On 10/1/23 3:03 PM, Bonita Montero wrote:
> Am 01.10.2023 um 19:18 schrieb Richard Damon:
>
>> No, the Standard establishes the rules, and the standard say that the
>> static initialization synchronization can't fail, so if std::mutex
>> might fail for this sort of lock, the implementation can't use a
>> std::mutex to do that synchronization.
>
> But the standard should mandate that this might fail and throw
> a system_error to work with any conditions.
>
> Rest unread.
>

Why? You don't seem to understand how Stzndards work, and are just
ADMITTING to being ignorant.

YOUR LOSS.

The standard ALLOWS a mutex lock to fail, as there are operating
conditions when this might happen, either due to "misuse" of the Mutex,
or making a stronger inter-process mutex that needs system resources.

Static initialization just isn't allowed to use such broken methods.

Thank you for letting the world know that we can not trust any program
that you create, as you don't understand that programs need to do what
they are supposed to do.

Re: Thread-safe initialization of static objects

<l8nSM.46550$TwR4.32061@fx46.iad>

  copy mid

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

  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!fx46.iad.POSTED!not-for-mail
Subject: Re: Thread-safe initialization of static objects
Newsgroups: comp.lang.c++
References: <udafjf$2joeq$1@dont-email.me> <MTUPM.158223$Hih7.125749@fx11.iad>
<uep6pj$1b36d$1@dont-email.me> <byVPM.165856$Hih7.109980@fx11.iad>
<uep8vu$1bect$1@dont-email.me> <PKZPM.232647$ZXz4.71820@fx18.iad>
<ueqfkl$1i6un$2@dont-email.me> <Fa5QM.124660$1B%c.102962@fx09.iad>
<uerem0$1qg8s$1@dont-email.me> <ZYdQM.67167$3vM.17655@fx37.iad>
<uerv9b$1tqis$1@dont-email.me> <LJoQM.19137$EIy4.5875@fx48.iad>
<uetn46$2bkun$1@dont-email.me> <3bzQM.36476$q0k.14387@fx34.iad>
<ueuj9u$2gdqk$3@dont-email.me> <eJCQM.35600$ugs.8334@fx36.iad>
<ueutjo$2ii89$2@dont-email.me> <S%pRM.268878$2ph4.195852@fx14.iad>
<uf6ecm$8rfg$1@dont-email.me> <n0NRM.30341$NkG.4566@fx41.iad>
<uf8dve$nt9u$1@dont-email.me> <ssZRM.206761$1B%c.192431@fx09.iad>
<ufaudd$1dfn9$1@dont-email.me>
From: pauldontspamtolk@removeyourself.dontspam.yahoo (Pavel)
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
Firefox/91.0 SeaMonkey/2.53.17.1
MIME-Version: 1.0
In-Reply-To: <ufaudd$1dfn9$1@dont-email.me>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Lines: 18
Message-ID: <l8nSM.46550$TwR4.32061@fx46.iad>
X-Complaints-To: https://www.astraweb.com/aup
NNTP-Posting-Date: Sun, 01 Oct 2023 23:19:45 UTC
Date: Sun, 1 Oct 2023 19:19:37 -0400
X-Received-Bytes: 2174
 by: Pavel - Sun, 1 Oct 2023 23:19 UTC

Bonita Montero wrote:
> Am 30.09.2023 um 20:06 schrieb Pavel:
>
>> This does not prove that the kernel call to acquire the primitive may
>> fail. ...
>
> This has not to be proven, but this has to be assumed by the standard.
> mutex::lock() can throw system_error for that:
Nope. The standard never says this specifically about mutex::lock. Only
about all mutices collectively. Then about every other mutex *apart
from* std::mutex. Regardless, even the standards says that about
std::mutex, this would still not mean that C++ variable initialization
may throw system_error because the standard never says that such
initialization shall be implemented using std::mutex.

>
> Rest unread.
One more broken promise?

Re: Thread-safe initialization of static objects

<ufdemr$2p2ch$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Bonita.Montero@gmail.com (Bonita Montero)
Newsgroups: comp.lang.c++
Subject: Re: Thread-safe initialization of static objects
Date: Mon, 2 Oct 2023 05:50:53 +0200
Organization: A noiseless patient Spider
Lines: 7
Message-ID: <ufdemr$2p2ch$1@dont-email.me>
References: <udafjf$2joeq$1@dont-email.me> <MTUPM.158223$Hih7.125749@fx11.iad>
<uep6pj$1b36d$1@dont-email.me> <byVPM.165856$Hih7.109980@fx11.iad>
<uep8vu$1bect$1@dont-email.me> <PKZPM.232647$ZXz4.71820@fx18.iad>
<ueqfkl$1i6un$2@dont-email.me> <Fa5QM.124660$1B%c.102962@fx09.iad>
<uerem0$1qg8s$1@dont-email.me> <ZYdQM.67167$3vM.17655@fx37.iad>
<uerv9b$1tqis$1@dont-email.me> <LJoQM.19137$EIy4.5875@fx48.iad>
<uetn46$2bkun$1@dont-email.me> <3bzQM.36476$q0k.14387@fx34.iad>
<ueuj9u$2gdqk$3@dont-email.me> <eJCQM.35600$ugs.8334@fx36.iad>
<ueutjo$2ii89$2@dont-email.me> <S%pRM.268878$2ph4.195852@fx14.iad>
<uf6ecm$8rfg$1@dont-email.me> <n0NRM.30341$NkG.4566@fx41.iad>
<uf8dve$nt9u$1@dont-email.me> <ssZRM.206761$1B%c.192431@fx09.iad>
<ufaudd$1dfn9$1@dont-email.me> <2ShSM.259308$vMO8.78214@fx16.iad>
<ufcfpo$2f5v7$1@dont-email.me> <I%jSM.193899$noZ7.183010@fx13.iad>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 2 Oct 2023 03:50:51 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="bb8cbd45ad1a17b9153633bfe066831e";
logging-data="2918801"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/BQ5L4Xg3rOw7LlvQe52plVTlpxpdhaJo="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:zifT9pk0q9l6ROCd7DJqAdQsir8=
Content-Language: de-DE
In-Reply-To: <I%jSM.193899$noZ7.183010@fx13.iad>
 by: Bonita Montero - Mon, 2 Oct 2023 03:50 UTC

Am 01.10.2023 um 21:45 schrieb Richard Damon:

> Static initialization just isn't allowed to use such broken methods.

That's not my opinion that this is a less method.
It's not more broken than a failing mutex.

Re: Thread-safe initialization of static objects

<ufdeog$2p2pl$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Bonita.Montero@gmail.com (Bonita Montero)
Newsgroups: comp.lang.c++
Subject: Re: Thread-safe initialization of static objects
Date: Mon, 2 Oct 2023 05:51:47 +0200
Organization: A noiseless patient Spider
Lines: 6
Message-ID: <ufdeog$2p2pl$1@dont-email.me>
References: <udafjf$2joeq$1@dont-email.me> <MTUPM.158223$Hih7.125749@fx11.iad>
<uep6pj$1b36d$1@dont-email.me> <byVPM.165856$Hih7.109980@fx11.iad>
<uep8vu$1bect$1@dont-email.me> <PKZPM.232647$ZXz4.71820@fx18.iad>
<ueqfkl$1i6un$2@dont-email.me> <Fa5QM.124660$1B%c.102962@fx09.iad>
<uerem0$1qg8s$1@dont-email.me> <ZYdQM.67167$3vM.17655@fx37.iad>
<uerv9b$1tqis$1@dont-email.me> <LJoQM.19137$EIy4.5875@fx48.iad>
<uetn46$2bkun$1@dont-email.me> <3bzQM.36476$q0k.14387@fx34.iad>
<ueuj9u$2gdqk$3@dont-email.me> <eJCQM.35600$ugs.8334@fx36.iad>
<ueutjo$2ii89$2@dont-email.me> <S%pRM.268878$2ph4.195852@fx14.iad>
<uf6ecm$8rfg$1@dont-email.me> <n0NRM.30341$NkG.4566@fx41.iad>
<uf8dve$nt9u$1@dont-email.me> <ssZRM.206761$1B%c.192431@fx09.iad>
<ufaudd$1dfn9$1@dont-email.me> <l8nSM.46550$TwR4.32061@fx46.iad>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 2 Oct 2023 03:51:44 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="bb8cbd45ad1a17b9153633bfe066831e";
logging-data="2919221"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/KM6n1EZTgfbkTuf4zgv4aOT7hxdxFxB0="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:7XN1plrxxlsCF+eVbjr3MJI/aSY=
Content-Language: de-DE
In-Reply-To: <l8nSM.46550$TwR4.32061@fx46.iad>
 by: Bonita Montero - Mon, 2 Oct 2023 03:51 UTC

Am 02.10.2023 um 01:19 schrieb Pavel:

> Nope. The standard never says this specifically about mutex::lock. ...

Of course, mutex::lock() may throw a system_error.

Re: Thread-safe initialization of static objects

<971828e2-0fba-4973-a6df-ee5d716fa9e6n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
X-Received: by 2002:a05:620a:688e:b0:76d:9ee4:2b2b with SMTP id rv14-20020a05620a688e00b0076d9ee42b2bmr130000qkn.15.1696246782831;
Mon, 02 Oct 2023 04:39:42 -0700 (PDT)
X-Received: by 2002:a05:6870:98af:b0:1c5:87d6:b779 with SMTP id
eg47-20020a05687098af00b001c587d6b779mr4321436oab.8.1696246782490; Mon, 02
Oct 2023 04:39:42 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c++
Date: Mon, 2 Oct 2023 04:39:41 -0700 (PDT)
In-Reply-To: <udafjf$2joeq$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=92.40.182.2; posting-account=w4UqJAoAAAAYC-PItfDbDoVGcg0yISyA
NNTP-Posting-Host: 92.40.182.2
References: <udafjf$2joeq$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <971828e2-0fba-4973-a6df-ee5d716fa9e6n@googlegroups.com>
Subject: Re: Thread-safe initialization of static objects
From: cauldwell.thomas@gmail.com (Frederick Virchanza Gotham)
Injection-Date: Mon, 02 Oct 2023 11:39:42 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 1975
 by: Frederick Virchanza - Mon, 2 Oct 2023 11:39 UTC

On Wednesday, September 6, 2023 at 7:15:29 PM UTC+1, Bonita Montero wrote:
>
> With C++11 static local or global data is initialized thread-safe.
> This is usually done with double checked locking (DCL). DCL needs
> a flag along with the static data which shows if the data already
> is initialized and a mutex which guards the initalization.
> I assumed that an implementation simply would use a central mutex
> for all static data objects since it includes a kernel semaphore,
> which is a costly resource.

In the following sample code, I would expect the implementations of Func1 and Func2 to be very similar, except that Func2 would also need to set a global flag somewhere indicating that 'myvec' should have its destructor called.

https://godbolt.org/z/1vcE6MEeK

Re: Thread-safe initialization of static objects

<ufeb2e$2u9vm$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Bonita.Montero@gmail.com (Bonita Montero)
Newsgroups: comp.lang.c++
Subject: Re: Thread-safe initialization of static objects
Date: Mon, 2 Oct 2023 13:54:56 +0200
Organization: A noiseless patient Spider
Lines: 7
Message-ID: <ufeb2e$2u9vm$1@dont-email.me>
References: <udafjf$2joeq$1@dont-email.me>
<971828e2-0fba-4973-a6df-ee5d716fa9e6n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 2 Oct 2023 11:54:54 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="bb8cbd45ad1a17b9153633bfe066831e";
logging-data="3090422"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+7RG32xSYhoh2JLHHvseG9qVOvkYJ/Sxk="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:dYwlsGse/A3PLv7h7cXY35d3TLc=
Content-Language: de-DE
In-Reply-To: <971828e2-0fba-4973-a6df-ee5d716fa9e6n@googlegroups.com>
 by: Bonita Montero - Mon, 2 Oct 2023 11:54 UTC

Am 02.10.2023 um 13:39 schrieb Frederick Virchanza Gotham:

> In the following sample code, I would expect the implementations of Func1 and Func2 to be very similar, except that Func2 would also need to set a global flag somewhere indicating that 'myvec' should have its destructor called.

static initialization of non-trivial types is usually done
with DCL - no need to instantiate the object yourself.

Re: Thread-safe initialization of static objects

<AdySM.46105$hC28.27892@fx01.iad>

  copy mid

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

  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!fx01.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> <MTUPM.158223$Hih7.125749@fx11.iad>
<uep6pj$1b36d$1@dont-email.me> <byVPM.165856$Hih7.109980@fx11.iad>
<uep8vu$1bect$1@dont-email.me> <PKZPM.232647$ZXz4.71820@fx18.iad>
<ueqfkl$1i6un$2@dont-email.me> <Fa5QM.124660$1B%c.102962@fx09.iad>
<uerem0$1qg8s$1@dont-email.me> <ZYdQM.67167$3vM.17655@fx37.iad>
<uerv9b$1tqis$1@dont-email.me> <LJoQM.19137$EIy4.5875@fx48.iad>
<uetn46$2bkun$1@dont-email.me> <3bzQM.36476$q0k.14387@fx34.iad>
<ueuj9u$2gdqk$3@dont-email.me> <eJCQM.35600$ugs.8334@fx36.iad>
<ueutjo$2ii89$2@dont-email.me> <S%pRM.268878$2ph4.195852@fx14.iad>
<uf6ecm$8rfg$1@dont-email.me> <n0NRM.30341$NkG.4566@fx41.iad>
<uf8dve$nt9u$1@dont-email.me> <ssZRM.206761$1B%c.192431@fx09.iad>
<ufaudd$1dfn9$1@dont-email.me> <2ShSM.259308$vMO8.78214@fx16.iad>
<ufcfpo$2f5v7$1@dont-email.me> <I%jSM.193899$noZ7.183010@fx13.iad>
<ufdemr$2p2ch$1@dont-email.me>
From: Richard@Damon-Family.org (Richard Damon)
In-Reply-To: <ufdemr$2p2ch$1@dont-email.me>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Lines: 12
Message-ID: <AdySM.46105$hC28.27892@fx01.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, 2 Oct 2023 07:56:15 -0400
X-Received-Bytes: 1999
 by: Richard Damon - Mon, 2 Oct 2023 11:56 UTC

On 10/1/23 11:50 PM, Bonita Montero wrote:
> Am 01.10.2023 um 21:45 schrieb Richard Damon:
>
>> Static initialization just isn't allowed to use such broken methods.
>
> That's not my opinion that this is a less method.
> It's not more broken than a failing mutex.
>

So, you admit that you don't mind you code being broken.

Thanks for letting the world know.

Re: Thread-safe initialization of static objects

<ufebdc$2ucee$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Bonita.Montero@gmail.com (Bonita Montero)
Newsgroups: comp.lang.c++
Subject: Re: Thread-safe initialization of static objects
Date: Mon, 2 Oct 2023 14:00:47 +0200
Organization: A noiseless patient Spider
Lines: 11
Message-ID: <ufebdc$2ucee$1@dont-email.me>
References: <udafjf$2joeq$1@dont-email.me> <MTUPM.158223$Hih7.125749@fx11.iad>
<uep6pj$1b36d$1@dont-email.me> <byVPM.165856$Hih7.109980@fx11.iad>
<uep8vu$1bect$1@dont-email.me> <PKZPM.232647$ZXz4.71820@fx18.iad>
<ueqfkl$1i6un$2@dont-email.me> <Fa5QM.124660$1B%c.102962@fx09.iad>
<uerem0$1qg8s$1@dont-email.me> <ZYdQM.67167$3vM.17655@fx37.iad>
<uerv9b$1tqis$1@dont-email.me> <LJoQM.19137$EIy4.5875@fx48.iad>
<uetn46$2bkun$1@dont-email.me> <3bzQM.36476$q0k.14387@fx34.iad>
<ueuj9u$2gdqk$3@dont-email.me> <eJCQM.35600$ugs.8334@fx36.iad>
<ueutjo$2ii89$2@dont-email.me> <S%pRM.268878$2ph4.195852@fx14.iad>
<uf6ecm$8rfg$1@dont-email.me> <n0NRM.30341$NkG.4566@fx41.iad>
<uf8dve$nt9u$1@dont-email.me> <ssZRM.206761$1B%c.192431@fx09.iad>
<ufaudd$1dfn9$1@dont-email.me> <2ShSM.259308$vMO8.78214@fx16.iad>
<ufcfpo$2f5v7$1@dont-email.me> <I%jSM.193899$noZ7.183010@fx13.iad>
<ufdemr$2p2ch$1@dont-email.me> <AdySM.46105$hC28.27892@fx01.iad>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 2 Oct 2023 12:00:44 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="bb8cbd45ad1a17b9153633bfe066831e";
logging-data="3092942"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18J+QKmA38L1q7zUVfP8ALTHJgqZ2dgNh8="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:g+/9U7uX2cipVxayGDsaD34dBkU=
In-Reply-To: <AdySM.46105$hC28.27892@fx01.iad>
Content-Language: de-DE
 by: Bonita Montero - Mon, 2 Oct 2023 12:00 UTC

Am 02.10.2023 um 13:56 schrieb Richard Damon:

> On 10/1/23 11:50 PM, Bonita Montero wrote:

>> That's not my opinion that this is a less method.
>> It's not more broken than a failing mutex.

> So, you admit that you don't mind you code being broken.

No, I wouldn't consider that as broken.

Re: Thread-safe initialization of static objects

<flySM.36535$EPT1.7419@fx02.iad>

  copy mid

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

  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!fx02.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> <MTUPM.158223$Hih7.125749@fx11.iad>
<uep6pj$1b36d$1@dont-email.me> <byVPM.165856$Hih7.109980@fx11.iad>
<uep8vu$1bect$1@dont-email.me> <PKZPM.232647$ZXz4.71820@fx18.iad>
<ueqfkl$1i6un$2@dont-email.me> <Fa5QM.124660$1B%c.102962@fx09.iad>
<uerem0$1qg8s$1@dont-email.me> <ZYdQM.67167$3vM.17655@fx37.iad>
<uerv9b$1tqis$1@dont-email.me> <LJoQM.19137$EIy4.5875@fx48.iad>
<uetn46$2bkun$1@dont-email.me> <3bzQM.36476$q0k.14387@fx34.iad>
<ueuj9u$2gdqk$3@dont-email.me> <eJCQM.35600$ugs.8334@fx36.iad>
<ueutjo$2ii89$2@dont-email.me> <S%pRM.268878$2ph4.195852@fx14.iad>
<uf6ecm$8rfg$1@dont-email.me> <n0NRM.30341$NkG.4566@fx41.iad>
<uf8dve$nt9u$1@dont-email.me> <ssZRM.206761$1B%c.192431@fx09.iad>
<ufaudd$1dfn9$1@dont-email.me> <2ShSM.259308$vMO8.78214@fx16.iad>
<ufcfpo$2f5v7$1@dont-email.me> <I%jSM.193899$noZ7.183010@fx13.iad>
<ufdemr$2p2ch$1@dont-email.me> <AdySM.46105$hC28.27892@fx01.iad>
<ufebdc$2ucee$1@dont-email.me>
From: Richard@Damon-Family.org (Richard Damon)
In-Reply-To: <ufebdc$2ucee$1@dont-email.me>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Lines: 14
Message-ID: <flySM.36535$EPT1.7419@fx02.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, 2 Oct 2023 08:04:27 -0400
X-Received-Bytes: 2103
 by: Richard Damon - Mon, 2 Oct 2023 12:04 UTC

On 10/2/23 8:00 AM, Bonita Montero wrote:
> Am 02.10.2023 um 13:56 schrieb Richard Damon:
>
>> On 10/1/23 11:50 PM, Bonita Montero wrote:
>
>>> That's not my opinion that this is a less method.
>>> It's not more broken than a failing mutex.
>
>> So, you admit that you don't mind you code being broken.
>
> No, I wouldn't consider that as broken.
>

So, you don't know that you code is broken?

Re: Thread-safe initialization of static objects

<ufehf7$2vf25$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!rocksolid2!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Bonita.Montero@gmail.com (Bonita Montero)
Newsgroups: comp.lang.c++
Subject: Re: Thread-safe initialization of static objects
Date: Mon, 2 Oct 2023 15:44:09 +0200
Organization: A noiseless patient Spider
Lines: 12
Message-ID: <ufehf7$2vf25$1@dont-email.me>
References: <udafjf$2joeq$1@dont-email.me> <MTUPM.158223$Hih7.125749@fx11.iad>
<uep6pj$1b36d$1@dont-email.me> <byVPM.165856$Hih7.109980@fx11.iad>
<uep8vu$1bect$1@dont-email.me> <PKZPM.232647$ZXz4.71820@fx18.iad>
<ueqfkl$1i6un$2@dont-email.me> <Fa5QM.124660$1B%c.102962@fx09.iad>
<uerem0$1qg8s$1@dont-email.me> <ZYdQM.67167$3vM.17655@fx37.iad>
<uerv9b$1tqis$1@dont-email.me> <LJoQM.19137$EIy4.5875@fx48.iad>
<uetn46$2bkun$1@dont-email.me> <3bzQM.36476$q0k.14387@fx34.iad>
<ueuj9u$2gdqk$3@dont-email.me> <eJCQM.35600$ugs.8334@fx36.iad>
<ueutjo$2ii89$2@dont-email.me> <S%pRM.268878$2ph4.195852@fx14.iad>
<uf6ecm$8rfg$1@dont-email.me> <n0NRM.30341$NkG.4566@fx41.iad>
<uf8dve$nt9u$1@dont-email.me> <ssZRM.206761$1B%c.192431@fx09.iad>
<ufaudd$1dfn9$1@dont-email.me> <2ShSM.259308$vMO8.78214@fx16.iad>
<ufcfpo$2f5v7$1@dont-email.me> <I%jSM.193899$noZ7.183010@fx13.iad>
<ufdemr$2p2ch$1@dont-email.me> <AdySM.46105$hC28.27892@fx01.iad>
<ufebdc$2ucee$1@dont-email.me> <flySM.36535$EPT1.7419@fx02.iad>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 2 Oct 2023 13:44:07 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="bb8cbd45ad1a17b9153633bfe066831e";
logging-data="3128389"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19lid/KtUZHILTZyW6mtDmvKtOMB9gMMo0="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:BqDDvFgsDF+tlvtqi92yaFUKxlY=
Content-Language: de-DE
In-Reply-To: <flySM.36535$EPT1.7419@fx02.iad>
 by: Bonita Montero - Mon, 2 Oct 2023 13:44 UTC

Am 02.10.2023 um 14:04 schrieb Richard Damon:

> On 10/2/23 8:00 AM, Bonita Montero wrote:

>> No, I wouldn't consider that as broken.

> So, you don't know that you code is broken?

For me it wouldn't be broken since the scope of the object whose
inintialization is failed is also left, so that the object can't
be addressed.

Re: Thread-safe initialization of static objects

<uff51a$338dm$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: chris.m.thomasson.1@gmail.com (Chris M. Thomasson)
Newsgroups: comp.lang.c++
Subject: Re: Thread-safe initialization of static objects
Date: Mon, 2 Oct 2023 12:18:02 -0700
Organization: A noiseless patient Spider
Lines: 17
Message-ID: <uff51a$338dm$1@dont-email.me>
References: <udafjf$2joeq$1@dont-email.me> <MTUPM.158223$Hih7.125749@fx11.iad>
<uep6pj$1b36d$1@dont-email.me> <byVPM.165856$Hih7.109980@fx11.iad>
<uep8vu$1bect$1@dont-email.me> <PKZPM.232647$ZXz4.71820@fx18.iad>
<ueqfkl$1i6un$2@dont-email.me> <Fa5QM.124660$1B%c.102962@fx09.iad>
<uerem0$1qg8s$1@dont-email.me> <ZYdQM.67167$3vM.17655@fx37.iad>
<uerv9b$1tqis$1@dont-email.me> <LJoQM.19137$EIy4.5875@fx48.iad>
<uetn46$2bkun$1@dont-email.me> <3bzQM.36476$q0k.14387@fx34.iad>
<ueuj9u$2gdqk$3@dont-email.me> <eJCQM.35600$ugs.8334@fx36.iad>
<ueutjo$2ii89$2@dont-email.me> <S%pRM.268878$2ph4.195852@fx14.iad>
<uf6ecm$8rfg$1@dont-email.me> <n0NRM.30341$NkG.4566@fx41.iad>
<uf8dve$nt9u$1@dont-email.me> <ssZRM.206761$1B%c.192431@fx09.iad>
<ufaudd$1dfn9$1@dont-email.me> <2ShSM.259308$vMO8.78214@fx16.iad>
<ufcfpo$2f5v7$1@dont-email.me> <I%jSM.193899$noZ7.183010@fx13.iad>
<ufdemr$2p2ch$1@dont-email.me> <AdySM.46105$hC28.27892@fx01.iad>
<ufebdc$2ucee$1@dont-email.me> <flySM.36535$EPT1.7419@fx02.iad>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 2 Oct 2023 19:18:03 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="377a9593523ae8d676f699571640eb13";
logging-data="3252662"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19/KIReVm8BNQJaI2oE4hM4K8vnQFZLosc="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.15.1
Cancel-Lock: sha1:S5ZFdgcEQS8FESmUAjrn/qy7av0=
Content-Language: en-US
In-Reply-To: <flySM.36535$EPT1.7419@fx02.iad>
 by: Chris M. Thomasson - Mon, 2 Oct 2023 19:18 UTC

On 10/2/2023 5:04 AM, Richard Damon wrote:
> On 10/2/23 8:00 AM, Bonita Montero wrote:
>> Am 02.10.2023 um 13:56 schrieb Richard Damon:
>>
>>> On 10/1/23 11:50 PM, Bonita Montero wrote:
>>
>>>> That's not my opinion that this is a less method.
>>>> It's not more broken than a failing mutex.
>>
>>> So, you admit that you don't mind you code being broken.
>>
>> No, I wouldn't consider that as broken.
>>
>
> So, you don't know that you code is broken?

Most likely?

Re: Thread-safe initialization of static objects

<LXKSM.296263$GHI6.117665@fx17.iad>

  copy mid

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

  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
Subject: Re: Thread-safe initialization of static objects
Newsgroups: comp.lang.c++
References: <udafjf$2joeq$1@dont-email.me> <MTUPM.158223$Hih7.125749@fx11.iad>
<uep6pj$1b36d$1@dont-email.me> <byVPM.165856$Hih7.109980@fx11.iad>
<uep8vu$1bect$1@dont-email.me> <PKZPM.232647$ZXz4.71820@fx18.iad>
<ueqfkl$1i6un$2@dont-email.me> <Fa5QM.124660$1B%c.102962@fx09.iad>
<uerem0$1qg8s$1@dont-email.me> <ZYdQM.67167$3vM.17655@fx37.iad>
<uerv9b$1tqis$1@dont-email.me> <LJoQM.19137$EIy4.5875@fx48.iad>
<uetn46$2bkun$1@dont-email.me> <3bzQM.36476$q0k.14387@fx34.iad>
<ueuj9u$2gdqk$3@dont-email.me> <eJCQM.35600$ugs.8334@fx36.iad>
<ueutjo$2ii89$2@dont-email.me> <S%pRM.268878$2ph4.195852@fx14.iad>
<uf6ecm$8rfg$1@dont-email.me> <n0NRM.30341$NkG.4566@fx41.iad>
<uf8dve$nt9u$1@dont-email.me> <ssZRM.206761$1B%c.192431@fx09.iad>
<ufaudd$1dfn9$1@dont-email.me> <l8nSM.46550$TwR4.32061@fx46.iad>
<ufdeog$2p2pl$1@dont-email.me>
From: pauldontspamtolk@removeyourself.dontspam.yahoo (Pavel)
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
Firefox/91.0 SeaMonkey/2.53.17.1
MIME-Version: 1.0
In-Reply-To: <ufdeog$2p2pl$1@dont-email.me>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Lines: 9
Message-ID: <LXKSM.296263$GHI6.117665@fx17.iad>
X-Complaints-To: https://www.astraweb.com/aup
NNTP-Posting-Date: Tue, 03 Oct 2023 02:24:43 UTC
Date: Mon, 2 Oct 2023 22:24:43 -0400
X-Received-Bytes: 1849
 by: Pavel - Tue, 3 Oct 2023 02:24 UTC

Bonita Montero wrote:
> Am 02.10.2023 um 01:19 schrieb Pavel:
>
>> Nope. The standard never says this specifically about mutex::lock. ...
>
> Of course, mutex::lock() may throw a system_error.
>
The standard does not say that; but, even if it did, it wouldn't follow
it needed to permit C++ static initialization throw system_error.

Re: Thread-safe initialization of static objects

<l%KSM.296264$GHI6.130562@fx17.iad>

  copy mid

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

  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
Subject: Re: Thread-safe initialization of static objects
Newsgroups: comp.lang.c++
References: <udafjf$2joeq$1@dont-email.me>
<971828e2-0fba-4973-a6df-ee5d716fa9e6n@googlegroups.com>
<ufeb2e$2u9vm$1@dont-email.me>
From: pauldontspamtolk@removeyourself.dontspam.yahoo (Pavel)
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
Firefox/91.0 SeaMonkey/2.53.17.1
MIME-Version: 1.0
In-Reply-To: <ufeb2e$2u9vm$1@dont-email.me>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Lines: 13
Message-ID: <l%KSM.296264$GHI6.130562@fx17.iad>
X-Complaints-To: https://www.astraweb.com/aup
NNTP-Posting-Date: Tue, 03 Oct 2023 02:28:33 UTC
Date: Mon, 2 Oct 2023 22:28:26 -0400
X-Received-Bytes: 1350
 by: Pavel - Tue, 3 Oct 2023 02:28 UTC

Bonita Montero wrote:
> Am 02.10.2023 um 13:39 schrieb Frederick Virchanza Gotham:
>
>> In the following sample code, I would expect the implementations of
>> Func1 and Func2 to be very similar, except that Func2 would also need
>> to set a global flag somewhere indicating that 'myvec' should have its
>> destructor called.
>
> static initialization of non-trivial types is usually done
> with DCL - no need to instantiate the object yourself.
>
What is a "non-trivial" type and where did you find it initialized in
the code by Frederick?

Re: Thread-safe initialization of static objects

<uffuts$3bpf5$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: chris.m.thomasson.1@gmail.com (Chris M. Thomasson)
Newsgroups: comp.lang.c++
Subject: Re: Thread-safe initialization of static objects
Date: Mon, 2 Oct 2023 19:39:55 -0700
Organization: A noiseless patient Spider
Lines: 43
Message-ID: <uffuts$3bpf5$1@dont-email.me>
References: <udafjf$2joeq$1@dont-email.me> <MTUPM.158223$Hih7.125749@fx11.iad>
<uep6pj$1b36d$1@dont-email.me> <byVPM.165856$Hih7.109980@fx11.iad>
<uep8vu$1bect$1@dont-email.me> <PKZPM.232647$ZXz4.71820@fx18.iad>
<ueqfkl$1i6un$2@dont-email.me> <Fa5QM.124660$1B%c.102962@fx09.iad>
<uerem0$1qg8s$1@dont-email.me> <ZYdQM.67167$3vM.17655@fx37.iad>
<uerv9b$1tqis$1@dont-email.me> <LJoQM.19137$EIy4.5875@fx48.iad>
<uetn46$2bkun$1@dont-email.me> <3bzQM.36476$q0k.14387@fx34.iad>
<ueuj9u$2gdqk$3@dont-email.me> <eJCQM.35600$ugs.8334@fx36.iad>
<ueutjo$2ii89$2@dont-email.me> <S%pRM.268878$2ph4.195852@fx14.iad>
<uf6ecm$8rfg$1@dont-email.me> <n0NRM.30341$NkG.4566@fx41.iad>
<uf8dve$nt9u$1@dont-email.me> <ssZRM.206761$1B%c.192431@fx09.iad>
<ufaudd$1dfn9$1@dont-email.me> <l8nSM.46550$TwR4.32061@fx46.iad>
<ufdeog$2p2pl$1@dont-email.me> <LXKSM.296263$GHI6.117665@fx17.iad>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 3 Oct 2023 02:39:56 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="cd2ff4e14c40a5b02e43003ab9e86230";
logging-data="3532261"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+o4na2SY+0dry3FlD9h6SX8qS7Ok8wrec="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.15.1
Cancel-Lock: sha1:alSd2/TDqoNCcUf3FZe4hwuls6M=
Content-Language: en-US
In-Reply-To: <LXKSM.296263$GHI6.117665@fx17.iad>
 by: Chris M. Thomasson - Tue, 3 Oct 2023 02:39 UTC

On 10/2/2023 7:24 PM, Pavel wrote:
> Bonita Montero wrote:
>> Am 02.10.2023 um 01:19 schrieb Pavel:
>>
>>> Nope. The standard never says this specifically about mutex::lock. ...
>>
>> Of course, mutex::lock() may throw a system_error.
>>
> The standard does not say that; but, even if it did, it wouldn't follow
> it needed to permit C++ static initialization throw system_error.

Bonita must be referring to:

https://cplusplus.com/reference/mutex/mutex/lock/

Read carefully:
_____________________________
Exception safety
Basic guarantee: if an exception is thrown by this member function, the
mutex object is left in a valid state. Further, a lock is never acquired
by the thread that made the throwing call.
If the mutex is already locked by the current thread, calling this
function causes a deadlock (undefined behavior): on certain library
implementations, this causes the function to fail.

If the call fails, a system_error exception is thrown:
exception type error condition description
system_error errc::resource_deadlock_would_occur A deadlock was detected
(implementations may detect certain cases of deadlock).
system_error errc::operation_not_permitted The thread does not have
privileges to perform the operation.
system_error errc::device_or_resource_busy The native handle type
manipulated is already locked.
Depending on the library implementation, this member function may also
throw exceptions to report other situations.
_____________________________

Basically, undefined behavior and bad user code causes the function to
fail, robust mutex aside for a moment. It kind of sorta seems like some
of Bonita's code must be saturated with undefined behavior, so it must
try to handle it somehow... I know, it says out loud, lets change the
standard! Oh shit.... Yikes!

Re: Thread-safe initialization of static objects

<aVLSM.230967$Hih7.113801@fx11.iad>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.quux.org!1.us.feeder.erje.net!3.us.feeder.erje.net!feeder.erje.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer01.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> <MTUPM.158223$Hih7.125749@fx11.iad>
<uep6pj$1b36d$1@dont-email.me> <byVPM.165856$Hih7.109980@fx11.iad>
<uep8vu$1bect$1@dont-email.me> <PKZPM.232647$ZXz4.71820@fx18.iad>
<ueqfkl$1i6un$2@dont-email.me> <Fa5QM.124660$1B%c.102962@fx09.iad>
<uerem0$1qg8s$1@dont-email.me> <ZYdQM.67167$3vM.17655@fx37.iad>
<uerv9b$1tqis$1@dont-email.me> <LJoQM.19137$EIy4.5875@fx48.iad>
<uetn46$2bkun$1@dont-email.me> <3bzQM.36476$q0k.14387@fx34.iad>
<ueuj9u$2gdqk$3@dont-email.me> <eJCQM.35600$ugs.8334@fx36.iad>
<ueutjo$2ii89$2@dont-email.me> <S%pRM.268878$2ph4.195852@fx14.iad>
<uf6ecm$8rfg$1@dont-email.me> <n0NRM.30341$NkG.4566@fx41.iad>
<uf8dve$nt9u$1@dont-email.me> <ssZRM.206761$1B%c.192431@fx09.iad>
<ufaudd$1dfn9$1@dont-email.me> <l8nSM.46550$TwR4.32061@fx46.iad>
<ufdeog$2p2pl$1@dont-email.me> <LXKSM.296263$GHI6.117665@fx17.iad>
<uffuts$3bpf5$1@dont-email.me>
From: pauldontspamtolk@removeyourself.dontspam.yahoo (Pavel)
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
Firefox/91.0 SeaMonkey/2.53.17.1
MIME-Version: 1.0
In-Reply-To: <uffuts$3bpf5$1@dont-email.me>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Lines: 166
Message-ID: <aVLSM.230967$Hih7.113801@fx11.iad>
X-Complaints-To: https://www.astraweb.com/aup
NNTP-Posting-Date: Tue, 03 Oct 2023 03:30:14 UTC
Date: Mon, 2 Oct 2023 23:30:13 -0400
X-Received-Bytes: 8473
 by: Pavel - Tue, 3 Oct 2023 03:30 UTC

Chris M. Thomasson wrote:
> On 10/2/2023 7:24 PM, Pavel wrote:
>> Bonita Montero wrote:
>>> Am 02.10.2023 um 01:19 schrieb Pavel:
>>>
>>>> Nope. The standard never says this specifically about mutex::lock. ...
>>>
>>> Of course, mutex::lock() may throw a system_error.
>>>
>> The standard does not say that; but, even if it did, it wouldn't
>> follow it needed to permit C++ static initialization throw system_error.
>
> Bonita must be referring to:
>
> https://cplusplus.com/reference/mutex/mutex/lock/
>
> Read carefully:
> _____________________________
> Exception safety
> Basic guarantee: if an exception is thrown by this member function, the
> mutex object is left in a valid state. Further, a lock is never acquired
> by the thread that made the throwing call.
> If the mutex is already locked by the current thread, calling this
> function causes a deadlock (undefined behavior): on certain library
> implementations, this causes the function to fail.
>
> If the call fails, a system_error exception is thrown:
> exception type    error condition    description
> system_error    errc::resource_deadlock_would_occur    A deadlock was
> detected (implementations may detect certain cases of deadlock).
> system_error    errc::operation_not_permitted    The thread does not
> have privileges to perform the operation.
> system_error    errc::device_or_resource_busy    The native handle type
> manipulated is already locked.
> Depending on the library implementation, this member function may also
> throw exceptions to report other situations.
> _____________________________
>
>
> Basically, undefined behavior and bad user code causes the function to
> fail, robust mutex aside for a moment. It kind of sorta seems like some
> of Bonita's code must be saturated with undefined behavior, so it must
> try to handle it somehow... I know, it says out loud, lets change the
> standard! Oh shit.... Yikes!
Well, this is not the standard. The standards says, literally:

------ cut here ---------
33.6.4
1 1
Mutex requirements
[thread.mutex.requirements]
33.6.4.1 In general
[thread.mutex.requirements.general]
A mutex object facilitates protection against data races and allows safe
synchronization of data between
execution agents (33.2.5). An execution agent owns a mutex from the time
it successfully calls one of the lock
functions until it calls unlock. Mutexes can be either recursive or
non-recursive, and can grant simultaneous
ownership to one or many execution agents. Both recursive and
non-recursive mutexes are supplied.
33.6.4.2 Mutex types
[thread.mutex.requirements.mutex]
33.6.4.2.1 General
[thread.mutex.requirements.mutex.general]
The mutex types are the standard library types mutex, recursive_mutex,
timed_mutex, recursive_timed_-
mutex, shared_mutex, and shared_timed_mutex. They meet the requirements
set out in 33.6.4.2. In this
description, m denotes an object of a mutex type.
[Note 1 : The mutex types meet the Cpp17Lockable requirements
(33.2.5.3). — end note]
2The mutex types meet Cpp17DefaultConstructible and Cpp17Destructible.
If initialization of an object of a
mutex type fails, an exception of type system_error is thrown. The mutex
types are neither copyable nor
movable.
3The error conditions for error codes, if any, reported by member
functions of the mutex types are as follows:
------ cut here ---------

So she read this far and got tired and decided std::mutex is allowed to
throw. But she should have read the whole thing:

------ cut here ---------
....
Throws: system_error when an exception is required (33.2.2).
------ cut here ---------

and here is what 33.2.2 has to say:
------ cut here ---------
33.2.2
1 [thread]
Exceptions
[thread.req.exception]
Some functions described in this Clause are specified to throw
exceptions of type system_error (19.5.8).
Such exceptions are thrown if any of the function’s error conditions is
detected or a call to an operating system
or other underlying API results in an error that prevents the library
function from meeting its specifications.
Failure to allocate storage is reported as described in 16.4.6.13.
[Example 1 : Consider a function in this Clause that is specified to
throw exceptions of type system_error and specifies
error conditions that include operation_not_permitted for a thread that
does not have the privilege to perform the
operation. Assume that, during the execution of this function, an errno
of EPERM is reported by a POSIX API call
used by the implementation. Since POSIX specifies an errno of EPERM when
“the caller does not have the privilege to
perform the operation”, the implementation maps EPERM to an
error_condition of operation_not_permitted (19.5)
and an exception of type system_error is thrown. — end example]
------ cut here ---------

In other words, lock is allowed to throw *if the underlying OS or API
creates some error condition* -- which a simple POSIX mutex or
pthread_once doesn't -- or "the function's" error condition is defined.
And those error conditions are defined in requirements for lock for
specific mutex types (but Bonita is a writer, she does not need to
read). And for std::mutex:

------- cut here ---------
36.6.4.2.2:
(Class mutex, that is std::mutex)
....
If one thread owns a
mutex object, attempts by another thread to acquire ownership of that
object will fail (for try_lock()) or
block (for lock()) until the owning thread has released ownership with a
call to unlock().
...
If the
implementation can detect the deadlock, a resource_deadlock_would_occur
error condition might be observed.
....
------- cut here ---------
Above is the only error condition that is defined for mutex::lock -- and
it does not apply to Windows or simple POSIX mutices implementation
would use for C++ static initialization (extra cost and complexity, no
benefits and standard non-compliance -- why would anyone used
deadlock-detecting mutex?).

For all other mutex types (not reasonably usable for static
initiazlization), the standard explicitly defines error conditions and
does mentions that they can throw system_error, e.g. for a recursive_mutex:

------- cut here ---------
33.6.4.2.3
Class recursive_mutex
....
If a thread has already acquired the maximum level of ownership for a
recursive_mutex object,
additional calls to try_lock() fail, and additional calls to lock()
throw an exception of type system_error.
------- cut here ---------

Same for timed and shared mutices -- but std::mutex is an exception
(above).

But of course none of the above matters for the subject because C++
mutices don't have to be used (and in fact not used) to implement C++
static variable implementation.

Re: Thread-safe initialization of static objects

<ufg4nn$3cpgp$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Bonita.Montero@gmail.com (Bonita Montero)
Newsgroups: comp.lang.c++
Subject: Re: Thread-safe initialization of static objects
Date: Tue, 3 Oct 2023 06:19:06 +0200
Organization: A noiseless patient Spider
Lines: 14
Message-ID: <ufg4nn$3cpgp$1@dont-email.me>
References: <udafjf$2joeq$1@dont-email.me> <MTUPM.158223$Hih7.125749@fx11.iad>
<uep6pj$1b36d$1@dont-email.me> <byVPM.165856$Hih7.109980@fx11.iad>
<uep8vu$1bect$1@dont-email.me> <PKZPM.232647$ZXz4.71820@fx18.iad>
<ueqfkl$1i6un$2@dont-email.me> <Fa5QM.124660$1B%c.102962@fx09.iad>
<uerem0$1qg8s$1@dont-email.me> <ZYdQM.67167$3vM.17655@fx37.iad>
<uerv9b$1tqis$1@dont-email.me> <LJoQM.19137$EIy4.5875@fx48.iad>
<uetn46$2bkun$1@dont-email.me> <3bzQM.36476$q0k.14387@fx34.iad>
<ueuj9u$2gdqk$3@dont-email.me> <eJCQM.35600$ugs.8334@fx36.iad>
<ueutjo$2ii89$2@dont-email.me> <S%pRM.268878$2ph4.195852@fx14.iad>
<uf6ecm$8rfg$1@dont-email.me> <n0NRM.30341$NkG.4566@fx41.iad>
<uf8dve$nt9u$1@dont-email.me> <ssZRM.206761$1B%c.192431@fx09.iad>
<ufaudd$1dfn9$1@dont-email.me> <l8nSM.46550$TwR4.32061@fx46.iad>
<ufdeog$2p2pl$1@dont-email.me> <LXKSM.296263$GHI6.117665@fx17.iad>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 3 Oct 2023 04:19:03 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="485eca7af7972ec2e41e655d59aee6d8";
logging-data="3565081"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+Flh5snLJZHXp/HE0FvCRF0RaBlFUBKiA="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:bG32DIZ+kWTs9WFL5nO76HmJxc0=
Content-Language: de-DE
In-Reply-To: <LXKSM.296263$GHI6.117665@fx17.iad>
 by: Bonita Montero - Tue, 3 Oct 2023 04:19 UTC

Am 03.10.2023 um 04:24 schrieb Pavel:
> Bonita Montero wrote:
>> Am 02.10.2023 um 01:19 schrieb Pavel:
>>
>>> Nope. The standard never says this specifically about mutex::lock. ...
>>
>> Of course, mutex::lock() may throw a system_error.

> The standard does not say that; ...

https://en.cppreference.com/w/cpp/thread/mutex/lock
"Throws std::system_error when errors occur"


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

Pages:123456789101112131415161718192021222324252627
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor