[Nagios-devel] Problems when trying to use Nagios embedded Perl interpreter

Sébastien Aperghis-Tramoni sebastien at aperghis.net
Fri Feb 5 18:39:36 UTC 2010


Hello,


At work, we wrote an event broker plugin which currently embeds its own
Perl interpreter. Now we are trying to remove this second interpreter
and use the native Nagios embedded interpreter instead. However, we are
faced with some technical difficulties, some being quite puzzling.

Technical context : Debian Etch x86-64, Nagios 3.0.6, Perl 5.8.8


First, its seems that the Nagios Perl interpreter has some kind of
limitations in how it can be used : any use of eval_pv() leads to a
SIGSEGV. gdb says it occurs within Perl_newSVpv(). A small program
(mostly) replicating the way Nagios initialises its interpreter (as
per base/utils.c:init_embedded_perl) doesn't expose the same behaviour:

    int main(int argc, char **argv, char **env) {
        int     embed_argc      = 3;
        char    *embedding[]    = { "", "/usr/lib/nagios3/p1.pl" };

        PERL_SYS_INIT3(&embed_argc, &embedding, &env);
        my_perl = perl_alloc();
        perl_construct(my_perl);

        perl_parse(my_perl, xs_init, embed_argc, embedding, env);
        perl_run(my_perl);

        eval_pv("print STDERR qq|OH HAI\n|; 42;", TRUE);

        perl_destruct(my_perl);
        perl_free(my_perl);
        PERL_SYS_TERM();

        return 0;
   }

prints "OH HAI", as expected.


Being unable to use eval_pv("require 'myfile.pl'") within the event
broker plugin, I used the mechanism documented in p1.pl, by calling
Embed::Persistent::eval_file() then Embed::Persistent::run_package().
The Perl code is successfully loaded, but then, trying to call_pv()
into one of the Perl functions defined within this code leads to SIGSEGV.

This function is called by the Nagios scheduler (set up by
schedule_new_event()):

    void check_new_cluster_message() {
        dSP;
        PUSHMARK(SP);
        call_pv("Nagios::Cluster::Embedded::CheckNewClusterMessage", G_DISCARD |
G_NOARGS);
    }

When executed, it generates a SIGSEGV. The strange thing is that gdb
points the PUSHMASK line as being the source of it.


Does anybody have a pointer or have encountered such a situation?
Did I do something wrong when trying to use Nagios Perl interpreter?


Thanks in advance

-- 
Sébastien Aperghis-Tramoni

Close the world, txEn eht nepO.




More information about the Nagios-devel mailing list