Issues with running Nagios 3.2.0 with --enable-embedded-perl

Hello Guys,

I have tried to install Nagios 3.2.0 version on Linux CentOS 5.2 and I have got an issue:
When starting, it ends with segmentation fault:

[root@mon bin]# ./nagios -d /usr/local/nagios_new/etc/nagios.cfg
Segmentation fault
[root@mon bin]#

Despite the fact that checking the config works OK:

[root@mon bin]# ./nagios -v /usr/local/nagios_new/etc/nagios.cfg

Nagios Core 3.2.0
Copyright © 2009 Nagios Core Development Team and Community Contributors
Copyright © 1999-2009 Ethan Galstad
Last Modified: 08-12-2009
License: GPL

Website: nagios.org
Reading configuration data…
Read main config file okay…
Processing object config file ‘/usr/local/nagios_new/etc/objects/contactgroups.cfg’…
Processing object config file ‘/usr/local/nagios_new/etc/objects/timeperiods.cfg’…
Processing object config file ‘/usr/local/nagios_new/etc/objects/templates.cfg’…
Processing object config directory ‘/usr/local/nagios_new/etc/output’…
Processing object config file ‘/usr/local/nagios_new/etc/output/Cluj Application srv.cfg’…
Processing object config file ‘/usr/local/nagios_new/etc/output/Cluj Interxion srv.cfg’…
Processing object config file ‘/usr/local/nagios_new/etc/output/Cluj Network srv.cfg’…
Processing object config file ‘/usr/local/nagios_new/etc/output/Cluj VPNs.cfg’…
Processing object config file ‘/usr/local/nagios_new/etc/output/commands.cfg’…
Processing object config file ‘/usr/local/nagios_new/etc/output/Cluj ISP EuroWeb.cfg’…
Processing object config file ‘/usr/local/nagios_new/etc/output/Cluj UPS.cfg’…
Processing object config file ‘/usr/local/nagios_new/etc/output/Cluj ISP RDS.cfg’…
Processing object config file ‘/usr/local/nagios_new/etc/output/Cluj Redbus srv.cfg’…
Processing object config file ‘/usr/local/nagios_new/etc/output/Cluj London.cfg’…
Processing object config file ‘/usr/local/nagios_new/etc/output/sgroup.cfg’…
Read object config files okay…

Running pre-flight check on configuration data…

Checking services…
Checked 225 services.
Checking hosts…
Checked 74 hosts.
Checking host groups…
Checked 9 host groups.
Checking service groups…
Checked 0 service groups.
Checking contacts…
Checked 4 contacts.
Checking contact groups…
Checked 5 contact groups.
Checking service escalations…
Checked 450 service escalations.
Checking service dependencies…
Checked 0 service dependencies.
Checking host escalations…
Checked 148 host escalations.
Checking host dependencies…
Checked 73 host dependencies.
Checking commands…
Checked 107 commands.
Checking time periods…
Checked 4 time periods.
Checking for circular paths between hosts…
Checking for circular host and service dependencies…
Checking global event handlers…
Checking obsessive compulsive processor commands…
Checking misc settings…

Total Warnings: 0
Total Errors: 0

Things look okay - No serious problems were detected during the pre-flight check
[root@mon bin]#

The Nagios is compiled with embedded perl support (as I have a some plugins in Perl). No errors or warnings appeared while configuring and compiling the code.
Below is a try to find the cause:

[root@mon bin]# gdb ./nagios
GNU gdb Red Hat Linux (6.5-37.el5_2.2rh)
Copyright © 2006 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type “show copying” to see the conditions.
There is absolutely no warranty for GDB. Type “show warranty” for details.
This GDB was configured as “i386-redhat-linux-gnu”…(no debugging symbols found)
Using host libthread_db library “/lib/libthread_db.so.1”.

(gdb) run -d /usr/local/nagios_new/etc/nagios.cfg
Starting program: /usr/local/nagios_new/bin/nagios -d /usr/local/nagios_new/etc/nagios.cfg

