GNU bug report logs -
#7227
re-search-forward goes infinite loop with dash inside []
Previous Next
Reported by: Jari Aalto <jari.aalto <at> cante.net>
Date: Sat, 16 Oct 2010 09:13:02 UTC
Severity: normal
Found in version 23.2+1-4
Done: Jari Aalto <jari.aalto <at> cante.net>
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 7227 in the body.
You can then email your comments to 7227 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org
:
bug#7227
; Package
emacs
.
(Sat, 16 Oct 2010 09:13:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Jari Aalto <jari.aalto <at> cante.net>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Sat, 16 Oct 2010 09:13:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
Package: emacs
Version: 23.2+1-4
Severity: normal
Executing the following code causes Emacs to go into infinite loop.
Simply run it behind the last paren with C-x C-e
(re-search-forward "^\\([a-z0-9.-]+\\)+[ \t]+\\([0-9]+\\) +\\([a-z].*\\)")
==========
If the dash is taken awy from the "[a-z0-9.-]", this code does not cause
infinite loop:
(re-search-forward "^\\([a-z0-9.]+\\)+[ \t]+\\([0-9]+\\) +\\([a-z].*\\)")
TEST ROWS FOR THE REGEXPS:
row-one 1234 rest of line
row2 1234 rest of line
TEST SETUP
emacs -Q --no-site-file
<copy the re-search-forward lisp statements into buffer>
<copy the test rows into buffer>
<Execute lisp statements>
-- System Information
Debian Release: squeeze/sid
APT Prefers testing
APT policy: (990, testing) (500, unstable) (1, experimental)
Architecture: amd64
Kernel: Linux picasso 2.6.32-5-amd64 #1 SMP Fri Sep 17 21:50:19 UTC 2010 x86_64 GNU/Linux
Locale: LANG=en_DK.UTF-8
-- Versions of packages `emacs depends on'.
Depends:
emacs23 23.2+1-4 GNU Emacs is the extensible self-documenting
emacs23-lucid 23.2+1-4 GNU Emacs is the extensible self-documenting
emacs23-nox 23.2+1-4 GNU Emacs is the extensible self-documenting
Information forwarded
to
owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org
:
bug#7227
; Package
emacs
.
(Sat, 16 Oct 2010 11:25:01 GMT)
Full text and
rfc822 format available.
Message #8 received at 7227 <at> debbugs.gnu.org (full text, mbox):
Jari Aalto <jari.aalto <at> cante.net> writes:
> Executing the following code causes Emacs to go into infinite loop.
> Simply run it behind the last paren with C-x C-e
>
> (re-search-forward "^\\([a-z0-9.-]+\\)+[ \t]+\\([0-9]+\\) +\\([a-z].*\\)")
Works fine here.
Note that nested repetitions like \([...]+\)+ are bad in any case.
Andreas.
--
Andreas Schwab, schwab <at> linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
Information forwarded
to
owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org
:
bug#7227
; Package
emacs
.
(Sat, 16 Oct 2010 11:37:02 GMT)
Full text and
rfc822 format available.
Message #11 received at submit <at> debbugs.gnu.org (full text, mbox):
Am 16.10.2010 11:16, schrieb Jari Aalto:
> Package: emacs Version: 23.2+1-4 Severity: normal
>
> Executing the following code causes Emacs to go into infinite loop.
> Simply run it behind the last paren with C-x C-e
>
> (re-search-forward "^\\([a-z0-9.-]+\\)+[ \t]+\\([0-9]+\\)
> +\\([a-z].*\\)") ==========
>
> If the dash is taken awy from the "[a-z0-9.-]", this code does not
> cause infinite loop:
>
> (re-search-forward "^\\([a-z0-9.]+\\)+[ \t]+\\([0-9]+\\)
> +\\([a-z].*\\)")
>
> TEST ROWS FOR THE REGEXPS:
>
> row-one 1234 rest of line
>
> row2 1234 rest of line
>
> TEST SETUP
>
> emacs -Q --no-site-file <copy the re-search-forward lisp statements
> into buffer> <copy the test rows into buffer> <Execute lisp
> statements>
>
> -- System Information Debian Release: squeeze/sid APT Prefers
> testing APT policy: (990, testing) (500, unstable) (1, experimental)
> Architecture: amd64 Kernel: Linux picasso 2.6.32-5-amd64 #1 SMP Fri
> Sep 17 21:50:19 UTC 2010 x86_64 GNU/Linux Locale: LANG=en_DK.UTF-8
>
> -- Versions of packages `emacs depends on'. Depends: emacs23
> 23.2+1-4 GNU Emacs is the extensible self-documenting
> emacs23-lucid 23.2+1-4 GNU Emacs is the extensible
> self-documenting emacs23-nox 23.2+1-4 GNU Emacs is the
> extensible self-documenting
>
>
>
>
Hi,
can't reproduce this with
GNU Emacs 23.1.1 (i586-suse-linux-gnu, GTK+ Version 2.20.1) of 2010-07-05
in scratch buffer I get an error immediatly:
Debugger entered--Lisp error: (search-failed "^\\([a-z0-9.-]+\\)+[
]+\\([0-9]+\\) +\\([a-z].*\\)")
re-search-forward("^\\([a-z0-9.-]+\\)+[ ]+\\([0-9]+\\) +\\([a-z].*\\)")
eval((re-search-forward "^\\([a-z0-9.-]+\\)+[ ]+\\([0-9]+\\)
+\\([a-z].*\\)"))
eval-last-sexp-1(nil)
eval-last-sexp(nil)
call-interactively(eval-last-sexp nil nil)
Thanks for tiny-tools BTW.
Andreas
--
https://code.launchpad.net/~a-roehler/python-mode/python-mode-components
https://code.launchpad.net/s-x-emacs-werkstatt/
Information forwarded
to
owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org
:
bug#7227
; Package
emacs
.
(Sat, 16 Oct 2010 13:39:02 GMT)
Full text and
rfc822 format available.
Message #14 received at 7227 <at> debbugs.gnu.org (full text, mbox):
Andreas Schwab <schwab <at> linux-m68k.org> writes:
> Jari Aalto <jari.aalto <at> cante.net> writes:
>
>> Executing the following code causes Emacs to go into infinite loop.
>> Simply run it behind the last paren with C-x C-e
>>
>> (re-search-forward "^\\([a-z0-9.-]+\\)+[ \t]+\\([0-9]+\\) +\\([a-z].*\\)")
>
> Works fine here.
Hm. The test case needs adjustment:
;; (1) Run C-x C-e, works:
(re-search-forward "^\\([a-z0-9.-]+\\)+[ \t]+\\([0-9]+\\) +\\([a-z].*\\)")
row2 1234 rest of line
;; (2) but C-x C-e below causes a loop
(re-search-forward "^\\([a-z0-9.-]+\\)+[ \t]+\\([0-9]+\\) +\\([a-z].*\\)")
------------------------------------------------------------------------
row2 1234 rest of line
> Note that nested repetitions like \([...]+\)+ are bad in any case.
This was only a test. The anchor "^" should help, and I assume the first
'[a-z0-9.-]+' should be greedy, so it shouldn't take that long to
resolve.
Jari
Information forwarded
to
owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org
:
bug#7227
; Package
emacs
.
(Sat, 16 Oct 2010 13:51:01 GMT)
Full text and
rfc822 format available.
Message #17 received at 7227 <at> debbugs.gnu.org (full text, mbox):
Jari Aalto <jari.aalto <at> cante.net> writes:
> Hm. The test case needs adjustment:
>
> ;; (1) Run C-x C-e, works:
>
> (re-search-forward "^\\([a-z0-9.-]+\\)+[ \t]+\\([0-9]+\\) +\\([a-z].*\\)")
> row2 1234 rest of line
>
> ;; (2) but C-x C-e below causes a loop
>
> (re-search-forward "^\\([a-z0-9.-]+\\)+[ \t]+\\([0-9]+\\) +\\([a-z].*\\)")
> ------------------------------------------------------------------------
> row2 1234 rest of line
>
>> Note that nested repetitions like \([...]+\)+ are bad in any case.
>
> This was only a test. The anchor "^" should help, and I assume the first
> '[a-z0-9.-]+' should be greedy, so it shouldn't take that long to
> resolve.
Not in the non-matching case. When the match against the dash line is
tried you get quadratic behaviour due to explosion of the search tree.
Andreas.
--
Andreas Schwab, schwab <at> linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
Reply sent
to
Jari Aalto <jari.aalto <at> cante.net>
:
You have taken responsibility.
(Fri, 22 Oct 2010 07:52:02 GMT)
Full text and
rfc822 format available.
Notification sent
to
Jari Aalto <jari.aalto <at> cante.net>
:
bug acknowledged by developer.
(Fri, 22 Oct 2010 07:52:02 GMT)
Full text and
rfc822 format available.
Message #22 received at 7227-done <at> debbugs.gnu.org (full text, mbox):
Reason for close:
Not a bug. In non-matching case, the regexp engine pumps up; thus "Loop
effect" feel.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Fri, 19 Nov 2010 12:24:03 GMT)
Full text and
rfc822 format available.
This bug report was last modified 14 years and 275 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.