Current-Users archive

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

Re: atexit(), dlclose() and more atexit()

On 29.06.2020 00:50, Joerg Sonnenberger wrote:
> On Mon, Jun 29, 2020 at 12:34:31AM +0200, Kamil Rytarowski wrote:
>> On 28.06.2020 23:57, Joerg Sonnenberger wrote:
>>> 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.
>> atexit is implemented today as 'The atexit() function registers the
>> function pointed to by func to be called without arguments on normal
>> termination of the program or when the object defining the function is
>> unloaded.' for around 20 years now.
>> NetBSD is a leftover with a broken implementation.
> Funny, neither POSIX nor ISO C agree with you, but I guess neither is
> the relevant standard. But I'll stop here. It isn't productive.

There is no disagreement, but a field not specified. This behavior is
suggested in Itanium C++ ABI with so called reasonable treatment of
atexit handlers upon dlclose).

I've submitted in 2018 a request to Itanium C++ ABI people to clarify
the wording, but they redirected me to POSIX. POSIX kind of intends to
support no-op dlclose, but perhaps I will need to try to reach them.

So this is a dominant convention (Linux, FreeBSD, Solaris) and we will
keep observing recurring NetBSD-specific behavior crashes.

> Joerg

Attachment: signature.asc
Description: OpenPGP digital signature

Home | Main Index | Thread Index | Old Index