tech-userlevel archive

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

Re: Add a hack to deinstall pthread_atexit handlers at dso unload time



On Thu, Feb 09, 2017 at 09:20:53AM +0100, Martin Husemann wrote:
> On Wed, Feb 08, 2017 at 10:36:37PM +0100, Joerg Sonnenberger wrote:
> > Sorry, wrong rant. That was for the TLS destructor problem where similar
> > crude hacks exist. The FreeBSD "solution" is still wrong. Introducing
> > __pthread_cxa_finalize or even a public interface for that is fine.
> > Iterating over all text segments to guess what handlers to remove is
> > definitely not fine.
> 
> If we are not going to do what all others do, I would suggest the very
> most simple solution:
> 
> Add 
> 
>      int
>      pthread_atfork_deregister(void (*prepare)(void), void (*parent)(void),
>          void (*child)(void));
> 
> and make it remove the handlers from the internal list if != NULL.
> 
> Then the DSO can just handle it all "manually" in a destructor function.

This is quite fragile as it effectively means that the handler should
only ever be a function the current DSO, since other modules may want to
register the very same handler too.

Joerg


Home | Main Index | Thread Index | Old Index