tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Lua shared object asymmetry loading Xlib.



On 20.01.2019 10:19, Marc Balmer wrote:
> 
> 
>> Am 20.01.2019 um 10:14 schrieb Martin Husemann <martin%duskware.de@localhost>:
>>
>> On Sun, Jan 20, 2019 at 10:06:33AM +0100, Marc Balmer wrote:
>>> Why are atexit handlers run after dlclosing loaded libraries?  That sounds wrong to me, but is there a reason?
>>
>> They are run at exit(1) time, the application (or in this case library)
>> is responsible of removing them if it dlclose()s the library implementing
>> them earlier.
> 
> So the _init / _fini functions in a shared library could handle that?  How can an atexit handler be unregistered?
> 

atexit handlers cannot be deregistered (unless someone builds an
intermediate stack of callback functions and manages their entries
manually).

> fwiw, other operating systems unregister functions from a shared library automatically at dlclose() time (e.g. macOS)
> 

In my opinion this is a libc deficiency in NetBSD, not a bug X libs (or
other 3rd party software with DSO modules using this mechanism). It's at
most a portability issue there.

Other mainstream POSIX-like systems call the callback upon dlclose(3).

The benefit of atexit(3) is that it's a pure C solution without a need
for C extension and the order of calling destructors is more
deterministic rather than fiddling with destructor priorities.

>>
>> However, this was a bug in the X libs and it has been fixed (AFAIR).
> 
> Yes, christos seems to have fixed it.
> 

I find it as workaround of our libc behavior.

>>
>> Martin
> 


Attachment: signature.asc
Description: OpenPGP digital signature



Home | Main Index | Thread Index | Old Index