public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Adhemerval Zanella Netto <adhemerval.zanella@linaro.org>
To: Florian Weimer <fweimer@redhat.com>
Cc: libc-alpha@sourceware.org
Subject: Re: Calling __cxa_thread_atexit_impl directly, from C code
Date: Tue, 30 Aug 2022 09:56:09 -0300	[thread overview]
Message-ID: <dc87488b-05f3-f208-94a2-97a677ca6624@linaro.org> (raw)
In-Reply-To: <87pmgi5gi6.fsf@oldenburg.str.redhat.com>



On 30/08/22 04:37, Florian Weimer wrote:
> * Adhemerval Zanella Netto:
> 
>> It would mean that libgcc_s would need to build and use the fallback
>> implementation in the case of failure, which is suboptimal (although not
>> sure it would be an improvement over abort on failure).
> 
> The fallback implementation also has to allocate memory.
> 
> The alternative would be to throw std::bad_alloc.

Yeah, but the suboptimal is not solely for the allocation memory part,
but also for the missing synchronization and ordering.  But I also think
moving the failing handling to caller it still better than the hard hammer
or aborting the process (even though I agree it won't improve that much).

> 
>> But I also think for compat reasons we can't really change 
>> __cxa_thread_atexit_impl, since C++ constructors will be the ones responsible
>> to call __cxa_thread_atexit and afaik it assumes it can not fail (meaning
>> that any failure will be ignored).
> 
> Yes, there is the general problem that for registering an object for
> destruction, as a matter of principle, you need to try to allocate the
> data structure in the registry first, and if that is successful, create
> the object.  Otherwise you may end up with an object and no way to
> register its destructor.  Perhaps you should just call the destructor at
> this point and throw std::bad_alloc.
> 
> I guess we should go with the static destructor counting approach
> instead. 8-/

Why strategy more specially do you mean the counting approach?  I just reread
the 'Counting static __cxa_atexit calls' thread and tend to agree with you
that having the number of required unique __cxa_atexit calls seems slight
better than a failable .init_array mode.

  reply	other threads:[~2022-08-30 12:56 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-26  8:31 Florian Weimer
2022-08-29 18:59 ` Adhemerval Zanella Netto
2022-08-29 19:21   ` Florian Weimer
2022-08-29 19:56     ` Adhemerval Zanella Netto
2022-08-30  7:37       ` Florian Weimer
2022-08-30 12:56         ` Adhemerval Zanella Netto [this message]
2022-09-06  6:44           ` Florian Weimer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=dc87488b-05f3-f208-94a2-97a677ca6624@linaro.org \
    --to=adhemerval.zanella@linaro.org \
    --cc=fweimer@redhat.com \
    --cc=libc-alpha@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).