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

Hi, My CGI application runs well on Plain CGI environment. But now I am trying it on mod_perl. It throws the following error:

Attempting to process state: advanced_search Attempting to process sta +te: run_search [Wed Jan 28 10:09:27 2009] -e: Use of uninitialized va +lue in pattern match (m//) at /usr/lib/perl5/site_perl/5.8.8/Data/Ser +ializer.pm line 597. [Wed Jan 28 10:09:27 2009] -e: Use of uninitialized value in subroutin +e entry at /usr/lib/perl5/site_perl/5.8.8/Data/Serializer.pm line 692 +. Magic number checking on storable string failed at ../../lib/Storable. +pm (autosplit into ../../lib/auto/Storable/thaw.al) line 366, at /usr +/lib/perl5/site_perl/5.8.8/Data/Serializer/Storable.pm line 32


If I configure apache(httpd.conf) for the following setting, my application works and retrieve the search results
ScriptAlias /cgi-bin/ "/var/www/cgi-bin/" <Directory "/var/www/cgi-bin"> AllowOverride None Options None Order allow,deny Allow from all </Directory>

But if I change my configuration to:
PerlModule ModPerl::RegistryPrefork Alias /cgi-bin/ /var/www/cgi-bin/ <Location /cgi-bin> SetHandler perl-script PerlResponseHandler ModPerl::RegistryPrefork PerlSendHeader On PerlOptions +ParseHeaders Options +ExecCGI </Location>

Then only i received the error I mentioned above.
please suggest?

Replies are listed 'Best First'.
Re: Magic number checking on storable string failed
by CountZero (Bishop) on Jan 28, 2009 at 05:46 UTC
    We suggest you buy the Monastery a crystal ball, so we can look at your code without you having to show it to the Monks. It would also be interesting to know your version of Perl, the OS and what version of Apache and mod_perl you are running.

    CountZero

    A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

      Hi, Thanks for you reply. you can view the whole application through the followiing link:
      Repository
      And dbwiz2.pl that runs every time and then controller moves to the CGI.pm and then it moves to the Search.pm
      I am getting this problem in parasearch.pm Where I am using Data::Serializer for storing and retrieving the data.
      please suggest.
Re: Magic number checking on storable string failed
by Illuminatus (Curate) on Jan 28, 2009 at 05:50 UTC
    1. It is best to provide a code snippet (preferrably a runnable one) in the post to take a look at.
    2. I am not sure what you mean by 'Plain CGI env' and mod_perl. If the former is run from a shell, and the latter is run by a web server, there is a good probability that the user, cwd, and perl/path search dirs are not what you are expecting them to be
      Please look at the post why mod_perl creating the problem?
Re: Magic number checking on storable string failed
by gone2015 (Deacon) on Jan 28, 2009 at 13:26 UTC

    So, this is a mystery... I'd look at /usr/lib/perl5/site_perl/5.8.8/Data/Serializer.pm line 597 and start tracing back from there. The later messages may or may not be the consequence of the first unitialised value.

    I had a quick look at the current version (Data::Serializer v0.48) on CPAN. Around line 597 I see:

    592: sub _get_token { 593: my $self = (shift); 594: my $line = (shift); 595: #Should be anchored to beginning 596: #my ($token) = $line =~ /\^([^\^]+?)\^/; 597: my ($token) = $line =~ /^\^([^\^]{1,120}?)\^/; 598: return $token; 599: }
    so, if that's the version you're using, it appears that $line is undefined. Seems that _get_token is used only in deserialize(), where it operates on its first argument (after $self), so:
    my $self = (shift); if ($self->raw) { return $self->raw_deserialize(@_); } my $value = (shift); my $token = $self->_get_token($value);
    I see that deserialise() is used in a number of places...

    I would force the initial warning to confess (eg: local $SIG{__WARN__} = sub { confess(@_) };) and see what the stack traceback tells me.

Re: Magic number checking on storable string failed
by Anonymous Monk on Jan 29, 2009 at 08:03 UTC
    Hi,
    If I configure apache(httpd.conf) for the following setting, my application works and retrieve the search results
    ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"
    <Directory "/var/www/cgi-bin">
    AllowOverride None
    Options None
    Order allow,deny
    Allow from all
    </Directory>

    But if I change my configuration to:
    PerlModule ModPerl::RegistryPrefork
    Alias /cgi-bin/ /var/www/cgi-bin/
    <Location /cgi-bin>
    SetHandler perl-script
    PerlResponseHandler ModPerl::RegistryPrefork
    PerlSendHeader On
    PerlOptions +ParseHeaders
    Options +ExecCGI
    </Location>

    Then only i received the error I mentioned in my first post.
    please suggest?
Re: Magic number checking on storable string failed
by mje (Curate) on Jan 28, 2009 at 10:21 UTC

    Perhaps you have created some data with one version of storable, then upgraded Storable and are trying to read it back.

    or perhaps you are not thawing the data you froze

Re: Magic number checking on storable string failed
by shanu_040 (Sexton) on Jan 28, 2009 at 11:26 UTC
    Hi, If that is the case, then what should I do?