[collectd] Sigsev in python plugin.

Marc Schlinger Marc.Schlinger at pace.com
Fri Nov 30 11:30:12 CET 2012

Hello all,

I've been testing the python plugin of collectd today, and have spotted
an issue. A very simple python plugin will SIGSEV when launched from the
command line. I've experienced the same error on with debian package version
4.10.1+squeeze2, 5.1.0-3 and from source tarball collectd-5.2.0.tar.gz, on
both python 2.6 and 2.7

the plugin and config file can be found at:

$ /opt/collectd/sbin/collectd -C ~/dev/collectd/collectd.cfg -T -f
python.spam (gauge): 18.903025
Erreur de segmentation

The backtrace is:
#0  0x00007ffff70ba4ff in ?? () from /lib/x86_64-linux-gnu/libc.so.6
#1  0x00007ffff69f222b in PyString_FromString () from /usr/lib/libpython2.7.so.1.0
#2  0x00007ffff6d985c0 in cpy_string_to_unicode_or_bytes (timeout=0, id=0x0,
data=Unhandled dwarf expression opcode 0xf3) at cpython.h:158
#3  cpy_flush_callback (timeout=0, id=0x0, data=Unhandled dwarf expression opcode 0xf3
) at python.c:509
#4  0x000000000040e861 in plugin_flush (plugin=0x0, timeout=0, identifier=0x0) at plugin.c:1385
#5  0x000000000040e9f3 in plugin_shutdown_all () at plugin.c:1409
#6  0x000000000040699e in do_shutdown (argc=Unhandled dwarf expression opcode 0xf3
) at collectd.c:360
#7  main (argc=Unhandled dwarf expression opcode 0xf3
) at collectd.c:609

The problem comes from plugin_shutdown_all () in plugin.c:1409

        plugin_flush (/* plugin = */ NULL,
                        /* timeout = */ 0,
                        /* identifier = */ NULL);

Identifier is set to NULL, and in cpy_string_to_unicode_or_bytes from
cpython.h:158 it is passed to PyString_FromString.

http://docs.python.org/2/c-api/string.html#PyString_FromString, says clearly
that the parameter can't be NULL and won't be checked.

I manage to make it work with the attach modification i.e replacing buf by an
empty string if it is NULL.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: cpython.h.diff
Type: text/x-patch
Size: 401 bytes
Desc: cpython.h.diff
URL: <http://mailman.verplant.org/pipermail/collectd/attachments/20121130/a41c8d25/attachment-0001.bin>

More information about the collectd mailing list