perl-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stas Bekman <>
Subject Re: t/perl/ithreads.t revisited
Date Mon, 13 Dec 2004 18:45:17 GMT
Steve Hay wrote:

> I now get this in the stderr.txt file:
> SV = PV(0x31f64d0) at 0x31960b8
>   REFCNT = 1
>   PV = 0x31f7ed4 "ModPerl::Util::exit: (120000) exit was called at 
> C:/apache2/perl5/site/lib/Apache/ line 238"\0
>   CUR = 98
>   LEN = 99
> Attempt to free temp prematurely: SV 0x31960b8, Perl interpreter: 
> 0x2b51784 at 
> C:/Temp/bug-reporting-skeleton-mp2/t/response/TestPerl/ line 56.
> Scalars leaked: 1

Getting back to the exit function itself called from Apache::Test::plan().

This sv thing shouldn't have really happened. How does exit works in mp2:

void modperl_perl_exit(pTHX_ int status)
     PL_diehook = Nullsv;
     modperl_croak(aTHX_ MODPERL_RC_EXIT, "ModPerl::Util::exit");

so exit calls modperl_croak(), which creates an APR::Error exception 
object and throws it via Perl_croak(aTHX_ Nullch);

Now when the handler returns its status goes through modperl_errsv() which 
has a special case for objects thrown from exit()'s call.

int modperl_errsv(pTHX_ int status, request_rec *r, server_rec *s)
     SV *sv = ERRSV;
     STRLEN n_a;

     if (SvTRUE(sv)) {
         if (sv_derived_from(sv, "APR::Error") &&
             SvIVx(sv) == MODPERL_RC_EXIT) {
             /* ModPerl::Util::exit was called */
             return OK;

the actual stringification of the exception object into a string:

"ModPerl::Util::exit: (120000) exit was called at 
C:/apache2/perl5/site/lib/Apache/ line 238"\0

happens only if something tries to stringify $@ or bool'ify. But this 
stringification is done by a perl code in APR::Error, which overloads:

use overload
     nomethod => \&fatal,
     'bool'   => \&str,
     '=='     => \&num,
     '0+'     => \&num,
     '""'     => \&str;

sub str {
     sprintf "%s: (%d) %s at %s line %d", $_[0]->{func},
         $_[0]->{rc}, APR::Error::strerror($_[0]->{rc}),
         $_[0]->{file}, $_[0]->{line};

and this is what your SV's PV string looks like. So there is no really any 
C code here that could get the refcounting wrong.

may be this is something triggered by overload? what happens if you 
comment out the overload part?

(notice that APR::Error is autogenerated, so you may want to modify
blib/lib/Apache2/APR/ if you don't want to rebuild things)

alternatively try to add CORE::dump() inside str() above to see who has 
called the stringification function.

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

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message