public inbox for glibc-bugs-regex@sourceware.org
help / color / mirror / Atom feed
From: "paolo dot bonzini at lu dot unisi dot ch" <sourceware-bugzilla@sources.redhat.com>
To: glibc-bugs-regex@sources.redhat.com
Subject: [Bug regex/429] regex hangs on backreferences
Date: Tue, 09 Nov 2004 15:51:00 -0000	[thread overview]
Message-ID: <20041109155144.7183.qmail@sourceware.org> (raw)
In-Reply-To: <20041007110031.429.jakub@redhat.com>


------- 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.


  parent reply	other threads:[~2004-11-09 15:51 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-10-07 11:00 [Bug regex/429] New: " jakub at redhat dot com
2004-10-07 14:17 ` [Bug regex/429] " gotom at debian dot or dot jp
2004-11-04  8:43 ` bonzini at gnu dot org
2004-11-04  9:04 ` bonzini at gnu dot org
2004-11-09  7:55 ` bonzini at gnu dot org
2004-11-09 15:24 ` jakub at redhat dot com
2004-11-09 15:51   ` Paolo Bonzini
2004-11-09 15:51 ` paolo dot bonzini at lu dot unisi dot ch [this message]
2004-11-10 10:53 ` bonzini at gnu dot org
2004-11-12 12:22 ` bonzini at gnu dot org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20041109155144.7183.qmail@sourceware.org \
    --to=sourceware-bugzilla@sources.redhat.com \
    --cc=glibc-bugs-regex@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).