Return-Path: Delivered-To: apmail-apr-dev-archive@www.apache.org Received: (qmail 65518 invoked from network); 18 Jul 2008 04:02:54 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 18 Jul 2008 04:02:54 -0000 Received: (qmail 99435 invoked by uid 500); 18 Jul 2008 04:02:53 -0000 Delivered-To: apmail-apr-dev-archive@apr.apache.org Received: (qmail 99382 invoked by uid 500); 18 Jul 2008 04:02:53 -0000 Mailing-List: contact dev-help@apr.apache.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Id: Delivered-To: mailing list dev@apr.apache.org Received: (qmail 99371 invoked by uid 99); 18 Jul 2008 04:02:52 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 17 Jul 2008 21:02:52 -0700 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of bojan@rexursive.com designates 203.171.74.242 as permitted sender) Received: from [203.171.74.242] (HELO beauty.rexursive.com) (203.171.74.242) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 18 Jul 2008 04:01:59 +0000 Received: from [10.1.120.24] (shrek.rexursive.com [10.1.120.24]) by beauty.rexursive.com (Postfix) with ESMTP id DDF994C009A; Fri, 18 Jul 2008 14:01:52 +1000 (EST) Subject: Re: svn commit: r677505 - /apr/apr-util/trunk/misc/apr_reslist.c From: Bojan Smojver To: Mladen Turk Cc: dev@apr.apache.org In-Reply-To: <1216344035.2754.11.camel@shrek.rexursive.com> References: <20080717054557.AA2E02388A45@eris.apache.org> <20080717195057.213327svh8rbt1xc@www.rexursive.com> <487F1E0A.2040102@apache.org> <20080717212420.3879209jc5q4grmo@www.rexursive.com> <487F340D.8020600@apache.org> <1216344035.2754.11.camel@shrek.rexursive.com> Content-Type: multipart/mixed; boundary="=-4tMaSfyvP5Nq3DRvv3Bh" Date: Fri, 18 Jul 2008 14:01:52 +1000 Message-Id: <1216353712.2754.17.camel@shrek.rexursive.com> Mime-Version: 1.0 X-Mailer: Evolution 2.22.3.1 (2.22.3.1-1.fc9) X-Virus-Checked: Checked by ClamAV on apache.org --=-4tMaSfyvP5Nq3DRvv3Bh Content-Type: text/plain Content-Transfer-Encoding: 7bit On Fri, 2008-07-18 at 11:20 +1000, Bojan Smojver wrote: > The attached program crashes (double free) with or without that > change. He, he... It's always good to go through code again. There was a bug in the test program that caused it to crash. The attached program runs fine with pre cleanup and regular cleanup. Apologies for barking up the wrong tree and wasting everyone's time :-( -- Bojan --=-4tMaSfyvP5Nq3DRvv3Bh Content-Disposition: attachment; filename=test.c Content-Type: text/x-csrc; name=test.c; charset=utf-8 Content-Transfer-Encoding: 7bit #include #include #include #include #include #include #include struct res{ apr_pool_t *p; char *r; }; struct sub{ struct res *r; /* parent resource */ char *s; }; static apr_status_t res_clean(void *data){ struct res *r=data; free(r->r); r->r=NULL; return APR_SUCCESS; } static apr_status_t sub_clean(void *data){ struct sub *s=data; /* use parent resource a bit */ printf("%s\n",s->r->r); free(s->s); s->s=NULL; return APR_SUCCESS; } static apr_status_t con(void **res,void *parm,apr_pool_t *pool){ apr_pool_t *rpool,*spool; struct res **r=(struct res **)res; struct sub *s; apr_pool_create(&rpool,pool); *r=apr_pcalloc(rpool,sizeof(**r)); (*r)->p=rpool; (*r)->r=malloc(5); memcpy((*r)->r,"data",5); apr_pool_cleanup_register(rpool,*r,res_clean,apr_pool_cleanup_null); apr_pool_create(&spool,rpool); s=apr_pcalloc(spool,sizeof(*s)); s->r=*r; s->s=malloc(5); memcpy(s->s,"data",5); apr_pool_cleanup_register(spool,s,sub_clean,apr_pool_cleanup_null); return APR_SUCCESS; } static apr_status_t de(void *res,void *parm,apr_pool_t *pool){ struct res *r=res; apr_pool_destroy(r->p); return APR_SUCCESS; } int main(int argc,char **argv){ int i,j; struct res *r[10]; apr_pool_t *pool; apr_reslist_t *list; apr_initialize(); apr_pool_create(&pool,NULL); apr_reslist_create(&list,0,0,10,0,con,de,NULL,pool); for(j=0;j<1000;j++){ for(i=0;i<10;i++) apr_reslist_acquire(list,(void **)&r[i]); for(i=0;i<10;i++) apr_reslist_release(list,r[i]); } apr_terminate(); return 0; } --=-4tMaSfyvP5Nq3DRvv3Bh--