unofficial mirror of libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Adhemerval Zanella <adhemerval.zanella@linaro.org>
To: Florian Weimer <fweimer@redhat.com>
Cc: libc-alpha@sourceware.org
Subject: Re: [RFC] stdlib: Make atexit to not act as __cxa_atexit
Date: Tue, 2 Jul 2019 10:12:26 -0300	[thread overview]
Message-ID: <44d11528-a60b-47de-5e2d-61f5769755c5@linaro.org> (raw)
In-Reply-To: <87k1d098yo.fsf@oldenburg2.str.redhat.com>



On 02/07/2019 04:44, Florian Weimer wrote:
> * Adhemerval Zanella:
> 
>>   3. exit is the only way where atexit handlers are actually called.
>>      Unloading a library through dlclose does not issue the atexit
>>      anymore (this is the main semantic change).
> 
> Sorry, I don't think this is the right direction.  We got the current
> atexit behavior from Solaris, and I think it is useful.
> 
>   <https://docs.oracle.com/cd/E88353_01/html/E37843/atexit-3c.html>

I am not sure this is also a good design, specially that we have elf
destructors that provide a similar semantic.

> 
> I think the bug is that our implementation of that behavior interferes
> with the execution order when there is no dlclose at all.  There should
> be a different way for fixing that.
> 
> Maybe we can turn __cxa_finalize into a NOP and have the dynamic loader
> handle atexit handlers directly on dlclose (assuming that it's always
> called before the other ELF destructors)?

We need __cxa_finalize because it is called by __do_global_dtors_aux
from initfini callbacks. Also making the loader itself handler atexit
is not the best option IMHO: we will either to call a private symbol on 
libc (which might require an additional lookup) or export the internal 
data so loader can implement the callback issuing itself. 

> 
> Or otherwise use flags to mark things, but in such a way that the
> handlers are processed in reverse atexit order, unless a dlclose
> happens.

I think one possible option to still allow atexit handler being called
by atexit is to still register them as ef_at (using the new __atexit
symbol) and on __run_exit_handler first process et_at and them
ef_on and ef_cxa. This is still a semantic change of atexit regarding
the order of on_exit and __cxa_atexit, but we keep the Solaris like
one to call them on dlclose.

What do you think?

  reply	other threads:[~2019-07-02 13:12 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-01 20:59 [RFC] stdlib: Make atexit to not act as __cxa_atexit Adhemerval Zanella
2019-07-02  7:44 ` Florian Weimer
2019-07-02 13:12   ` Adhemerval Zanella [this message]
2019-07-02 13:24     ` Florian Weimer
2019-07-02 16:56       ` Adhemerval Zanella
2019-07-03 10:05         ` Florian Weimer
2019-07-03 19:22           ` Adhemerval Zanella
2019-07-08 11:16             ` Florian Weimer
2019-07-08 13:39               ` Adhemerval Zanella
2019-07-08 13:57                 ` Florian Weimer
2019-07-11 19:09                   ` Adhemerval Zanella

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

  List information: https://www.gnu.org/software/libc/involved.html

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

  git send-email \
    --in-reply-to=44d11528-a60b-47de-5e2d-61f5769755c5@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).