[collectd] perl plugin woes

Sebastian Harl sh at tokkee.org
Mon Mar 10 11:00:43 CET 2008


On Sun, Mar 09, 2008 at 08:11:01PM -0700, Thorsten von Eicken wrote:
> I'm having trouble getting the perl plugin to work on CentOS 5.0. As 
> soon as I put a LoadPlugin line into the perl conf section I get:
> [2008-03-09 23:02:22] perl: Initializing Perl interpreter...
> /usr/sbin/collectd: symbol lookup error: 
> /usr/lib/perl5/5.8.8/i386-linux-thread-multi/auto/IO/IO.so: undefined 
> symbol: Perl_Tstack_sp_ptr

This is a know bug/problem with libtool/call it whatever you like. I
guess this should be put in the FAQ or possibly the collectd-perl

(Skip the following two paragraphs if you're not interested in the
technical details.)

Anyway, the problem is that, by default, libtool/libltdl only uses the
RTDL_LAZY or RTDL_NOW flag when doing dlopen(3) and there is no (sane)
way to tell libltdl to use any other flags. Now, when the perl plugin is
loaded using lt_dlopen() (the dlopen wrapper provided by libltdl), the
RTLD_LOCAL flag is used (that's the default in glibc and presumably
other libc implementations) which causes all symbols defined in this
library to not be made available to subsequently loaded libraries. As
libperl is loaded as a dependency of the perl plugin, none of its
symbols will be made available to subsequently loaded libraries either.

Now, if you try to load a Perl module from a collectd Perl plugin which
uses DynaLoader to load further libraries (like IO.so in this case) this
library will depend on libperl as well. However, libperl has already
been loaded before and the linker will not do so again but will be
unable to resolve any symbols as they have not been made available
before. This could be solved by using dlopen()'s RTLD_GLOBAL flag in the
first place. Supposedly, this flag would cause libltdl not to be as
portable as the developers want it to be and thus it's not supported.

(I hope this did not get too confusing... ;-)

There are four ways to solve this. The first two will probably take some
time and require modifications of collectd. The latter ones are rather
hacks but may be used now.

1. Do not use libtool/libltdl in collectd. We'd then have to take care
of portable code ourselves. I did not have a look at that so far but I
assume it's not trivial - else something like libtool would not be
justified (well, we're in the OpenSource world, so basically anything is
justified... ;-).

2. Wait for libtool to provide something like lt_dlopen_flags(). This
has already been discussed on the developer's mailing list but I don't
know the current state. collectd might not work on whatever platform(s)
that do(es)n't support RTLD_GLOBAL then.

3. Use "LD_PRELOAD=/path/to/libperl collectd[mon]" to run collectd. This
way, libperl is loaded at startup and all symbols will be made available
to subsequently loaded libraries. I do not recommend this for any
packages or the like though as it would fail, if libperl is not

4. Configure collectd using something like "./configure
the flags used by libltdl. That's what I'm currently using for the
Debian package. I don't really like that but it's imho the best solution
right now. You have to make sure that you're using the appropriate flags
for your architecture - see the dlopen(3) manpage.

Any feedback and comments would be very appreciated.


Sebastian "tokkee" Harl +++ GnuPG-ID: 0x8501C7FC +++ http://tokkee.org/

Those who would give up Essential Liberty to purchase a little Temporary
Safety, deserve neither Liberty nor Safety.         -- Benjamin Franklin

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://mailman.verplant.org/pipermail/collectd/attachments/20080310/33398876/attachment.pgp 

More information about the collectd mailing list