You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Stas Bekman <st...@stason.org> on 2005/05/03 08:56:50 UTC

Re: [MP2] : REDIRECT_ERROR_NOTES not set on errordocument redirect

Mark wrote:
> -------------8<---------- Start Bug Report ------------8<----------
> 1. Problem Description:
> 
> $ENV{REDIRECT_ERROR_NOTES} not working with MP2
> 
> Using latest everything (modperl 2 RC5).
> 
> 
> To illustrate, I simply configure Apache with an errordocument:
> 
>    ErrorDocument 500 /cgi/printenv
> 
> I have a perl-scripts configured like this:
> 
>   <Directory "/usr/local/apache2/perl">
>     Options ExecCGI
>     SetHandler perl-script
>     PerlResponseHandler ModPerl::Registry
>     PerlOptions +ParseHeaders
>   </Directory>
> 
> And a script the generates an error:
> 
>   #/usr/bin/perl
>   barf();
> 
> 
> The errordocument 'printenv' output shows REDIRECT_ERROR_NOTES empty.
> 
> When the identical barf script is run under CGI (script-alias), 
> REDIRECT_ERROR_NOTES
> has an error message.
> 
> 
> I fooled around with more complex examples, accessing ARP table 
> 'error-notes' and
> that is also empty.

because you are in the sub request. the value is set in $r->main 
'error-notes' table. I wonder why the sub-request doesn't see it.

Also I wonder if we should adjust in ModPerl::RegistryCooker:

  sub log_error {
      my($self, $msg) = @_;
      my $class = ref $self;

-    $self->{REQ}->log_error($msg);
-    $self->{REQ}->notes->set('error-notes' => $msg);
+    $self->{REQ}->log_rerror($msg);
      $@{$self->{URI}} = $msg;
  }

which is supposed to do that same in one call. Any difference with the 
above change?

> *** The httpd binary was not found

what Apache is that?

-- 
__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com

Re: [MP2] : REDIRECT_ERROR_NOTES not set on errordocument redirect

Posted by Mark <ma...@immermail.com>.
Stas Bekman wrote:
> Mark wrote:
> 
>> -------------8<---------- Start Bug Report ------------8<----------
>> 1. Problem Description:
>>
>> $ENV{REDIRECT_ERROR_NOTES} not working with MP2
>>
>> Using latest everything (modperl 2 RC5).
>>
>>
>> To illustrate, I simply configure Apache with an errordocument:
>>
>>    ErrorDocument 500 /cgi/printenv
>>
>> I have a perl-scripts configured like this:
>>
>>   <Directory "/usr/local/apache2/perl">
>>     Options ExecCGI
>>     SetHandler perl-script
>>     PerlResponseHandler ModPerl::Registry
>>     PerlOptions +ParseHeaders
>>   </Directory>
>>
>> And a script the generates an error:
>>
>>   #/usr/bin/perl
>>   barf();
>>
>>
>> The errordocument 'printenv' output shows REDIRECT_ERROR_NOTES empty.
>>
>> When the identical barf script is run under CGI (script-alias), 
>> REDIRECT_ERROR_NOTES
>> has an error message.
>>
>>
>> I fooled around with more complex examples, accessing ARP table 
>> 'error-notes' and
>> that is also empty.
> 
> 
> because you are in the sub request. the value is set in $r->main 
> 'error-notes' table. I wonder why the sub-request doesn't see it.

Sorry, I wasn't clear about that.  In my tests using APR table,
I did look at the previous request, which is where I expected to
find the error-notes.  Here's my handler:

