perl-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stas Bekman <>
Subject [mp2] pool object dependant methods insanity
Date Sat, 18 Dec 2004 17:08:26 GMT
[the previous thread was too long, starting a new one]

*** what methods need to be protected from dependent blocks going out
*** of scope ***

the following looks only at the first level (i.e. methods taking a
pool object):
*** returning objects ***

- mpxs_apr_brigade_create

- apr_bucket_alloc_create
- mpxs_APR__Bucket_setaside

- mpxs_APR__Finfo_stat

- mpxs_apr_ipsubnet_create

- mpxs_apr_pool_create (not sure about this one)

- mpxs_Apache__RequestRec_new

- apr_table_copy
- apr_table_overlay
- apr_table_make

- mpxs_apr_thread_mutex_create

*** returning strings ***

- mpxs_Apache__ServerUtil_server_root_relative (once this is
   supported, we no longer need to double copy the string)

- ap_construct_server
- ap_construct_url

- mpxs_apr_uri_parse

- ap_ht_time
- escape_path

as you can see most of these already use perl wrappers, so I can't quite 
see how this can be automated.

The biggest problem, that this is not enough. If the returned object (by 
one of the above methods) is used to create other objects/SVs,
the latter should be made dependant on the former too. e.g.:


the bucket allocator goes out of scope, before eos bucket, potentially
wiped out eos internals while there are still in use.

so if we try to identify all those, I think we are going to come up with a 
huge list of methods to fix. And most likely there will be 3rd and 4th 
levels as well.

Besides the problem of writing all this code, I think it may add a 
significant memory and CPU overhead.

Ideas for a better solution? We certainly can't leave things like there 
are, for example at the moment this perfectly well written code:

     $pool = APR::Pool->new();
     my $mutex = APR::ThreadMutex->new($pool);

will crash with apr built "--enable-pool-debug 
CPPFLAGS="-DAPR_BUCKET_DEBUG" (or in a real world application), since 
$pool goes out of scope before the mutex is destroyed.

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

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

View raw message