[1]+ Stopped gdb ./nagios
[root@mon bin]# fg
gdb ./nagios
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
[Thread debugging using libthread_db enabled]
(no debugging symbols found)
[New Thread -1208183104 (LWP 21792)]
(no debugging symbols found)

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread -1208183104 (LWP 21792)]
0x00938be1 in Perl_get_cv () from /usr/lib/perl5/5.8.8/i386-linux-thread-multi/CORE/libperl.so
(gdb) bt
#0 0x00938be1 in Perl_get_cv () from /usr/lib/perl5/5.8.8/i386-linux-thread-multi/CORE/libperl.so
#1 0x0093b036 in perl_free () from /usr/lib/perl5/5.8.8/i386-linux-thread-multi/CORE/libperl.so
#2 0x0093d5f9 in perl_parse () from /usr/lib/perl5/5.8.8/i386-linux-thread-multi/CORE/libperl.so
#3 0x080905b7 in init_embedded_perl ()
#4 0x080579f5 in main ()
(gdb)

It seems that this is due to perl, but I cannot figure out what exactly causes this.

Also have tried to run Nagios in debug mode (with debug_level=-1, debug_verbosity=2) but this is all I got in nagios.debug:

[1258446070.459957] [001.0] [pid=23617] drop_privileges() start
[1258446070.460128] [004.0] [pid=23617] Original UID/GID: 0/0
[1258446070.471956] [004.0] [pid=23617] New UID/GID: 500/501

Here is perl version used:

[root@mon bin]# perl -V
Summary of my perl5 (revision 5 version 8 subversion 8) configuration:
Platform:
osname=linux, osvers=2.6.18-53.1.14.el5pae, archname=i386-linux-thread-multi
uname=‘linux builder16.centos.org 2.6.18-53.1.14.el5pae #1 smp wed mar 5 12:07:47 est 2008 i686 athlon i386 gnulinux ‘
config_args=’-des -Doptimize=-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i386 -mtune=generic -fasynchronous-unwind-tables -Dversion=5.8.8 -Dmyhostname=localhost -Dperladmin=root@localhost -Dcc=gcc -Dcf_by=Red Hat, Inc. -Dinstallprefix=/usr -Dprefix=/usr -Darchname=i386-linux -Dvendorprefix=/usr -Dsiteprefix=/usr -Duseshrplib -Dusethreads -Duseithreads -Duselargefiles -Dd_dosuid -Dd_semctl_semun -Di_db -Ui_ndbm -Di_gdbm -Di_shadow -Di_syslog -Dman3ext=3pm -Duseperlio -Dinstallusrbinperl=n -Ubincompat5005 -Uversiononly -Dpager=/usr/bin/less -isr -Dd_gethostent_r_proto -Ud_endhostent_r_proto -Ud_sethostent_r_proto -Ud_endprotoent_r_proto -Ud_setprotoent_r_proto -Ud_endservent_r_proto -Ud_setservent_r_proto -Dinc_version_list=5.8.7 5.8.6 5.8.5 -Dscriptdir=/usr/bin’
hint=recommended, useposix=true, d_sigaction=define
usethreads=define use5005threads=undef useithreads=define usemultiplicity=define
useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
use64bitint=undef use64bitall=undef uselongdouble=undef
usemymalloc=n, bincompat5005=undef
Compiler:
cc=‘gcc’, ccflags =’-D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -pipe -Wdeclaration-after-statement -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/gdbm’,
optimize=’-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i386 -mtune=generic -fasynchronous-unwind-tables’,
cppflags=’-D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -pipe -Wdeclaration-after-statement -I/usr/local/include -I/usr/include/gdbm’
ccversion=’’, gccversion=‘4.1.2 20071124 (Red Hat 4.1.2-42)’, gccosandvers=’‘
intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
ivtype=‘long’, ivsize=4, nvtype=‘double’, nvsize=8, Off_t=‘off_t’, lseeksize=8
alignbytes=4, prototype=define
Linker and Libraries:
ld=‘gcc’, ldflags =’ -L/usr/local/lib’
libpth=/usr/local/lib /lib /usr/lib
libs=-lresolv -lnsl -lgdbm -ldb -ldl -lm -lcrypt -lutil -lpthread -lc
perllibs=-lresolv -lnsl -ldl -lm -lcrypt -lutil -lpthread -lc
libc=/lib/libc-2.5.so, so=so, useshrplib=true, libperl=libperl.so
gnulibc_version=‘2.5’
Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags=’-Wl,-E -Wl,-rpath,/usr/lib/perl5/5.8.8/i386-linux-thread-multi/CORE’
cccdlflags=’-fPIC’, lddlflags=’-shared -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i386 -mtune=generic -fasynchronous-unwind-tables -L/usr/local/lib’

