On Sun, Jun 28, 2020 at 11:48:15PM +0200, Kamil Rytarowski wrote: > On 28.06.2020 23:29, Joerg Sonnenberger wrote: > > It is fundamentally wrong to use a handler in a library that can be > > unloaded. Some systems hack around that problem by looping over all > > atexit handlers on dlclose, but that's exactly that, a costly hack. The > > most common way this triggers is a segfault, actually. > > The world disagrees and NetBSD is different for no good reason.
You sound like a broken record. Have you *thought* about the reasons at all? Like for example the very definition of atexit: "Run a handler at process exit". The Linux variant does not do that. Heck, they only document it as a side note. > We shall add support for this. We shall not. It is a bad design. > On 28.06.2020 23:29, Joerg Sonnenberger wrote: > > The code should be using either a C dtor with the appropiate attribute > > or __cxa_atexit directly, but the former is preferable. > > This replacement forces to use a hack with a GCC extension (destructor > attribute) instead of C complaint code. So what? It can be spelled out differently and the library here certainly contains enough dependencies on GCC extensions already. > __cxa_atexit is a C++ thing so another hack for our atexit(3). Where the heck did you arrive at the conclusion that __cxa_atexit is a C++ thing? It is support infrastructure having dynamic cleanup handlers on a per DSO base. Just because C++ was the first language to desire that doesn't mean it is C++ only. In fact, the above extension is using exactly the same code. Joerg