Problem with atexit and _dl_fini

Nat! nat@mulle-kybernetik.com
Mon Jun 10 13:08:00 GMT 2019


On 10.06.19 13:48, Adhemerval Zanella wrote:
>
> On 09/06/2019 17:59, Nat! wrote:
>> Another datapoint to support my claim that _dl-fini breaks atexit. This time its very easy to reproduce ;)
>>
>> Here 's the README.md from the Github Repo https://github.com/mulle-nat/atexit-breakage-linux
>>
>>
>> ```
>>
>> # Shows another breakage involving `atexit` on linux
>>
>> Here the `atexit` callback is invoked mistakenly multiple times.
> This 'example' does not really show the issue because ldd script issues
> the loader multiple times, see below. You can check exactly what ldd is
> doing by calling with sh -x.

I agree it doesn't show the same issue, but it shows that something else 
is going very wrong. :) Or are you happy, that atexit is called multiple 
times ? Who's calling exit here anyway ? Check out the debugger output 
too (see updated README.md)


>
> I will try to use your instruction to run on docker to see what exactly
> is happening in your environment.

That's not necessary anymore. I managed to make it reproducible in a 
much simpler form just now.

The ld-so-breakage project is basically a recreation of the original 
"docker" scenario written from scratch. I try to explain in the README , 
what is going on. But if there are questions hit me up (maybe as an 
issue ?) :

     https://github.com/mulle-nat/ld-so-breakage


The "another datapoint" project shows how constructor/destructor don't 
pair up:

     https://github.com/mulle-nat/atexit-breakage-linux


And as a random bonus this project indicates to me that LD_PRELOAD 
doesn't do what its supposed to either:

     https://github.com/mulle-nat/LD_PRELOAD-breakage-linux


In total I think the state of affairs is pretty dismal. I didn't expect 
that much basic stuff not working on linux. With hindsight, I probably 
have wasted _weeks_ on these problems.

I still maintain that the concept to let `atexit` callbacks not run by 
`exit` is broken. An `atexit` callback is not the same as an 
`__attribute__((destructor))__`.


Ciao

    Nat!




More information about the Libc-help mailing list