Stas Bekman wrote:
I've rebuit with --enable-pool-debug CPPFLAGS="-DAPR_BUCKET_DEBUG", but also apr1/httpd2.1

% ~/perl/5.8.x/bin/perl -MApache2 -MAPR::Pool -MAPR::Table -wle '
$t= APR::Table::make(APR::Pool->new, 10); $t->set($_=>$_), print "Set $_" for 1..20'


Segmentation fault


Now I get the segfault

So trying to go the way Joe has chosen for apreq, I've replaced the plain apr_table_make autogenerated wrapper with explicit:


static MP_INLINE SV *mpxs_APR__Table_make(pTHX_ SV *p_sv, int nelts)
{
    apr_pool_t *p = mp_xs_sv2_APR__Pool(p_sv);
    apr_table_t *t = apr_table_make(p, nelts);
    SV *t_sv = mp_xs_APR__Table_2obj(t);
    sv_magic(SvRV(t_sv), p_sv, PERL_MAGIC_ext, Nullch, -1);
    return t_sv;
}

and segfault is gone. here we create a dependency p_sv <- t_sv, so only when t_sv goes out of scope the pool object will be destroyed, and this code is now safe:

  APR::Table::make(APR::Pool->new, 10);

Unfortunately it doesn't seem like this dependency code can be easily integrated with the automatic type conversion, because the code accepts a single argument in xs/modperl_xs_sv_convert.h.

At the moment we will need to rewrite all methods that accept the pool object, like I did for APR::Table::make above. for example inside APR::Table there are also copy() and overlay() that need the same solution.

Any suggestions?

I'm thinking whether we could use the same solution for PV return values that use the pool object. For example with server_root_relative(), see the end of notes at:
http://perl.apache.org/docs/2.0/api/Apache/ServerUtil.html#C_server_root_relative_
which documents the danger of having the SvPV having a hole in body if the pool went out of scope. I guess we can attach the same magical dependency there too.


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

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to