apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stas Bekman <s...@stason.org>
Subject Re: [Fwd: [mp2] coredump strerror code on Solaris 8
Date Wed, 08 Sep 2004 22:18:49 GMT
Joe Orton wrote:
> On Wed, Sep 08, 2004 at 05:01:33PM -0400, Stas Bekman wrote:
>>Here is another:
>>(gdb) bt
>>#0  apr_cpystrn (dst=0xffbef010 "", src=0x0, dst_size=4290703375)
>>   at apr_cpystrn.c:57
>>#1  0xff1d4c4c in stuffbuffer (buf=0xffbeef10 "", bufsize=256, s=0x0)
>>   at errorcodes.c:34
>>#2  0xfee074f0 in modperl_error_strerror (rc=500) at modperl_error.c:37
>>#3  0xfe990c90 in XS_APR__Error_strerror (cv=0x1f4) at Error.xs:36
>>In the second one the trace seems to be optimized away, since 
>>modperl_error_strerror does not call stuffbuffer, so it's some internal 
>>function that is broken.
> Three cheers for tail call recursion...  I guess mod_perl_error_strerror
> will call apr_strerror(500, buf, 256) in this case?  Bets are 500 is an
> HTTP status code rather than a genuine apr_status_t so you probably
> didn't really want to do that, but it probably shouldn't segfault
> either.

That's right. Unfortunately Apache didn't provide a way to handle errors 
in filters. I suppose it was assumed that filters can't go wrong. So 500 
is how we try to tell the request that there was a problem in the filter.

But normally apr_strerror(500, buf, 256) returns "not specified error" 
string or something like that, which is cool. Why does it segfault is what 
I can't understand. Notice that it doesn't happen on linux.

The segfault is triggered by mp2 test t/filter/in_error.t should you try 
to reproduce it. This test calls perl's die in the filter to emulate a 
filter error and that's when Arshavir was getting the segfault.

Here is the implementation of modperl_error_strerror:

char *modperl_error_strerror(pTHX_ apr_status_t rc)
     char *ptr;
     char buf[256];

     if (rc >= APR_OS_START_USERERR &&
         rc < APR_OS_START_USERERR + MP_error_strings_size) {
         /* custom mod_perl errors */
         ptr = (char*)MP_error_strings[(int)(rc - APR_OS_START_USERERR)];
     else {
         /* apache apr errors */
         ptr = apr_strerror(rc, buf, sizeof(buf));

     /* must copy the string and not return a pointer to the local
      * address. Using a single (per interpreter) static buffer.
     return Perl_form(aTHX_ "%s", ptr);

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

View raw message