Return-Path: Delivered-To: apmail-httpd-modules-dev-archive@locus.apache.org Received: (qmail 27349 invoked from network); 2 Jan 2007 20:05:52 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 2 Jan 2007 20:05:52 -0000 Received: (qmail 65867 invoked by uid 500); 2 Jan 2007 20:05:57 -0000 Delivered-To: apmail-httpd-modules-dev-archive@httpd.apache.org Received: (qmail 65785 invoked by uid 500); 2 Jan 2007 20:05:57 -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 65740 invoked by uid 99); 2 Jan 2007 20:05:57 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 02 Jan 2007 12:05:56 -0800 X-ASF-Spam-Status: No, hits=1.2 required=10.0 tests=RCVD_IN_SORBS_WEB X-Spam-Check-By: apache.org Received-SPF: pass (herse.apache.org: local policy) Received: from [83.151.18.208] (HELO dedi17.smart-servers.de) (83.151.18.208) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 02 Jan 2007 12:05:46 -0800 Received: from xdsl-213-196-247-200.netcologne.de ([213.196.247.200] helo=dilbert.crrrwg.de ident=foobar) by dedi17.smart-servers.de with esmtpsa (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.63) (envelope-from ) id 1H1psd-0003W9-H2 for modules-dev@httpd.apache.org; Tue, 02 Jan 2007 21:05:03 +0100 Received: from asus.crrrwg.de ([192.168.201.92] ident=c18cc80a948ce4fecc66532df34afa21) by dilbert.crrrwg.de with esmtp (Exim 4.50) id 1H1psp-0001cg-PK for modules-dev@httpd.apache.org; Tue, 02 Jan 2007 21:05:15 +0100 Subject: Re: splitting a string... From: Joachim Zobel Reply-To: jzobel@heute-morgen.de To: modules-dev@httpd.apache.org In-Reply-To: <459A228B.1020107@jupiterhosting.com> References: <45972688.7090502@jupiterhosting.com> <1167566411.6170.22.camel@test.asus> <45981B09.8080704@jupiterhosting.com> <1167604803.6170.26.camel@test.asus> <45986BB7.2000903@joe-lewis.com> <4598D8E3.9060102@jupiterhosting.com> <1167645825.5604.13.camel@test.asus> <45991844.5070008@jupiterhosting.com> <1167665888.5604.23.camel@test.asus> <459A228B.1020107@jupiterhosting.com> Content-Type: text/plain Organization: Not organized Date: Tue, 02 Jan 2007 21:05:15 +0100 Message-Id: <1167768315.4483.11.camel@test.asus> Mime-Version: 1.0 X-Mailer: Evolution 2.6.3 Content-Transfer-Encoding: 7bit X-SA-Do-Not-Run: Yes X-SA-Exim-Connect-IP: 213.196.247.200 X-SA-Exim-Rcpt-To: modules-dev@httpd.apache.org X-SA-Exim-Mail-From: jzobel@heute-morgen.de X-SA-Exim-Scanned: No (on dedi17.smart-servers.de); SAEximRunCond expanded to false X-Virus-Checked: Checked by ClamAV on apache.org Am Dienstag, den 02.01.2007, 01:14 -0800 schrieb Drew Bertola: > line 91 looks like this: > > apr_bucket_read(e, &str, &len, APR_NONBLOCK_READ); > > Also, it only happens if I use > > APR_BRIGADE_INSERT_TAIL(ctx->bb, e); Ah, understood. You don't mention this, but you probably have a for ( e = APR_BRIGADE_FIRST(bb) ; e != APR_BRIGADE_SENTINEL(bb) ; e = APR_BUCKET_NEXT(e) ) { for your loop. Right? So if you _move_ e to another brigade, the e != APR_BRIGADE_SENTINEL(bb) will never be fullfilled and APR_BUCKET_NEXT(e) will step through the wrong brigade and will treat the sentinel as a bucket. This causes the observed segfault. You could instead copy the bucket using /** * Copy a bucket. * @param e The bucket to copy * @param c Returns a pointer to the new bucket */ #define apr_bucket_copy(e,c) (e)->type->copy(e, c) And then delete the bucket at the end of the loop using /** * Delete a bucket by removing it from its brigade (if any) and then * destroying it. * @remark This mainly acts as an aid in avoiding code verbosity. It is * the preferred exact equivalent to: *
 *      APR_BUCKET_REMOVE(e);
 *      apr_bucket_destroy(e);
 * 
* @param e The bucket to delete */ #define apr_bucket_delete(e) do { \ APR_BUCKET_REMOVE(e); \ apr_bucket_destroy(e); \ } while (0) Since buckets do reference counting this is not copying of the data, so its relatively cheap. There are other solutions, which work equally well. Sincerely, Joachim