[lttng-dev] dlopen, gcc -l and LD_PRELOAD

Jérémie Galarneau jeremie.galarneau at efficios.com
Fri Mar 15 15:33:11 EDT 2013


On Fri, Mar 15, 2013 at 12:41 PM, Thibault, Daniel
<Daniel.Thibault at drdc-rddc.gc.ca> wrote:
>    In the lttng-ust man pages, there is a paragraph that reads:
>
> Note about dlopen() usage: Due to locking side-effects caused by the way libc lazily resolves Thread-Local Storage (TLS) symbols when a library is dlopened, linking the tracepoint probe or liblttng-ust with dlopen() is discouraged.  They should be linked with the application using "-llibname" or loaded with LD_PRELOAD.
>
>    I'm confused by the LD_PRELOAD bit: as far as I know, LD_PRELOAD serves only to substitute a dynamic library (the LD_PRELOAD argument) for another (the one the executable was linked against).  I don't see how one could compile an instrumented application and leave its tracepoint provider unlinked, which is what the stated -llibname <-> LD_PRELOAD opposition implies.
>

You may want to have a look at the comment at
lttng-ust/include/lttng/tracepoint.h:229 which explains how this is
accomplished. Basically, the tracepoint provider symbols are
initialised and the probe is registered when the provider's shared
object constructor is invoked. See ust-tracepoint-event.h:671 if you
are interested in the actual implementation.

>    (Also, shouldn't that paragraph drop 'lazily', assuming the locking problems also arise if dlopen is used with RTLD_NOW?  Because if RTLD_NOW fixed the locking problem, that's what would be recommended here, no?)

Good question. I think this problem has been fixed as part of the 2.1
release. However, I do know there are other issues related to
"dlopen()"-ing probe providers; details on the bug tracker[1].

Jérémie
[1] https://bugs.lttng.org/issues/447

>
> Daniel U. Thibault
> R & D pour la défense Canada - Valcartier (RDDC Valcartier) / Defence R&D Canada - Valcartier (DRDC Valcartier)
> Cyber sécurité pour les missions essentielles (CME) / Mission Critical Cyber Security (MCCS)
> Protection des systèmes et contremesures (PSC) / Systems Protection & Countermeasures (SPC)
> 2459 route de la Bravoure
> Québec, QC  G3J 1X5
> CANADA
> Vox : (418) 844-4000 x4245
> Fax : (418) 844-4538
> NAC : 918V QSDJ <http://www.travelgis.com/map.asp?addr=918V%20QSDJ>
> Gouvernement du Canada / Government of Canada
> <http://www.valcartier.drdc-rddc.gc.ca/>
>
> _______________________________________________
> lttng-dev mailing list
> lttng-dev at lists.lttng.org
> http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev



More information about the lttng-dev mailing list