Return-Path: Delivered-To: apmail-httpd-modules-dev-archive@locus.apache.org Received: (qmail 93928 invoked from network); 31 Jan 2007 10:01:43 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 31 Jan 2007 10:01:43 -0000 Received: (qmail 89866 invoked by uid 500); 31 Jan 2007 10:01:49 -0000 Delivered-To: apmail-httpd-modules-dev-archive@httpd.apache.org Received: (qmail 89844 invoked by uid 500); 31 Jan 2007 10:01:48 -0000 Mailing-List: contact modules-dev-help@httpd.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: modules-dev@httpd.apache.org Delivered-To: mailing list modules-dev@httpd.apache.org Received: (qmail 89835 invoked by uid 99); 31 Jan 2007 10:01:48 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 31 Jan 2007 02:01:48 -0800 X-ASF-Spam-Status: No, hits=2.0 required=10.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (herse.apache.org: domain of gushaow@gmail.com designates 64.233.182.184 as permitted sender) Received: from [64.233.182.184] (HELO nf-out-0910.google.com) (64.233.182.184) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 31 Jan 2007 02:01:40 -0800 Received: by nf-out-0910.google.com with SMTP id n28so449540nfc for ; Wed, 31 Jan 2007 02:01:19 -0800 (PST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:mime-version:content-type; b=GuPGlgHrf+OjkRL0/fI56fXy9koh1kEpiuCLa2UJhYucKOc6KVBRs4WfisplRpBu08V7FfnvNM5bVdOrLa/+PjzwQcscn0O2DUU9usacJJhfFbiY1GVqT9iAxLiSgbqfXMGPQu5m3HsTXCvzllLdlzT47Wbd/Cz4dT3/7Ssqe1I= Received: by 10.49.20.15 with SMTP id x15mr2142269nfi.1170237678785; Wed, 31 Jan 2007 02:01:18 -0800 (PST) Received: by 10.48.245.3 with HTTP; Wed, 31 Jan 2007 02:01:18 -0800 (PST) Message-ID: <50df4dd70701310201o285c1e0eia9e15061a26356a8@mail.gmail.com> Date: Wed, 31 Jan 2007 18:01:18 +0800 From: Weilt To: modules-dev@httpd.apache.org Subject: a strange problem of gcc -O2 optimization flag in a output filter MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_485_9092673.1170237678746" X-Virus-Checked: Checked by ClamAV on apache.org ------=_Part_485_9092673.1170237678746 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline Hi, I have wrote a module, which has an output filter. The filter collects all the buckets of a request and does some processing, then it produces a new brigade containing the new output data and pass it to the next filter in the filter chains. The output filter code is like this: static apr_status_t TestOutFilter(ap_filter_t *f, apr_bucket_brigade *pbbIn) { request_rec *r = f->r; conn_rec *c = r->connection; OutContext *pCtx; if(!(pCtx = f->ctx)){ f->ctx = pCtx=apr_palloc(r->pool,sizeof *pCtx); pCtx->pbbTmp = apr_brigade_create(r->pool,c->bucket_alloc); } apr_bucket_brigade *pbbOut = pCtx->pbbTmp; while(!APR_BRIGADE_EMPTY(pbbIn)){ apr_bucket *pbktIn,*tmpbucket; pbktIn=APR_BRIGADE_FIRST(pbbIn); APR_BUCKET_REMOVE(pbktIn); APR_BRIGADE_INSERT_TAIL(pbbOut, pbktIn); if(APR_BUCKET_IS_FLUSH(pbktIn)) continue; if(APR_BUCKET_IS_EOS(pbktIn)) { /* we have all the buckets in pbbTmp; do some processing and create a new bucket outputbuffer contains the new data to pass to next filter */ tmpbucket=apr_bucket_heap_create(outputbuffer, lenofbuffer,0,c->bucket_alloc); APR_BRIGADE_INSERT_TAIL(pbbOut, tmpbucket); } APR_BRIGADE_INSERT_TAIL(pbbOut, pbktIn); ap_remove_output_filter(f); return ap_pass_brigade(f->next,pbbOut); } } return APR_SUCCESS; } The strange thing is when I use "/usr/local/apache2/bin/apxs -i -a -c -Wc,O0 -Wc,-ggdb testmodule.c" to compile the module, it works well, but if I "/usr/local/apache2/bin/apxs -i -a -c -Wc,O2 -Wc,-ggdb testmodule.c", it has death cycle in the function. Here '-Wc' means add gcc flag, '-Wc,O0' means 'gcc -O0' ,which is no optimization. '-Wc,O2' is the default value if it's not specified. I use gdb to debug this, and find that in "-Wc,O2" case, the function has death loop in the while loop. The pbbIn and pbbOut values are not changed after a loop, which means: "pbktIn=APR_BRIGADE_FIRST(pbbIn); APR_BUCKET_REMOVE(pbktIn); APR_BRIGADE_INSERT_TAIL(pbbOut, pbktIn);" aren't executed correctly or even optimized out. By the way, even "-Wc,O1" flat works correctly. I can't figure out the reason and how to solve it. Any one knows something about this? Thanks! ------=_Part_485_9092673.1170237678746--