public inbox for libc-help@sourceware.org
 help / color / mirror / Atom feed
From: Nat! <nat@mulle-kybernetik.com>
To: Adhemerval Zanella <adhemerval.zanella@linaro.org>,
	libc-help@sourceware.org
Subject: Re: Problem with atexit and _dl_fini
Date: Tue, 11 Jun 2019 20:20:00 -0000	[thread overview]
Message-ID: <174f19a0-40ea-a5b1-d21d-3903f9bba9f8@mulle-kybernetik.com> (raw)
In-Reply-To: <31060c89-404f-e8e1-6c18-d75e0b63f6ad@linaro.org>


On 11.06.19 20:39, Adhemerval Zanella wrote:
>
> It seems that this requirement seems to come from LSB, although I am not
> sure which one came first (the specification or the implementation).
> It also states that __cxa_atexit should register a function to be called
> by exit or when a shared library is unloaded.

I don't really have much further to add to this topic, so this is just 
some commentary and speculation... and I am probably repeating myself.


https://pubs.opengroup.org/onlinepubs/009695399/functions/atexit.htmlstates: 


    The /atexit/() function shall register the function pointed to by 
/func/, to be called without arguments at normal program termination.

That's "normal program termination" not anytime before. dlclose is 
anytime before. What is happening is a violation of `atexit`.


When I read 
http://refspecs.linuxbase.org/LSB_5.0.0/LSB-Core-generic/LSB-Core-generic.html#BASELIB---CXA-FINALIZE

I see that it's *Intels* version of C++ that originally dictated this 
violation of the C standard. Possibly Intel was writing this with 
Windows in mind ?

> And __cxa_finalize requires to call atexit registers functions as well. It
> also states __cxa_finalize should be called on dlclose.

In my opinion the__cxa_finalize requirement is wrong. It's further my 
opinion, that a vendors requirement for its C++ ABI, does not "trump" 
open standards. :)

>
> I think it might due the fact old gcc version uses atexit to register C++
> destructors for local static and global objects. However it seems to be
> enabled as default for GLIBC (since it support __cxa_atexit since initial
> versions).
>
> So I think there is no impeding reason to make atexit not be called from
> __cxa_finalize, although I am not sure how we would handle the LSB deviation.
> I will write down a libc-alpha to check what other developer think.

I think the proper solution is to rewrite __cxa__finalize and remove 
atexit functionality completely from it.
Alas I am not hopeful, that this will be resolved to my taste :)


>
> [1] http://refspecs.linuxbase.org/LSB_5.0.0/LSB-Core-generic/LSB-Core-generic.pdf
>

Ciao

    Nat!



  reply	other threads:[~2019-06-11 20:20 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-18 21:23 Nat!
2019-05-19 16:23 ` Florian Weimer
2019-05-19 19:37   ` Nat!
2019-05-21 20:43     ` Adhemerval Zanella
2019-05-22 10:22       ` Nat!
2019-05-22 15:01         ` Adhemerval Zanella
2019-05-22 15:29           ` Nat!
2019-05-22 19:35             ` Adhemerval Zanella
2019-05-29 21:16               ` Nat!
2019-06-09 20:59     ` Nat!
2019-06-10 11:48       ` Adhemerval Zanella
2019-06-10 13:08         ` Nat!
2019-06-10 20:27           ` Adhemerval Zanella
2019-06-11 18:39             ` Adhemerval Zanella
2019-06-11 20:20               ` Nat! [this message]
2019-06-11 22:40                 ` Nat!
2019-06-12  3:41                   ` Carlos O'Donell
2019-06-13 22:53                   ` Nat!
2019-06-14 12:29                     ` Manfred
2019-06-14 15:14                     ` Adhemerval Zanella
2019-06-11 18:53             ` Nat!

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=174f19a0-40ea-a5b1-d21d-3903f9bba9f8@mulle-kybernetik.com \
    --to=nat@mulle-kybernetik.com \
    --cc=adhemerval.zanella@linaro.org \
    --cc=libc-help@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).