Subject: 24.0.50; No response from 'occur' (infinite loop when regexp matches empty string?)
From: Larry Denenberg <[email-masked]>
To: [email-masked]
Cc: [email-masked]
Date: Wed, 08 Dec 2010 13:53:36 -0500
List-Id: <debbugs-submit.debbugs.gnu.org>

This bug manifests in all versions of GNU emacs that I have.  The facts:

1) Start with 'emacs -nw -Q'.  We see buffer *scratch* containing the
initial greeting ';; This buffer is for notes . . .'.

2) Enter 'M-x occur<RET>'.  We're now in the minibuffer with prompt
'List lines matching regexp:'.

3) Enter 'a*<RET>'.  Emacs stops responding.

I believe the problem is in function occur-engine (file replace.el),
specifically the section labelled 'Highlight the matches'.

		    ;; Highlight the matches
		    (let ((len (length curstring))
			  (start 0))
		      (while (and (< start len)
				  (string-match regexp curstring start))
			(add-text-properties
			 (match-beginning 0) (match-end 0)
			 (append
			  `(occur-match t)
			  (when match-face
			    ;; Use `face' rather than `font-lock-face' here
			    ;; so as to override faces copied from the buffer.
			    `(face ,match-face)))
			 curstring)
			(setq start (match-end 0))))

When the given regexp matches a null string, the final line of code here
does not change variable start, so we loop infinitely.

/Larry Denenberg
[email-masked]
http://larry.denenberg.com/

In GNU Emacs 24.0.50.1 (i386-apple-darwin9.8.0, NS apple-appkit-949.54)
 of 2010-08-10 on braeburn.aquamacs.org - Aquamacs Distribution 2.1dev
Windowing system distributor `Apple', version 10.3.1038
configured using `configure  '--with-ns' '--without-x' 'CFLAGS=-arch i386 -arch ppc' 'LDFLAGS=-arch i386 -arch ppc''

Important settings:
  value of $LC_ALL: nil
  value of $LC_COLLATE: nil
  value of $LC_CTYPE: nil
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: nil
  value of $LANG: nil
  value of $XMODIFIERS: nil
  locale-coding-system: nil
  default enable-multibyte-characters: t

Major mode: Info

Minor modes in effect:
  TeX-PDF-mode: t
  TeX-source-correlate-mode: t
  display-time-mode: t
  savehist-mode: t
  smart-frame-positioning-mode: t
  aquamacs-autoface-mode: t
  recentf-mode: t
  osx-key-mode: t
  show-paren-mode: t
  delete-selection-mode: t
  pc-selection-mode: t
  cua-mode: t
  tooltip-mode: t
  mouse-wheel-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  column-number-mode: t
  line-number-mode: t
  transient-mark-mode: t

Load-path shadows:
/Users/larry/Emacs/mh-e-8.1/emacs/lisp/mh-e/mh-xface hides /Applications/Aquamacs.app/Contents/Resources/lisp/mh-e/mh-xface
/Users/larry/Emacs/mh-e-8.1/emacs/lisp/mh-e/mh-utils hides /Applications/Aquamacs.app/Contents/Resources/lisp/mh-e/mh-utils
/Users/larry/Emacs/mh-e-8.1/emacs/lisp/mh-e/mh-tool-bar hides /Applications/Aquamacs.app/Contents/Resources/lisp/mh-e/mh-tool-bar
/Users/larry/Emacs/mh-e-8.1/emacs/lisp/mh-e/mh-thread hides /Applications/Aquamacs.app/Contents/Resources/lisp/mh-e/mh-thread
/Users/larry/Emacs/mh-e-8.1/emacs/lisp/mh-e/mh-speed hides /Applications/Aquamacs.app/Contents/Resources/lisp/mh-e/mh-speed
/Users/larry/Emacs/mh-e-8.1/emacs/lisp/mh-e/mh-show hides /Applications/Aquamacs.app/Contents/Resources/lisp/mh-e/mh-show
/Users/larry/Emacs/mh-e-8.1/emacs/lisp/mh-e/mh-seq hides /Applications/Aquamacs.app/Contents/Resources/lisp/mh-e/mh-seq
/Users/larry/Emacs/mh-e-8.1/emacs/lisp/mh-e/mh-search hides /Applications/Aquamacs.app/Contents/Resources/lisp/mh-e/mh-search
/Users/larry/Emacs/mh-e-8.1/emacs/lisp/mh-e/mh-scan hides /Applications/Aquamacs.app/Contents/Resources/lisp/mh-e/mh-scan
/Users/larry/Emacs/mh-e-8.1/emacs/lisp/mh-e/mh-print hides /Applications/Aquamacs.app/Contents/Resources/lisp/mh-e/mh-print
/Users/larry/Emacs/mh-e-8.1/emacs/lisp/mh-e/mh-mime hides /Applications/Aquamacs.app/Contents/Resources/lisp/mh-e/mh-mime
/Users/larry/Emacs/mh-e-8.1/emacs/lisp/mh-e/mh-loaddefs hides /Applications/Aquamacs.app/Contents/Resources/lisp/mh-e/mh-loaddefs
/Users/larry/Emacs/mh-e-8.1/emacs/lisp/mh-e/mh-limit hides /Applications/Aquamacs.app/Contents/Resources/lisp/mh-e/mh-limit
/Users/larry/Emacs/mh-e-8.1/emacs/lisp/mh-e/mh-letter hides /Applications/Aquamacs.app/Contents/Resources/lisp/mh-e/mh-letter
/Users/larry/Emacs/mh-e-8.1/emacs/lisp/mh-e/mh-junk hides /Applications/Aquamacs.app/Contents/Resources/lisp/mh-e/mh-junk
/Users/larry/Emacs/mh-e-8.1/emacs/lisp/mh-e/mh-inc hides /Applications/Aquamacs.app/Contents/Resources/lisp/mh-e/mh-inc
/Users/larry/Emacs/mh-e-8.1/emacs/lisp/mh-e/mh-identity hides /Applications/Aquamacs.app/Contents/Resources/lisp/mh-e/mh-identity
/Users/larry/Emacs/mh-e-8.1/emacs/lisp/mh-e/mh-gnus hides /Applications/Aquamacs.app/Contents/Resources/lisp/mh-e/mh-gnus
/Users/larry/Emacs/mh-e-8.1/emacs/lisp/mh-e/mh-funcs hides /Applications/Aquamacs.app/Contents/Resources/lisp/mh-e/mh-funcs
/Users/larry/Emacs/mh-e-8.1/emacs/lisp/mh-e/mh-folder hides /Applications/Aquamacs.app/Contents/Resources/lisp/mh-e/mh-folder
/Users/larry/Emacs/mh-e-8.1/emacs/lisp/mh-e/mh-e hides /Applications/Aquamacs.app/Contents/Resources/lisp/mh-e/mh-e
/Users/larry/Emacs/mh-e-8.1/emacs/lisp/mh-e/mh-compat hides /Applications/Aquamacs.app/Contents/Resources/lisp/mh-e/mh-compat
/Users/larry/Emacs/mh-e-8.1/emacs/lisp/mh-e/mh-comp hides /Applications/Aquamacs.app/Contents/Resources/lisp/mh-e/mh-comp
/Users/larry/Emacs/mh-e-8.1/emacs/lisp/mh-e/mh-buffers hides /Applications/Aquamacs.app/Contents/Resources/lisp/mh-e/mh-buffers
/Users/larry/Emacs/mh-e-8.1/emacs/lisp/mh-e/mh-alias hides /Applications/Aquamacs.app/Contents/Resources/lisp/mh-e/mh-alias
/Users/larry/Emacs/mh-e-8.1/emacs/lisp/mh-e/mh-acros hides /Applications/Aquamacs.app/Contents/Resources/lisp/mh-e/mh-acros
/Users/larry/Emacs/Bin/hebrew hides /Applications/Aquamacs.app/Contents/Resources/lisp/language/hebrew

Features:
(shadow emacsbug thai-util thai-word lao-util flyspell ispell cua-rect
rect utf-7 compile comint ring find-func sort mule-util info mh-limit
browse-url flow-fill cperl-mode dabbrev mh-thread multi-isearch mh-funcs
mh-search mh-alias multi-prompt crm qp mail-extr mh-identity mh-letter
mh-comp smiley mh-mime mh-gnus mh-show goto-addr gnus-cite gnus-art
mm-uu mml2015 pgg pgg-parse pgg-def epg-config mm-view smime
password-cache dig gnus-sum nnoo gnus-group gnus-undo nnmail mail-source
format-spec gnus-start gnus-spec gnus-int message rfc822 mml mml-sec
mm-decode mm-bodies mm-encode gmm-utils mailheader gnus-win gnus-range
gnus gnus-ems nnheader mh-inc hl-line mh-tool-bar mh-seq mh-xface
mh-utils mh-folder which-func imenu mh-scan mh-e mh-compat mailabbrev
mh-acros mh-buffers mh-loaddefs time-stamp newcomment texmathp preview
prv-emacs reftex-vcr reftex-dcr reftex-auc reftex reftex-vars bib-cite
tex-fold tex-bar tex-buf toolbar-x noutline outline font-latex latex
tex-style tex latexenc ebuff-menu electric url-http tls url-auth
mail-parse rfc2231 rfc2047 rfc2045 ietf-drums url-gw url-cache url
url-proxy url-privacy url-expand url-methods url-history url-cookie
url-util url-parse auth-source gnus-util url-vars mm-util mail-prsvr
mailcap mail-utils time-date package quail help-mode jka-compr time
edmacro kmacro load-emacs-plugins aquamacs-mode-defaults auctex-config
server preview-latex tex-site auto-loads smart-dnd aquamacs-aux savehist
mouse-sel one-buffer-one-frame smart-frame-positioning drews_init
color-theme-autoloads view saveplace visual-line aquamacs-bug
aquamacs-autoface-mode aquamacs-editing sendmail recentf tree-widget
cus-edit osxkeys emulate-mac-keyboard-mode frame-cmds strings misc-fns
thingatpt+ thingatpt frame-fns avoid aquamacs-mac-fontsets fit-frame
aquamacs-frame-setup aquamacs-tabbar tabbar-window cl cl-19 tabbar
warnings cus-start cus-load load-emacs-pre-plugins aquamacs-site-start
filladapt aquamacs-redo check-for-updates aquamacs-menu osx_defaults
aquamacs-tool-bar aquamacs mac-extra-functions aquamacs-tools
aquamacs-macros parse-time timezone paren delsel pc-select cua-base
wid-edit regexp-opt advice advice-preload byte-opt bytecomp byte-compile
debug help-fns image-file disp-table easy-mmode tooltip ediff-hook
vc-hooks lisp-float-type mwheel ns-win easymenu tool-bar dnd fontset
image fringe lisp-mode register page menu-bar rfn-eshadow timer select
scroll-bar mldrag mouse jit-lock font-lock syntax facemenu font-core
frame cham georgian utf-8-lang misc-lang vietnamese tibetan thai
tai-viet lao korean japanese hebrew greek romanian slovak czech european
ethiopic indian cyrillic chinese case-table epa-hook jka-cmpr-hook help
simple abbrev loaddefs button minibuffer faces cus-face files
text-properties overlay md5 base64 format env code-pages mule custom
widget hashtable-print-readable backquote make-network-process ns
multi-tty emacs)