apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bojan Smojver" <bo...@rexursive.com>
Subject Re: svn commit: r677505 - /apr/apr-util/trunk/misc/apr_reslist.c
Date Sun, 20 Jul 2008 03:04:11 GMT
Quoting "Bojan Smojver" <bojan@rexursive.com>:

> PPS. The situation I was referring to in my previous e-mails cannot
> actually happen. R always outlives S.

This e-mail was written before pre_cleanup bug in apr_pools.c was  
fixed, hence my PPS. However, let me reiterate one point: if people  
hang cleanups that depend on the resource off the sub-pool created in  
the constructor, but don't destroy the sub-pool in the destructor,  
they can be in trouble.

In other words:

constructor:
   create sub-pool
   create resource (non-pool space)
   register cleanup in sub-pool, dependent on resource

destructor:
   destroy resource

The above will lead in the subsequent sub-pool destruction (through  
the regular pool machinery) to segfaults (because that cleanup will  
refer to already destroyed resource).

So, the writers should be aware that that they _must_ call  
apr_pool_destroy() in the destructor on any sub-pool they created in  
the constructor.

-- 
Bojan

Mime
View raw message