Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WQFKy-0007ad-UL for pgsql-bugs@arkaria.postgresql.org; Wed, 19 Mar 2014 12:11:13 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1WQFKy-0004aU-9l for pgsql-bugs@arkaria.postgresql.org; Wed, 19 Mar 2014 12:11:12 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WQFKx-0004aO-HA for pgsql-bugs@postgresql.org; Wed, 19 Mar 2014 12:11:11 +0000 Received: from mail-ee0-x22d.google.com ([2a00:1450:4013:c00::22d]) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WQFKu-0001x6-37 for pgsql-bugs@postgresql.org; Wed, 19 Mar 2014 12:11:10 +0000 Received: by mail-ee0-f45.google.com with SMTP id d17so6469148eek.18 for ; Wed, 19 Mar 2014 05:11:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; bh=GCkSezmB7obkL1eIdcRRU/4oYSlx43H5epinZaK3rik=; b=ZvyKJsVfGjz4tij9Lx2jWXei0JOBB0DhOmUGyR54wmgbjqiIM7CRKdA5KSS0HHELcC nMQORE/bTBPbVDvcTyCHVC568KqaDJuh2KLkxIdjIYl3Ne0k4jg1V4KUyMWLcWt9k3dt yqhADiqMZcxgiA7q4FqjKrFwv8QvyvnrSkf7+K+jK6G1yZi9ixjOUk3WcbodkJO5Pkwb bgOx5uLqAu9HzMvGRiGYlrMK25cwDLzBd6LzHa5g6X2hVkSY/Gw/ei8DHSfMoovSex2e Em3RV8XOso7p1DqW+Pmof7wzoahhlY5BCnYO8xuZ2F961S92M8JQS7WEVvCbjZc75e9L p6gQ== X-Received: by 10.14.37.8 with SMTP id x8mr35678612eea.32.1395231066996; Wed, 19 Mar 2014 05:11:06 -0700 (PDT) Received: from localhost (ip-46-232-148-34.static.adsl.cheapnet.it. [46.232.148.34]) by mx.google.com with ESMTPSA id l42sm54278680eew.19.2014.03.19.05.11.04 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Wed, 19 Mar 2014 05:11:05 -0700 (PDT) Date: Wed, 19 Mar 2014 13:11:02 +0100 From: Sandro Santilli To: Greg Stark Cc: Tom Lane , Craig Ringer , Florian Pflug , PostgreSQL Bugs Subject: Re: Leaking regexp_replace in 9.3.1 ? (was: [HACKERSUninterruptable regexp_replace in 9.3.1 ?) Message-ID: <20140319121102.GJ4042@localhost> References: <53077EED.2000907@2ndquadrant.com> <3663.1393002213@sss.pgh.pa.us> <646.1393031856@sss.pgh.pa.us> <20140226150113.GD9740@localhost> <20140318170401.GE29859@localhost> <32100.1395186092@sss.pgh.pa.us> <20140319075359.GA4042@localhost> <20140319085702.GF4042@localhost> <20140319114325.GG4042@localhost> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20140319114325.GG4042@localhost> User-Agent: Mutt/1.5.21 (2010-09-15) X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org On Wed, Mar 19, 2014 at 12:43:25PM +0100, Sandro Santilli wrote: > On Wed, Mar 19, 2014 at 10:57:10AM +0000, Greg Stark wrote: > > On Wed, Mar 19, 2014 at 8:57 AM, Sandro Santilli wrote: > > > ==21240== by 0x64A200: newdfa.isra.4 (rege_dfa.c:307) > > > ==21240== by 0x64A4C3: getsubdfa (regexec.c:285) > > > ==21240== by 0x64B80A: cdissect (regexec.c:673) > > > ==21240== by 0x64C802: pg_regexec (regexec.c:473) > > > > > > It looks like a simple bug pg_regexec where it's reusing a loop > > counter "n" to mean two different things. When it goes to free all the > > subdfas it looks like the code was written based "n" still being the > > number of trees but in fact it's been reused to be the number of > > matches. > > I confirm this patch fixes the leak: I've encoded another version of it as a pull request: https://github.com/postgres/postgres/pull/5 --strk; -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs