Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kxvQZ-0003N4-R4 for pgsql-bugs@arkaria.postgresql.org; Fri, 08 Jan 2021 17:19:55 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kxvQY-00054V-PG for pgsql-bugs@arkaria.postgresql.org; Fri, 08 Jan 2021 17:19:54 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kxvQY-00054O-Iq for pgsql-bugs@lists.postgresql.org; Fri, 08 Jan 2021 17:19:54 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kxvQS-0008Pi-DA for pgsql-bugs@lists.postgresql.org; Fri, 08 Jan 2021 17:19:53 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 108HJk32323717; Fri, 8 Jan 2021 12:19:46 -0500 From: Tom Lane To: exclusion@gmail.com cc: pgsql-bugs@lists.postgresql.org Subject: Re: BUG #16814: Invalid memory access on regexp_match with .* and BRE In-reply-to: <16814-6c5e3edd2bdf0d50@postgresql.org> References: <16814-6c5e3edd2bdf0d50@postgresql.org> Comments: In-reply-to PG Bug reporting form message dated "Thu, 07 Jan 2021 19:00:01 +0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <323715.1610126386.1@sss.pgh.pa.us> Date: Fri, 08 Jan 2021 12:19:46 -0500 Message-ID: <323716.1610126386@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk PG Bug reporting form writes: > When executing the following regexp call: > select regexp_match('abc', '.*', 'b'); > valgrind detects an error: Hah, nice one. It gives the wrong answer too, at least it does most of the time for me: # select regexp_match('abc', '.*', 'b'); regexp_match -------------- {""} (1 row) That's because it's acting like the pattern is '.*?' (prefer shortest match) rather than '.*'. This bug is well over the age of consent, btw. Tcl's got it too, so it surely is aboriginal in Henry Spencer's code. Thanks for the report! regards, tom lane