sub handler {
     my $r = shift;

     my $pr = $r->prev;

     $r->content_type('text/plain');

     # dump out the previous request's notes table
     my $table = $pr->notes;
     foreach my $key (keys %{$table}) {
         printf "$key = '%s'\n", $table->{$key};
     }

     ...



> Also I wonder if we should adjust in ModPerl::RegistryCooker:
> 
>  sub log_error {
>      my($self, $msg) = @_;
>      my $class = ref $self;
> 
> -    $self->{REQ}->log_error($msg);
> -    $self->{REQ}->notes->set('error-notes' => $msg);
> +    $self->{REQ}->log_rerror($msg);
>      $@{$self->{URI}} = $msg;
>  }
> 
> which is supposed to do that same in one call. Any difference with the 
> above change?

With this in place (which I admit I don't understand) error-notes is
now populated, but maybe the wrong stack frame or something, since
the error text is not the actual error from the original request.
I will study this further, maybe this is somehow my problem?


> what Apache is that?

Server version: Apache/2.0.53

Thanks,

Mark

Re: [MP2] : REDIRECT_ERROR_NOTES not set on errordocument redirect

Posted by Stas Bekman <st...@stason.org>.
Mark wrote:
[...]
>> Could it possibly come from here?
>>
>> src/modules/perl/modperl_callback.c
>>
>>     if (status == HTTP_INTERNAL_SERVER_ERROR) {
>>         if (r && r->notes) {
>>             apr_table_set(r->notes, "error-notes", SvPV_nolen(ERRSV));
>>         }
>>     }
>>
>> And we should check whether error-notes is already set and append the 
>> error instead?
> 
> 
> Yes, this appears to be the culprit.  Based on my glance at apr_tables.h,
> I concluded this was the right thing to do, and it works:
> 
> - apr_table_set(r->notes, "error-notes", SvPV_nolen(ERRSV));
> + apr_table_mergen(r->notes, "error-notes", SvPV_nolen(ERRSV));
> 
> (I did this on 2.0.0 release)

Thanks Mark, committed.


-- 
__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com

Re: [MP2] : REDIRECT_ERROR_NOTES not set on errordocument redirect

Posted by Mark <ma...@immermail.com>.
Stas Bekman wrote:
> Mark wrote:
> 
>> Stas Bekman wrote:
>>
>>> Mark wrote:
>>>
>>>> -------------8<---------- Start Bug Report ------------8<----------
>>>> 1. Problem Description:
>>>>
>>>> $ENV{REDIRECT_ERROR_NOTES} not working with MP2
>>>>
>>>> Using latest everything (modperl 2 RC5).
>>>>
>>>>
>>>> To illustrate, I simply configure Apache with an errordocument:
>>>>
>>>>    ErrorDocument 500 /cgi/printenv
>>>>
>>>> I have a perl-scripts configured like this:
>>>>
>>>>   <Directory "/usr/local/apache2/perl">
>>>>     Options ExecCGI
>>>>     SetHandler perl-script
>>>>     PerlResponseHandler ModPerl::Registry
>>>>     PerlOptions +ParseHeaders
>>>>   </Directory>
>>>>
>>>> And a script the generates an error:
>>>>
>>>>   #/usr/bin/perl
>>>>   barf();
>>>>
>>>>
>>>> The errordocument 'printenv' output shows REDIRECT_ERROR_NOTES empty.
>>>>
>>>> When the identical barf script is run under CGI (script-alias), 
>>>> REDIRECT_ERROR_NOTES
>>>> has an error message.
>>>>
>>>>
>>>> I fooled around with more complex examples, accessing ARP table 
>>>> 'error-notes' and
>>>> that is also empty.
>>>
>>>
>>>
>>>
>>> because you are in the sub request. the value is set in $r->main 
>>> 'error-notes' table. I wonder why the sub-request doesn't see it.
>>>
>>> Also I wonder if we should adjust in ModPerl::RegistryCooker:
>>>
>>>  sub log_error {
>>>      my($self, $msg) = @_;
>>>      my $class = ref $self;
>>>
>>> -    $self->{REQ}->log_error($msg);
>>> -    $self->{REQ}->notes->set('error-notes' => $msg);
>>> +    $self->{REQ}->log_rerror($msg);
>>>      $@{$self->{URI}} = $msg;
>>>  }
>>>
>>> which is supposed to do that same in one call. Any difference with 
>>> the above change?
>>
>>
>>
>> OK, I installed RC6 (no change with that) and poked around a little more.
>>
>> $r->prev->notes->get('error-notes') is definitely empty in the 
>> errordocument
>> handler, despite being set in ModPerl::RegistryCooker as shown above.
>>
>> However, as a test, I changed 'error-notes' to 'error-notice' in
>> RegistryCooker::log_error, and voila $r->prev->notes->get('error-notice')
>> does contain the proper error message.
>>
>> This suggests 'error-notes' is being wiped out (re-initialized?) 
>> somewhere
>> after RegistryCooker.  Someone with more knowledge than I can probably
>> guess where this might be happening?
> 
> 
> Could it possibly come from here?
> 
> src/modules/perl/modperl_callback.c
> 
>     if (status == HTTP_INTERNAL_SERVER_ERROR) {
>         if (r && r->notes) {
>             apr_table_set(r->notes, "error-notes", SvPV_nolen(ERRSV));
>         }
>     }
> 
> And we should check whether error-notes is already set and append the 
> error instead?

Yes, this appears to be the culprit.  Based on my glance at apr_tables.h,
I concluded this was the right thing to do, and it works:

- apr_table_set(r->notes, "error-notes", SvPV_nolen(ERRSV));
+ apr_table_mergen(r->notes, "error-notes", SvPV_nolen(ERRSV));

(I did this on 2.0.0 release)

Thanks.

Mark

Re: [MP2] : REDIRECT_ERROR_NOTES not set on errordocument redirect

Posted by Stas Bekman <st...@stason.org>.
Mark wrote:
> Stas Bekman wrote:
> 
>> Mark wrote:
>>
>>> -------------8<---------- Start Bug Report ------------8<----------
>>> 1. Problem Description:
>>>
>>> $ENV{REDIRECT_ERROR_NOTES} not working with MP2
>>>
>>> Using latest everything (modperl 2 RC5).
>>>
>>>
>>> To illustrate, I simply configure Apache with an errordocument:
>>>
>>>    ErrorDocument 500 /cgi/printenv
>>>
>>> I have a perl-scripts configured like this:
>>>
>>>   <Directory "/usr/local/apache2/perl">
>>>     Options ExecCGI
>>>     SetHandler perl-script
>>>     PerlResponseHandler ModPerl::Registry
>>>     PerlOptions +ParseHeaders
>>>   </Directory>
>>>
>>> And a script the generates an error:
>>>
>>>   #/usr/bin/perl
>>>   barf();
>>>
>>>
>>> The errordocument 'printenv' output shows REDIRECT_ERROR_NOTES empty.
>>>
>>> When the identical barf script is run under CGI (script-alias), 
>>> REDIRECT_ERROR_NOTES
>>> has an error message.
>>>
>>>
>>> I fooled around with more complex examples, accessing ARP table 
>>> 'error-notes' and
>>> that is also empty.
>>
>>
>>
>> because you are in the sub request. the value is set in $r->main 
>> 'error-notes' table. I wonder why the sub-request doesn't see it.
>>
>> Also I wonder if we should adjust in ModPerl::RegistryCooker:
>>
>>  sub log_error {
>>      my($self, $msg) = @_;
>>      my $class = ref $self;
>>
>> -    $self->{REQ}->log_error($msg);
>> -    $self->{REQ}->notes->set('error-notes' => $msg);
>> +    $self->{REQ}->log_rerror($msg);
>>      $@{$self->{URI}} = $msg;
>>  }
>>
>> which is supposed to do that same in one call. Any difference with the 
>> above change?
> 
> 
> OK, I installed RC6 (no change with that) and poked around a little more.
> 
> $r->prev->notes->get('error-notes') is definitely empty in the 
> errordocument
> handler, despite being set in ModPerl::RegistryCooker as shown above.
> 
> However, as a test, I changed 'error-notes' to 'error-notice' in
> RegistryCooker::log_error, and voila $r->prev->notes->get('error-notice')
> does contain the proper error message.
> 
> This suggests 'error-notes' is being wiped out (re-initialized?) somewhere
> after RegistryCooker.  Someone with more knowledge than I can probably
> guess where this might be happening?

Could it possibly come from here?

src/modules/perl/modperl_callback.c

     if (status == HTTP_INTERNAL_SERVER_ERROR) {
         if (r && r->notes) {
             apr_table_set(r->notes, "error-notes", SvPV_nolen(ERRSV));
         }
     }

And we should check whether error-notes is already set and append the 
error instead?

-- 
__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com

Re: [MP2] : REDIRECT_ERROR_NOTES not set on errordocument redirect

Posted by Mark <ma...@immermail.com>.
Stas Bekman wrote:
> Mark wrote:
> 
>> -------------8<---------- Start Bug Report ------------8<----------
>> 1. Problem Description:
>>
>> $ENV{REDIRECT_ERROR_NOTES} not working with MP2
>>
>> Using latest everything (modperl 2 RC5).
>>
>>
>> To illustrate, I simply configure Apache with an errordocument:
>>
>>    ErrorDocument 500 /cgi/printenv
>>
>> I have a perl-scripts configured like this:
>>
>>   <Directory "/usr/local/apache2/perl">
>>     Options ExecCGI
>>     SetHandler perl-script
>>     PerlResponseHandler ModPerl::Registry
>>     PerlOptions +ParseHeaders
>>   </Directory>
>>
>> And a script the generates an error:
>>
>>   #/usr/bin/perl
>>   barf();
>>
>>
>> The errordocument 'printenv' output shows REDIRECT_ERROR_NOTES empty.
>>
>> When the identical barf script is run under CGI (script-alias), 
>> REDIRECT_ERROR_NOTES
>> has an error message.
>>
>>
>> I fooled around with more complex examples, accessing ARP table 
>> 'error-notes' and
>> that is also empty.
> 
> 
> because you are in the sub request. the value is set in $r->main 
> 'error-notes' table. I wonder why the sub-request doesn't see it.
> 
> Also I wonder if we should adjust in ModPerl::RegistryCooker:
> 
>  sub log_error {
>      my($self, $msg) = @_;
>      my $class = ref $self;
> 
> -    $self->{REQ}->log_error($msg);
> -    $self->{REQ}->notes->set('error-notes' => $msg);
> +    $self->{REQ}->log_rerror($msg);
>      $@{$self->{URI}} = $msg;
>  }
> 
> which is supposed to do that same in one call. Any difference with the 
> above change?

OK, I installed RC6 (no change with that) and poked around a little more.

$r->prev->notes->get('error-notes') is definitely empty in the errordocument
handler, despite being set in ModPerl::RegistryCooker as shown above.

However, as a test, I changed 'error-notes' to 'error-notice' in
RegistryCooker::log_error, and voila $r->prev->notes->get('error-notice')
does contain the proper error message.

This suggests 'error-notes' is being wiped out (re-initialized?) somewhere
after RegistryCooker.  Someone with more knowledge than I can probably
guess where this might be happening?

Mark