Strange characters in output when using check_logfiles with 3.0a5

Ethan Galstad nagios at nagios.org
Mon Jul 16 17:29:16 CEST 2007


Hendrik Bäcker wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> Hi List,
> 
> I've played a little bit with the actual cvs code and I can say:
> 
> 1. Yes - it's a bug ;)
> 2. No  - I don't have a patch
> 3. Yes - I think I've found the killer
> 4. No  - I don't know what there's going on - but perhaps others can
> explain.
> 
> My testing environment:
> 
> 1. Edit the <prefix>/bin/p1.pl on line
> after line 294:
> 
>         untie *STDOUT;
> 
> add:
> 	print "PRIVATE DEBUG p1.pl says: $plugin_output\n";
> 
> or trust me when I say: in p1.pl the output is fine!
> 
> 2. change base/checks.c around line 639 so that we have:
> 
> perl_plugin_output=POPpx;
> printf("PRIVATE DEBUG: Nagios says after POPpx: %s\n",perl_plugin_output);
> // Trust me Output is fine
> 
> pclose_result=POPi;
> printf("PRIVATE DEBUG: Nagios says after POPi: %s\n",perl_plugin_output);
> PUTBACK;
> printf("PRIVATE DEBUG: Nagios says after PUTBACK: %s\n",perl_plugin_output);
> FREETMPS;
> printf("PRIVATE DEBUG: Nagios says after FREETMPS:
> %s\n",perl_plugin_output);
> LEAVE;
> printf("PRIVATE DEBUG: Nagios says LEAVE: %s\n",perl_plugin_output);
> 
> 
> My Output after compile and force a ePN Plugin Check:
> PRIVATE DEBUG: p1.pl says: CRITICAL - Test down
> PRIVATE DEBUG: Nagios says after POPpx: CRITICAL - Test down
> PRIVATE DEBUG: Nagios says after POPi: CRITICAL - Test down
> PRIVATE DEBUG: Nagios says after PUTBACK: CRITICAL - Test down
> PRIVATE DEBUG: Nagios says after FREETMPS:
> PRIVATE DEBUG: Nagios says LEAVE:
> 
> So.. there seem to be a problem with FREETMPS...
> 
> On http://perldoc.perl.org/perlcall.html there is the info:
> 
> ###
> The FREETMPS /LEAVE  pair will get rid of any values returned by the
> Perl subroutine (see next example), plus it will also dump the mortal
> SVs we have created. Having ENTER /SAVETMPS  at the beginning of the
> code makes sure that no other mortals are destroyed.
> ###
> 
> I can imagine that the FREETMPS is destroying to much of the stack where
> the var plugin_output lives... but this is only a thought.
> 
> Are there any Perl / C gurus out there who can explain this behavior?
> 
> Regards
> Hendrik
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.6 (GNU/Linux)
> 
> iD8DBQFGlmy/lI0PwfxLQjkRAj+oAJ9YNCXFoDI9/2fpxs8bFGWsA+3v2ACfRhVy
> DKqMrGX6BMrkgyOj4RBBMac=
> =Uyyt
> -----END PGP SIGNATURE-----

Good debugging!  It looks as though the POPpx pointer was invalid after 
the FREETMPS call.  I compared the Nagios 3.x code to 2.x and found that 
I moved the code that save the plugin output to a point after the 
FREETMPS call.  I just fixed the code (and verified it works).  Patch 
has been posted to CVS. :-)

Ethan Galstad,
Nagios Developer
---
Email: nagios at nagios.org
Website: http://www.nagios.org

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/




More information about the Developers mailing list