Question

I have a rather complex problem to describe. I'm looking for any suggestions for further debugging.

I'm trying to convert to mod_perl from regular cgi. I send an http request to a script that loads up a page, and on that page there are links to load images that are retrieved via further scripts (in other words, the images are loaded via a cgi script, not just a plain link). So when the page loads in the browser, the browser kicks off half a dozen more requests that run scripts to load the images.

The first script (initial page load) runs fine, but sometime after that the apache server goes into a tight loop (very high cpu usage and has to be killed) when processing the image load scripts. Sometimes one of the image load scripts runs fine but a further one loops, sometimes it's the first image load script that loops. strace doesn't show up anything during the loop.

I've started the apache server in single user mode (with -X) and run the interactive perl debugger with trace on to see where the loop starts. I've done this several times, and each time it starts in exactly the same place, during processing of the 'use' statements. I see piles and piles of 'use' and 'require' statements going by, along with other junk, but it always stops at:

Params::Classify::CODE(0x7f43b0b46dd8)(/usr/lib/perl5/Params/Classify.pm:97):
97:     eval { local $SIG{__DIE__};
Params::Classify::CODE(0x7f43b0b46dd8)(/usr/lib/perl5/Params/Classify.pm:97):
97:     eval { local $SIG{__DIE__};
Params::Classify::CODE(0x7f43b0b46dd8)(/usr/lib/perl5/Params/Classify.pm:98):
98:             require XSLoader;
Params::Classify::CODE(0x7f43b0b46dd8)(/usr/lib/perl5/Params/Classify.pm:99):
99:             XSLoader::load(__PACKAGE__, $VERSION);
Params::Classify::CODE(0x7f43b0b46dd8)(/usr/lib/perl5/Params/Classify.pm:102):
102:    if($@ eq "") {
Params::Classify::CODE(0x7f43b0b46dd8)(/usr/lib/perl5/Params/Classify.pm:103):
103:            close(DATA);
Params::Classify::CODE(0x7f43b0b46dd8)(/usr/lib/perl5/Params/Classify.pm:130):
130:    1;
Data::Entropy::CODE(0x7f43b0b46dd8)(/usr/share/perl5/Data/Entropy.pm:46):
46:     use Params::Classify 0.000 qw(is_ref);
Data::Entropy::CODE(0x7f43b0b46dd8)(/usr/share/perl5/Data/Entropy.pm:46):
46:     use Params::Classify 0.000 qw(is_ref);

This section of 'use' processing is kicked off in my script with:

use Authen::Passphrase::BlowfishCrypt;

I've done some searches on Data::Entropy and Params::Classify and didn't find anything useful (which is what I expected - I doubt there is a bug with them).

This has the feel of memory corruption from previous script runs, but I'm not sure yet how to track it down. Since I'm new to mod_perl I thought I'd run it by some experts to see if they've run into something similar or have suggestions on how I can further debug this.

Running apache/2.2.22 mod_perl/2.0.5 perl/5.14.2.

Code is pretty basic, but here it is:

package Wii::Web;

use strict;
use warnings;

use base qw(Wii);

use Data::Dumper;
use Params::Validate qw(:all);
use Log::Log4perl qw(get_logger :easy);
use CGI;
use Carp qw(cluck);
use Email::Valid;
use Authen::Passphrase::BlowfishCrypt;
use Digest::SHA;
use Digest::HMAC;
use Time::HiRes qw(gettimeofday tv_interval);
use Wii::Web::View;
use Wii::Web::Register;
use Wii::Web::Login;
use Wii::Web::Session;
use Wii::Web::User;
use Wii::Web::Found;

$CGI::POST_MAX = 1024 * 5000;

BEGIN {
  $SIG{__DIE__} = \&sigDie;
}

sub sigDie {
  return if $^S; # we are in an eval block

  # assume this is the first print
  my ($error) = @_;
  print "Status: 500\n";
  print "Content-type: text/html\n\n";
  print "<html><body>\n";
  print "<h3>Whoops there was an error!</h3>\n";
  print "<!-- $error  -->\n";
  print "Please try again later<br />\n";
  print "<b>$error</b>\n";
  print "</body></html>\n";

  Wii::sigDie(@_);

  return 1;
}
<snip>

There are other modules involved before this one, but this is the one that kicks off the problem.

Was it helpful?

Solution

Params::Classify::XS is not thread safe. Switch from using the XS to perl Perl version.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top