From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 122419 invoked by alias); 11 Jun 2019 20:20:20 -0000 Mailing-List: contact libc-help-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Post: List-Help: , Sender: libc-help-owner@sourceware.org Received: (qmail 122409 invoked by uid 89); 11 Jun 2019 20:20:20 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-1.7 required=5.0 tests=AWL,BAYES_00,HTML_MESSAGE,SPF_PASS autolearn=ham version=3.3.1 spammy=anytime, trump, H*c:alternative, states X-HELO: muller.mulle-kybernetik.com Received: from muller.mulle-kybernetik.com (HELO muller.mulle-kybernetik.com) (78.46.34.175) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 11 Jun 2019 20:20:17 +0000 Received: (qmail 6494 invoked from network); 11 Jun 2019 22:20:14 +0200 Received: from unknown (HELO ?192.168.2.34?) (nat@78.46.34.175) by mail.mulle-kybernetik.com with ESMTPS (ECDHE-RSA-AES128-SHA encrypted); 11 Jun 2019 22:20:14 +0200 Subject: Re: Problem with atexit and _dl_fini To: Adhemerval Zanella , libc-help@sourceware.org References: <87blzypg5j.fsf@mid.deneb.enyo.de> <0a7c2435-43f8-8dfb-83ab-22ceff7ca51c@mulle-kybernetik.com> <9497a5c2-0dc8-18fe-6120-deb551f7ddd8@mulle-kybernetik.com> <31060c89-404f-e8e1-6c18-d75e0b63f6ad@linaro.org> From: Nat! Message-ID: <174f19a0-40ea-a5b1-d21d-3903f9bba9f8@mulle-kybernetik.com> Date: Tue, 11 Jun 2019 20:20:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.0 MIME-Version: 1.0 In-Reply-To: <31060c89-404f-e8e1-6c18-d75e0b63f6ad@linaro.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-SW-Source: 2019-06/txt/msg00012.txt.bz2 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!