[Halld-offline] collisions among static and dynmaic (plugins) libraries

Richard Jones richard.t.jones at uconn.edu
Wed Jul 13 17:31:50 EDT 2016


Hello David,

This seems to be the same problem, and I like your solution the best of all
of the different ways people recommend solving it. Thanks for helping me on
this.

-Richard Jones

On Wed, Jul 13, 2016 at 3:37 PM, David Lawrence <davidl at jlab.org> wrote:

>
> Hi Richard,
>
>   I spoke with Paul since I know we ran into this some time ago and found
> a solution. Digging through
> the github logs, here is where Paul implemented the solution we came up
> with:
>
> commit 61500561a96d5cb8d471c18bdb38d911611f3da9
> Author: Paul Mattione <pmatt at jlab.org>
> Date:   Tue Mar 17 15:35:54 2015 +0000
>
>     Make global static variables in DTranslationTable have function scope
> instead. Return these by reference from these container functions, and
> access only by these functions.
>     This fixes the crash-at-end-of-program problem (double-free,
> corrupted-memory) mentioned in the rev 17681 hd_root commit. Remove abort()
> call from hd_root.
>
> For example, at the top of DTranslationTable.cc
> <http://dtranslationtable.cc> there is this:
>
> // Use one translation table for all threads
> pthread_mutex_t& DTranslationTable::Get_TT_Mutex(void) const
> {
> static pthread_mutex_t tt_mutex = PTHREAD_MUTEX_INITIALIZER;
> return tt_mutex;
> }
>
>
> Previously, the “tt_mutex” variable was global so when a plugin that had
> been linked with
> the TTAB library was attached (dlopen), it automatically linked this. When
> the plugin is
> detached (dlclose) it was treated it like it went out of scope, deleting
> it. Then, the same thing
> happened at program exit leading to a double-free leading to a crash.
>
> By replacing the global with a static local variable inside a globally
> accessible method, one
> avoids this. So, you will need to hunt down where in the code a global
> variable is being used
> and wrap it inside a global getter method as is done above in order to
> avoid these crashes.
>
> Regards,
> -David
>
>
>
> On Jul 13, 2016, at 3:11 PM, Paul Mattione <pmatt at jlab.org> wrote:
>
> It’s only #include’d in danarest.  So, this problem would apply to every
> single class that’s #include’d into a plugin (such as DChargedTrack), so
> it’s unavoidable.
>
> - Paul
>
> On Jul 13, 2016, at 3:05 PM, Richard Jones <richard.t.jones at uconn.edu>
> wrote:
>
> Hello Dave,
>
> I have run into a nasty problem with segfaults at program exit. This seems
> to be related to the appearance of duplicate instances of some classes (eg.
> DEventWriterREST) that are defined both in the plugin (danarest.so) and the
> static library that is linked into hd_root (libHDDM.a). What is your policy
> with regard to classes that are used both in the static library and in the
> base code?
>
> BTW there is the related question of why the DEventWriterREST is
> duplicated in two places in the tree, once in the
> Utilitiles/plugins/danarest and once in the libraries/HDDM area.
>
> -Richard Jones
> _______________________________________________
> Halld-offline mailing list
> Halld-offline at jlab.org
> https://mailman.jlab.org/mailman/listinfo/halld-offline
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.jlab.org/pipermail/halld-offline/attachments/20160713/eb3f3191/attachment-0002.html>


More information about the Halld-offline mailing list