Characteristics of this binary (from libperl):
Compile-time options: MULTIPLICITY PERL_IMPLICIT_CONTEXT
PERL_MALLOC_WRAP USE_ITHREADS USE_LARGE_FILES
USE_PERLIO USE_REENTRANT_API
Built under linux
Compiled at Sep 17 2008 13:37:09
@INC:
/usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi
/usr/lib/perl5/site_perl/5.8.7/i386-linux-thread-multi
/usr/lib/perl5/site_perl/5.8.6/i386-linux-thread-multi
/usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi
/usr/lib/perl5/site_perl/5.8.8
/usr/lib/perl5/site_perl/5.8.7
/usr/lib/perl5/site_perl/5.8.6
/usr/lib/perl5/site_perl/5.8.5
/usr/lib/perl5/site_perl
/usr/lib/perl5/vendor_perl/5.8.8/i386-linux-thread-multi
/usr/lib/perl5/vendor_perl/5.8.7/i386-linux-thread-multi
/usr/lib/perl5/vendor_perl/5.8.6/i386-linux-thread-multi
/usr/lib/perl5/vendor_perl/5.8.5/i386-linux-thread-multi
/usr/lib/perl5/vendor_perl/5.8.8
/usr/lib/perl5/vendor_perl/5.8.7
/usr/lib/perl5/vendor_perl/5.8.6
/usr/lib/perl5/vendor_perl/5.8.5
/usr/lib/perl5/vendor_perl
/usr/lib/perl5/5.8.8/i386-linux-thread-multi
/usr/lib/perl5/5.8.8
.

Could someone help me with this?
Or just point out what’s wrong with perl?

Many Thanks,
Constantin.

Also I have run strace:

[root@mon bin]# strace -f ./nagios -d /usr/local/nagios_new/etc/nagios.cfg
execve("./nagios", “./nagios”, “-d”, “/usr/local/nagios_new/etc/nagios”…], /* 25 vars */]) = 0
brk(0)= 0x93a0000


Here all seems to be OK.


stat64("/usr/lib/perl5/site_perl/5.8.7", {st_mode=S_IFDIR|0755, st_size=4096, …}) = 0
stat64("/usr/lib/perl5/site_perl/5.8.6", {st_mode=S_IFDIR|0755, st_size=4096, …}) = 0
stat64("/usr/lib/perl5/site_perl/5.8.5", {st_mode=S_IFDIR|0755, st_size=4096, …}) = 0
stat64("/usr/lib/perl5/vendor_perl/5.8.7", {st_mode=S_IFDIR|0755, st_size=4096, …}) = 0
stat64("/usr/lib/perl5/vendor_perl/5.8.6", {st_mode=S_IFDIR|0755, st_size=4096, …}) = 0
stat64("/usr/lib/perl5/vendor_perl/5.8.5", {st_mode=S_IFDIR|0755, st_size=4096, …}) = 0
ioctl(0, SNDCTL_TMR_TIMEBASE or TCGETS, {B38400 opost isig icanon echo …}) = 0
_llseek(0, 0, 0xbfc9a000, SEEK_CUR) = -1 ESPIPE (Illegal seek)
ioctl(1, SNDCTL_TMR_TIMEBASE or TCGETS, {B38400 opost isig icanon echo …}) = 0
_llseek(1, 0, 0xbfc9a000, SEEK_CUR) = -1 ESPIPE (Illegal seek)
ioctl(2, SNDCTL_TMR_TIMEBASE or TCGETS, {B38400 opost isig icanon echo …}) = 0
_llseek(2, 0, 0xbfc9a000, SEEK_CUR) = -1 ESPIPE (Illegal seek)
open("/usr/local/nagios_new/bin/p1.pl", O_RDONLY|O_LARGEFILE) = 5
ioctl(5, SNDCTL_TMR_TIMEBASE or TCGETS, 0xbfc9a0b8) = -1 ENOTTY (Inappropriate ioctl for device)
_llseek(5, 0, [0], SEEK_CUR) = 0
fcntl64(5, F_SETFD, FD_CLOEXEC) = 0
fstat64(5, {st_mode=S_IFREG|0664, st_size=31882, …}) = 0
rt_sigaction(SIGCHLD, NULL, {SIG_DFL, ], 0}, 8) = 0
readlink("/proc/self/exe", “/usr/local/nagios_new/bin/nagios”…, 4095) = 32
— SIGSEGV (Segmentation fault) @ 0 (0) —
+++ killed by SIGSEGV +++
[root@mon bin]#

Try recompiling nagios without the embedded perl, and see if performance wise you can still use it.