GNU bug report logs - #16786
24.2; PostScript file with long lines locks up UI

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Reported by: Andreas Gustafsson <gson@HIDDEN>; dated Tue, 18 Feb 2014 00:30:04 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.
Disconnected #16786 from all other report(s). Request was from Glenn Morris <rgm@HIDDEN> to control <at> debbugs.gnu.org. Full text available.

Message received at 16786 <at> debbugs.gnu.org:


Received: (at 16786) by debbugs.gnu.org; 18 Feb 2014 02:16:03 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Feb 17 21:16:03 2014
Received: from localhost ([127.0.0.1]:57324 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.80)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1WFaE6-0002My-Qb
	for submit <at> debbugs.gnu.org; Mon, 17 Feb 2014 21:16:03 -0500
Received: from ironport2-out.teksavvy.com ([206.248.154.181]:42466)
 by debbugs.gnu.org with esmtp (Exim 4.80)
 (envelope-from <monnier@HIDDEN>) id 1WFaE5-0002MH-0d
 for 16786 <at> debbugs.gnu.org; Mon, 17 Feb 2014 21:16:01 -0500
X-IronPort-Anti-Spam-Filtered: true
X-IronPort-Anti-Spam-Result: Av8EABK/CFFLd/lO/2dsb2JhbABEuzWDWRdzgh8BBVYjEAsOJhIUGA0kiCTBLZEKA4hhnBmBXoMV
X-IPAS-Result: Av8EABK/CFFLd/lO/2dsb2JhbABEuzWDWRdzgh8BBVYjEAsOJhIUGA0kiCTBLZEKA4hhnBmBXoMV
X-IronPort-AV: E=Sophos;i="4.84,565,1355115600"; d="scan'208";a="47913032"
Received: from 75-119-249-78.dsl.teksavvy.com (HELO pastel.home)
 ([75.119.249.78])
 by ironport2-out.teksavvy.com with ESMTP/TLS/ADH-AES256-SHA;
 17 Feb 2014 21:15:55 -0500
Received: by pastel.home (Postfix, from userid 20848)
 id E415661186; Mon, 17 Feb 2014 21:15:54 -0500 (EST)
From: Stefan Monnier <monnier@HIDDEN>
To: Andreas Gustafsson <gson@HIDDEN>
Subject: Re: bug#16786: 24.2; PostScript file with long lines locks up UI
Message-ID: <jwvzjlpi377.fsf-monnier+emacsbugs@HIDDEN>
References: <21250.32840.43915.833076@HIDDEN>
Date: Mon, 17 Feb 2014 21:15:54 -0500
In-Reply-To: <21250.32840.43915.833076@HIDDEN> (Andreas Gustafsson's
 message of "Mon, 17 Feb 2014 23:34:00 +0200")
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: 0.3 (/)
X-Debbugs-Envelope-To: 16786
Cc: 16786 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: 0.3 (/)

>   (progn
>     (switch-to-buffer "test")
>     (insert (make-string 100000 97))
>     (ps-mode)
>   )

For this test, the main bottleneck seems to be the

   ("([^()\n%]*\\|[^()\n]*)" . font-lock-warning-face)

rule in ps-mode-font-lock-keywords-1.  The problem is the second half of
the regexp, which will take O(N) time to fail to match at a particular
position and which will try matching at every buffer position, for
a total of O(N^2).

This can be fixed by anchoring the search, e.g. with the patch below.
Of course, a small variation of the above test leads to
other bottlenecks.


        Stefan


=== modified file 'lisp/progmodes/ps-mode.el'
--- lisp/progmodes/ps-mode.el	2014-01-08 18:28:43 +0000
+++ lisp/progmodes/ps-mode.el	2014-02-18 02:10:59 +0000
@@ -220,7 +220,8 @@
     (ps-mode-match-string-or-comment
      (1 font-lock-comment-face nil t)
      (2 font-lock-string-face nil t))
-    ("([^()\n%]*\\|[^()\n]*)" . font-lock-warning-face)
+    ("\\(([^()\n%]*\\)\\|\\(?:^\\|[()]\\)\\(?1:[^()\n]*)\\)"
+     (1 font-lock-warning-face))
     ("[\200-\377]+" (0 font-lock-warning-face prepend nil)))
   "Subdued level highlighting for PostScript mode.")
 





