Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

uh... segfault. mod_perl, Apache::DBI and other atrocities.

by vaevictus (Pilgrim)
on Jul 05, 2001 at 00:39 UTC ( [id://93939]=perlquestion: print w/replies, xml ) Need Help??

vaevictus has asked for the wisdom of the Perl Monks concerning the following question:

Code below *sometimes* causes segfaults. Not perl crashes... works fine as CGI or commandline...
#!/usr/bin/perl -wT use strict; use CGI qw/:standard/; use lib "/home/vae/perl"; print header; execute(); info(); print end_html; sub execute { use strict; use CGI qw/:standard/; print h1("hi"); } sub info { use strict; use CGI qw/:standard/; use DBI; my $DSN= "DBI:mysql:vaevictus"; my $user= "vaevictus"; my $pass= ""; #censored. :) my $dbh = DBI->connect($DSN,$user,$pass) or print h1('nope'); print h1("hi"); $dbh->disconnect; }

Replies are listed 'Best First'.
Re: uh... segfault. mod_perl, Apache::DBI and other atrocities.
by chromatic (Archbishop) on Jul 05, 2001 at 01:29 UTC
    You don't need to re-use modules and pragmas, though I doubt that's causing your troubles. I'd remove them from within your subroutines anyway, because they're not doing anything for you. (Move 'use DBI' to the start of the program, or say require DBI instead.)

    I saw segfaults with mod_perl due to the interaction of XML::Parser and the trimmed-down Expat shipped with Apache. I had to rebuild Apache and disable Expat linkings (with 1.3.20, it's something like --disable-rule=EXPAT) to fix it, but it worked correctly after that.

    I'd suggest revising your code, testing again, testing with a very very simple "Hello, World!" mod_perl program, and then trying the recompile. Unless someone comes up with a better suggestion, that is.

      I'll try rebuilding without Expat... And ... 1. I removed all the extra uses and moved use dbi (it was like that cause i copied out of a package... and of course it still produces the same segfaults...
      Although recompiling apache is a somewhat involved solution (depending on how it got compiled in the first place) I would second the recommendation. I also have run into segfault issues with XML::Parser and the built in apache expat.
Re: uh... segfault. mod_perl, Apache::DBI and other atrocities.
by toma (Vicar) on Jul 05, 2001 at 04:12 UTC
    Make sure that you are using the exact versions of perl and apache that are supported by mod_perl. When I built mod_perl it relied on versions of perl and apache that were slightly out of date. This did not appear to be the usual, "well, we say it's supported with these versions because that's how we tested it, but other versions may work." It was more like, "the only way this will possibly work is if you use these *exact* versions."

    It should work perfectly the first time! - toma

Re: uh... segfault. mod_perl, Apache::DBI and other atrocities.
by vaevictus (Pilgrim) on Jul 05, 2001 at 01:02 UTC
    I should rephrase... it *always* segfaults... sometimes it gets through execute() and sometimes it doesn't....
Re: uh... segfault. mod_perl, Apache::DBI and other atrocities.
by vaevictus (Pilgrim) on Jul 06, 2001 at 03:22 UTC
    So as a go to set up php for the new server ... i see this at the bottom of the ./configure output...
    +--------------------------------------------------------------------+ | *** WARNING *** | | | | You chose to compile PHP with the built-in MySQL support. If you | | are compiling a server module, and intend to use other server | | modules that also use MySQL (e.g, mod_auth_mysql, PHP 3.0, | | mod_perl) you must NOT rely on PHP's built-in MySQL support, and | | instead build it with your local MySQL support files, by adding | | --with-mysql=/path/to/mysql to your configure line. | +--------------------------------------------------------------------+
    .... *argh* .... *sigh* ....

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://93939]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (5)
As of 2024-04-24 07:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found