You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@apr.apache.org by Brad Nicholes <BN...@novell.com> on 2001/07/30 22:34:42 UTC
Why is free() being called on a mutex lock???
In the function apr_sms_destroy() in the file apr_sms.c the function appears to be using free() to destroy a lock which has already been destroyed. On about #597 the follow code appears:
/* Remove the memory system from the parent memory systems child list */
if (pms) {
if (pms->sms_lock)
apr_lock_acquire(pms->sms_lock);
if ((*sms->ref = sms->sibling) != NULL)
sms->sibling->ref = sms->ref;
if (pms->sms_lock)
apr_lock_release(pms->sms_lock);
}
/* Call the pre-destroy if present */
if (sms->pre_destroy_fn)
sms->pre_destroy_fn(sms);
if (sms->sms_lock)
{
apr_lock_destroy(sms->sms_lock);
if (pms->free_fn)
apr_sms_free(sms->parent, sms->sms_lock);
}
In the last outer if statement a call is made to destroy the sms->sms_lock which should completely destroy and free the lock. In the next if statement a call to apr_sms_free () then tries to free it again. When traced through it ultimately calls free() on sms->sms_lock which should have already been destroyed by the call to apr_lock_destroy(). Am I missing something or is the code trying to free a lock that has already been destroyed?
Brad
Re: Why is free() being called on a mutex lock???
Posted by Justin Erenkrantz <je...@ebuilt.com>.
On Mon, Jul 30, 2001 at 02:34:42PM -0600, Brad Nicholes wrote:
> In the last outer if statement a call is made to destroy the sms->sms_lock which should completely destroy and free the lock. In the next if statement a call to apr_sms_free () then tries to free it again. When traced through it ultimately calls free() on sms->sms_lock which should have already been destroyed by the call to apr_lock_destroy(). Am I missing something or is the code trying to free a lock that has already been destroyed?
Yeah, that apr_sms_free is deleted in my local tree for the precise
reasons you mentioned. That extra call was a thinko on my part. I
haven't resynced my SMS code because I'm not sure how well SMS can
scale, so I've put SMS on the back burner for a bit.
I'll take a pass at merging my tree with CVS tonight. No promises
though. -- justin
P.S. Your mailer sends long lines.