perl-modperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stas Bekman <>
Subject Re: Modification of read only value attempted
Date Wed, 06 Jul 2005 16:37:31 GMT
Malte Ubl wrote:
> Hi,
> I'd really appreciate some help with a really weird mod_perl problem we 
> keep running into.
> This is mod_perl version 1.29 using Apache::PerlRun
> The application servers of our mod_perl site occasionally (once every 
> 2-3 weeks) start spitting out these error messages:
> [Sun Jul  3 14:58:01 2005] [error] Modification of a read-only value 
> attempted at 
> /usr/local/lib/perl5/site_perl/5.8.6/i686-linux/Apache/ line 
> 215.\n
> At first only a couple Apache childs seem to be affected but after a 
> while the error comes on every single request, so the whole website 
> comes to a stall.

Can you reproduce the problem at will?

> The problem only accurs if the central mainframe we are working against 
> is having a problem and we are doing a lot of error handling. However, 
> the problem does not alway occur if there is a problem with the 
> mainframe and all processing that actually does get started finishes 
> totally fine.
> The relevant line in is
> sub readscript {
>     my $pr = shift;
>     $pr->{'code'} = $pr->{r}->slurp_filename; # this is line 215
> }
> My understanding of the "Modfication of read-only..." error is that it 
> cant really occur on that line, since there are no literals being modified.
> Any help or pointer in the right direction would be really appreciated. 
> If the solution is to move away from Apache::PerlRun to something else 
> that would be alright, too. We'd like to avoid it though, because we are 
> satisfied with the speed and don't want to repeat the whole testing phase.

Quite often the error line is reported incorrectly. You can always add 
something like:

#line 215
    $pr->{'code'} = $pr->{r}->slurp_filename;

That's a special directive telling perl that the next line number is 215, 
so you will know for sure that this is the line it's talking about.

Once you figure out the exact line, you need to figure out where the error 
is coming from? You could use Devel::Peek to see what variable is 
readonly. e.g.:

use Devel::Peek;
my $x = 5;
Dump $x;

For example $$ is readonly, so you get:

perl -MDevel::Peek -le 'Dump $$'
SV = IV(0x805d9b0) at 0x805b7cc
   REFCNT = 1
   IV = 16911

You can see the readonly flag set.

Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker     mod_perl Guide --->

View raw message