__Unofficial__ patch for embedded Perl Interpeter support in Nagios 1.1 (fixes SEGV on start-up with threaded typically Linux Perls).

Stanley Hopcroft Stanley.Hopcroft at IPAustralia.Gov.AU
Sat Jun 21 08:14:25 CEST 2003


Dear Ladies and Gentlemen,

The Nagios kibutzers take great pleasure in announcing an _unofficial_
patch for embedded Perl support in Nagios 1.1.

The patch, while not extensively tested, _should_ fix the SEGV on
starting up (for any args, -h -m or -v) of a Nagios 1.1 configured
with an embedded Perl interpreter (for greater efficiency in executing
Perl plugins).

Details below.

Status

	Unofficial, unsactioned, and unsupported (vi) patch for SEGVs on
start-up of Nagios built with an embedded Perl interpreter.

	The SEGV occurs right at start-up and is associated with
libperl.so (it may occur at the first printf in the main program). It
only occurs with threaded Perls that are typically shipped with systems
having good pthread OS support.

	Affected systems include

	RH 8 and 9
	Mandrake 9 ( 2.4.19-16mdk )
	Suse     8
	Debian   ?

	Unaffected systems include
	
	FreeBSD RELENG_4 (v4 Release and Stable branches)

	If you have a Linux or Solaris system with a Perl greater than 5.6.1 and
you want an embedded Perl Nag, you need this patch.

Credits

	Ethan Galstad
	Reuben Farrelly

	I believe the patch was originally the work of Mr Reuben
Farrelly from Suse (the Suse 8 Nag 'package' has this problem fixed).

Feedback

	S Hopcroft

Flames
	S Hopcroft

Testing
	compiled and run on Mandrake 9/Perl 5.8.0
	compiled         on FreeBSD 4.8/Perl 5.8.0 {unthreaded]
        compiled and run on FreeBSD 4.7/Perl 5.005 [unthreaded]

Notes

	Should apply to Nag 1.0 but unchecked.

Patch
	attached.

Yours sincerely.



 -- 
------------------------------------------------------------------------
Stanley Hopcroft
------------------------------------------------------------------------

'...No man is an island, entire of itself; every man is a piece of the
continent, a part of the main. If a clod be washed away by the sea,
Europe is the less, as well as if a promontory were, as well as if a
manor of thy friend's or of thine own were. Any man's death diminishes
me, because I am involved in mankind; and therefore never send to know
for whom the bell tolls; it tolls for thee...'

from Meditation 17, J Donne.
-------------- next part --------------
--- nagios.c.orig	2003-06-03 13:47:58.000000000 +1000
+++ nagios.c	2003-06-21 14:37:17.000000000 +1000
@@ -58,6 +58,8 @@
 #include <perl.h>
 static PerlInterpreter *my_perl;
 #include <fcntl.h>
+#undef ctime   /* don't need perl's threaded version */
+#undef printf   /* can't use perl's printf until initialized */
 
 /* include PERL xs_init code for module and C library support */
 
@@ -85,18 +87,22 @@
 #    define EXTERN_C extern
 #  endif
 #endif
- 
-EXTERN_C void xs_init _((void));
 
+#ifdef THREADEDPERL
+EXTERN_C void xs_init _((pTHX));
+EXTERN_C void boot_DynaLoader _((pTHX_ CV* cv));
+#else
+EXTERN_C void xs_init _((void));
 EXTERN_C void boot_DynaLoader _((CV* cv));
+#endif
 
-EXTERN_C void
-xs_init(void)
-{
-	char *file = __FILE__;
 #ifdef THREADEDPERL
-	dTHX;
+EXTERN_C void xs_init(pTHX)
+#else
+EXTERN_C void xs_init(void)
 #endif
+{
+	char *file = __FILE__;
 	dXSUB_SYS;
 
 	/* DynaLoader is a special case */
--- utils.c.orig	2002-11-18 12:15:13.000000000 +1100
+++ utils.c	2003-06-21 14:48:40.000000000 +1000
@@ -49,6 +49,11 @@
 #include <fcntl.h>
 /* In perl.h (or friends) there is a macro that defines sighandler as Perl_sighandler, so we must #undef it so we can use our sighandler() function */
 #undef sighandler
+/* and we don't need perl's reentrant versions */
+#undef localtime
+#undef getpwnam
+#undef getgrnam
+#undef strerror
 #endif
 
 char            *my_strtok_buffer=NULL;


More information about the Users mailing list