Information forwarded to bug-gnu-emacs@HIDDEN:
bug#16786; Package emacs. Full text available.
Merged 3219 4123 9589 13675 15555 16786. Request was from Glenn Morris <rgm@HIDDEN> to control <at> debbugs.gnu.org. Full text available.

Message received at 16786 <at> debbugs.gnu.org:


Received: (at 16786) by debbugs.gnu.org; 18 Feb 2014 00:55:46 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Feb 17 19:55:45 2014
Received: from localhost ([127.0.0.1]:57278 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.80)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1WFYyP-0007TT-Ik
	for submit <at> debbugs.gnu.org; Mon, 17 Feb 2014 19:55:45 -0500
Received: from fencepost.gnu.org ([208.118.235.10]:43968 ident=Debian-exim)
 by debbugs.gnu.org with esmtp (Exim 4.80)
 (envelope-from <rgm@HIDDEN>) id 1WFYyO-0007TM-4I
 for 16786 <at> debbugs.gnu.org; Mon, 17 Feb 2014 19:55:44 -0500
Received: from rgm by fencepost.gnu.org with local (Exim 4.71)
 (envelope-from <rgm@HIDDEN>)
 id 1WFYyM-0006iD-NJ; Mon, 17 Feb 2014 19:55:42 -0500
From: Glenn Morris <rgm@HIDDEN>
To: Andreas Gustafsson <gson@HIDDEN>
Subject: Re: bug#16786: 24.2; PostScript file with long lines locks up UI
References: <21250.32840.43915.833076@HIDDEN>
X-Spook: advisors ARPA interception JUWTF anarchy blackjack Becker
X-Ran: [n`(fBk:TC@7qBZ!)y')@]1L,d:5|O!n@rk4G7i>S@~y,Uy6.`&%e%~EFA;BdR;xqCOCce
X-Hue: black
X-Debbugs-No-Ack: yes
X-Attribution: GM
Date: Mon, 17 Feb 2014 19:55:42 -0500
In-Reply-To: <21250.32840.43915.833076@HIDDEN> (Andreas Gustafsson's
 message of "Mon, 17 Feb 2014 23:34:00 +0200")
Message-ID: <dfzjlp1box.fsf@HIDDEN>
User-Agent: Gnus (www.gnus.org), GNU Emacs (www.gnu.org/software/emacs/)
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
X-Spam-Score: -5.6 (-----)
X-Debbugs-Envelope-To: 16786
Cc: 16786 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -5.6 (-----)

Andreas Gustafsson wrote:

> I have a PostScript source file containing some embedded font data
> in the form of a single line about 100,000 characters long.

I'm afraid this is a known problem. Emacs does not do well with long
lines, and absolutely not with lines that long.

See http://debbugs.gnu.org/3219 and related reports.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#16786; Package emacs. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 18 Feb 2014 00:29:11 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Feb 17 19:29:11 2014
Received: from localhost ([127.0.0.1]:57240 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.80)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1WFYYf-0006lf-Lm
	for submit <at> debbugs.gnu.org; Mon, 17 Feb 2014 19:29:11 -0500
Received: from eggs.gnu.org ([208.118.235.92]:39289)
 by debbugs.gnu.org with esmtp (Exim 4.80)
 (envelope-from <gson@HIDDEN>) id 1WFVpW-00022V-1e
 for submit <at> debbugs.gnu.org; Mon, 17 Feb 2014 16:34:22 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <gson@HIDDEN>) id 1WFVpM-0006JT-1o
 for submit <at> debbugs.gnu.org; Mon, 17 Feb 2014 16:34:16 -0500
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50 autolearn=disabled
 version=3.3.2
Received: from lists.gnu.org ([2001:4830:134:3::11]:52670)
 by eggs.gnu.org with esmtp (Exim 4.71)
 (envelope-from <gson@HIDDEN>) id 1WFVpL-0006JO-UM
 for submit <at> debbugs.gnu.org; Mon, 17 Feb 2014 16:34:11 -0500
Received: from eggs.gnu.org ([2001:4830:134:3::10]:40989)
 by lists.gnu.org with esmtp (Exim 4.71)
 (envelope-from <gson@HIDDEN>) id 1WFVpH-000678-FY
 for bug-gnu-emacs@HIDDEN; Mon, 17 Feb 2014 16:34:11 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <gson@HIDDEN>) id 1WFVpD-0006I4-3C
 for bug-gnu-emacs@HIDDEN; Mon, 17 Feb 2014 16:34:07 -0500
