From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7268 invoked by alias); 9 Nov 2004 15:51:54 -0000 Mailing-List: contact glibc-bugs-regex-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Post: List-Help: , Sender: glibc-bugs-regex-owner@sources.redhat.com Received: (qmail 7184 invoked by alias); 9 Nov 2004 15:51:44 -0000 Date: Tue, 09 Nov 2004 15:51:00 -0000 Message-ID: <20041109155144.7183.qmail@sourceware.org> From: "paolo dot bonzini at lu dot unisi dot ch" To: glibc-bugs-regex@sources.redhat.com In-Reply-To: <20041007110031.429.jakub@redhat.com> References: <20041007110031.429.jakub@redhat.com> Reply-To: sourceware-bugzilla@sources.redhat.com Subject: [Bug regex/429] regex hangs on backreferences X-Bugzilla-Reason: CC X-SW-Source: 2004-11/txt/msg00031.txt.bz2 List-Id: ------- Additional Comments From paolo dot bonzini at lu dot unisi dot ch 2004-11-09 15:51 ------- Subject: Re: regex hangs on backreferences > But even with your patch bug-regex11.c with s/#if 0/#if 1/ eats certainly > more than 10 minutes of CPU time (until I killed it). Yes. I managed to run a 7-backreference version, which took a few minutes before my patch. True, it does not make the full testcase feasible yet, but I'll work on it. > Either there is a better algorithm for many backreferences, or we should > consider using NFA for patterns where DFA with backtracing is known to take > too long. I think you can do some kind of caching to cut the number of invocations of calc_dst_limits_pos. Its implementation is naive. Complexity is exponential in N because every epsilon closure visits N backreferences without any remote hope of succeeding, because no OP_{OPEN,CLOSE}_SUBEXP is on the epsilon closure. I have to figure out exactly how the backref cache enters the game, because adding something ad hoc in regcomp.c does not seem the right way to fix it. And also, I want to understand which cases are common both in practice (to avoid slowing down the common case) and in the worst case: I'd like factor.sed and dc.sed to be sped up by 10% while fixing this bug. I certainly hope to bring it down to O(N) in the number of backreferences, albeit with a pretty big constant in front of it. Paolo -- http://sources.redhat.com/bugzilla/show_bug.cgi?id=429 ------- You are receiving this mail because: ------- You are on the CC list for the bug, or are watching someone who is.