Proposal to reduce anti-bundling requirements
Bjorn at xn--rombobjrn-67a.se
Sun Oct 4 15:48:09 UTC 2015
Florian Weimer wrote:
> I would really like to see DT_NEEDED-based use cases for
> symbol interposition.
Well, there is the thread wrapper I wrote for the Ada Milter API to
prevent Libgnat from leaking memory when Libmilter's threads terminate.
I think what it does is this symbol interposition you guys were talking
about. The advantage over LD_PRELOAD is that with the right combination
of static and dynamic linking the library can take care of it all. The
LD_PRELOAD solution must be done in the initscript or SystemD unit of
each individual milter that links to the library.
It is just a workaround though. I think it would be possible for Libgnat
to avoid leaking, and I haven't taken the time to test recent GCC
versions to see if the leak is still there.
// This module wraps any threads that are started from anywhere in the program,
// making them call GNAT.Threads.Register_Thread when they start and
// GNAT.Threads.Unregister_Thread when they terminate. Although Libgnat
// registers foreign threads automatically on GNU/Linux, it leaks memory when
// the threads terminate. Calling Unregister_Thread plugs the leak.
// Initially nothing special is done to threads, so that Ada tasks such as
// Libgnat's Interrupt_Manager task can be started during elaboration, even
// before Libgnat is ready to handle calls to Register_Thread. The wrapping
// begins after start_wrapping_threads is called.
// To make the wrapping of threads possible this module contains a function
// named pthread_create which will be called instead of the one in the Pthreads
// library. This function in turn calls the real pthread_create, but instructs
// it to have the thread run the thread start routine wrap_thread instead of
// its normal start routine. wrap_thread calls Register_Thread, arranges for
// Unregister_Thread to be called when the thread terminates, and then calls
// the normal start routine.
// For this to work the Pthreads library must be linked in dynamically, but
// this module must be statically linked into the main executable to ensure
// that this pthread_create is found before the one in the Pthreads library.
The Ada Milter API isn't currently in Fedora. The thread wrapper can be
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 819 bytes
Desc: OpenPGP digital signatur
More information about the devel