Received: from gunvor.araneus.fi ([46.246.126.150]:52881)
 by eggs.gnu.org with esmtp (Exim 4.71)
 (envelope-from <gson@HIDDEN>) id 1WFVpC-0006Go-Ow
 for bug-gnu-emacs@HIDDEN; Mon, 17 Feb 2014 16:34:03 -0500
Received: from guava.gson.org (unknown [10.0.1.240])
 by gunvor.araneus.fi (Postfix) with ESMTP id F1006145686;
 Mon, 17 Feb 2014 21:34:33 +0000 (UTC)
Received: by guava.gson.org (Postfix, from userid 101)
 id 119DA75E36; Mon, 17 Feb 2014 23:34:00 +0200 (EET)
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Message-ID: <21250.32840.43915.833076@HIDDEN>
Date: Mon, 17 Feb 2014 23:34:00 +0200
From: Andreas Gustafsson <gson@HIDDEN>
To: bug-gnu-emacs@HIDDEN
Subject: 24.2; PostScript file with long lines locks up UI
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
 recognized.
X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address
 (bad octet value).
X-Received-From: 2001:4830:134:3::11
X-Spam-Score: -5.0 (-----)
X-Debbugs-Envelope-To: submit
X-Mailman-Approved-At: Mon, 17 Feb 2014 19:29:07 -0500
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -5.0 (-----)

Hi,

I have a PostScript source file containing some embedded font data
in the form of a single line about 100,000 characters long.

When I open this file in emacs, it stops responding to keystrokes
(including control-G) for several minutes, consuming 100% CPU.

I see this behavior in 22.2.1, 23.4.1, and 24.2.1, but not in 21.4.1.

The problem can be reproduced by evaluating the following elisp
expression:

  (progn
    (switch-to-buffer "test")
    (insert (make-string 100000 97))
    (ps-mode)
  )

-- 
Andreas Gustafsson, gson@HIDDEN

In GNU Emacs 24.2.1 (x86_64--netbsd)
 of 2012-10-12 on pomegranate.tastylime.net
Configured using:
 `configure '--srcdir=/scratch/editors/emacs24-nox11/work/emacs-24.2'
 '--localstatedir=/var' '--without-dbus' '--without-m17n-flt'
 '--without-otf' '--without-rsvg' '--without-x' '--without-xft'
 '--without-gif' '--without-jpeg' '--without-png' '--without-tiff'
 '--without-xpm' '--prefix=/usr/pkg' '--build=x86_64--netbsd'
 '--host=x86_64--netbsd' '--infodir=/usr/pkg/info'
 '--mandir=/usr/pkg/man' 'build_alias=x86_64--netbsd'
 'host_alias=x86_64--netbsd' 'CC=gcc' 'CFLAGS=-O2 -I/usr/include'
 'LDFLAGS=-L/usr/lib -Wl,-R/usr/lib -Wl,-R/usr/pkg/lib' 'LIBS='
 'CPPFLAGS=-DTERMINFO -I/usr/include''

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: Lisp Interaction

Minor modes in effect:
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t

Recent input:
ESC [ ? 1 ; 2 c ESC x r e p o r TAB RET

Recent messages:
("emacs")
Customizing...
Done.
For information about GNU Emacs and the GNU system, type C-h C-a.

Load-path shadows:
None found.

Features:
(shadow sort gnus-util mail-extr warnings emacsbug message format-spec
rfc822 mml easymenu mml-sec mm-decode mm-bodies mm-encode mail-parse
rfc2231 mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045
ietf-drums mm-util mail-prsvr mail-utils time-date guess-offset cc-vars
cc-defs regexp-opt ediff-hook vc-hooks lisp-float-type lisp-mode
register page menu-bar rfn-eshadow timer 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 minibuffer loaddefs button faces
cus-face files text-properties overlay sha1 md5 base64 format env
code-pages mule custom widget hashtable-print-readable backquote
make-network-process multi-tty emacs)




Acknowledgement sent to Andreas Gustafsson <gson@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to bug-gnu-emacs@HIDDEN:
bug#16786; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Fri, 31 Oct 2014 17:00:04 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.