From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Gregory Heytings Newsgroups: gmane.emacs.bugs Subject: bug#61514: 30.0.50; sadistically long xml line hangs emacs Date: Tue, 21 Feb 2023 13:35:42 +0000 Message-ID: <6abb5de688b2692446f9@heytings.org> References: <87lel0c65v.fsf@everybody.org> <838rgvymcd.fsf@gnu.org> <831qmkwmux.fsf@gnu.org> <83cz64v3v7.fsf@gnu.org> <83r0ujte97.fsf@gnu.org> <6abb5de688808f8d363d@heytings.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="glEOrdaMFc" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="31245"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Eli Zaretskii , 61514@debbugs.gnu.org, mah@everybody.org To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Feb 21 14:36:15 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pUSoX-0007tW-HK for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 21 Feb 2023 14:36:13 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pUSoP-0004jD-2J; Tue, 21 Feb 2023 08:36:05 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pUSoN-0004gz-22 for bug-gnu-emacs@gnu.org; Tue, 21 Feb 2023 08:36:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pUSoM-0000Q3-Mt for bug-gnu-emacs@gnu.org; Tue, 21 Feb 2023 08:36:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pUSoM-0004qx-8D for bug-gnu-emacs@gnu.org; Tue, 21 Feb 2023 08:36:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Gregory Heytings Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 21 Feb 2023 13:36:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 61514 X-GNU-PR-Package: emacs Original-Received: via spool by 61514-submit@debbugs.gnu.org id=B61514.167698654818500 (code B ref 61514); Tue, 21 Feb 2023 13:36:02 +0000 Original-Received: (at 61514) by debbugs.gnu.org; 21 Feb 2023 13:35:48 +0000 Original-Received: from localhost ([127.0.0.1]:55010 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pUSo8-0004oF-49 for submit@debbugs.gnu.org; Tue, 21 Feb 2023 08:35:48 -0500 Original-Received: from heytings.org ([95.142.160.155]:38472) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pUSo4-0004nE-67 for 61514@debbugs.gnu.org; Tue, 21 Feb 2023 08:35:46 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=heytings.org; s=20220101; t=1676986542; bh=PumUwz6/u78+HG83IUxIGAPT4Y8N2JnRzTk3laBFyJg=; h=Date:From:To:cc:Subject:In-Reply-To:Message-ID:References:From; b=2i8rg1xB+M7C8M92baUoKCZYfUZ3IUgZmnUrdRFVaKVAV0XURBrQKWs36XhTEijE1 FSz3r/TujTgqRVPGA1W0E8Fxnt7RmzRNZ9K/NVCF8smzmfBqSsZI3Lrnd97Fp6IHnb DH1TZUSIFWKiGpJj2Nh6d1JOErBgV9kIfeW3YOzgwMsmBSU8gBo4HXM1ArBIS9Y41X 5Uufzu1SRiPwdPzl5BKxZjQ93fUBvKiw9XjIpnLJTNhseJhNQYsVeWKKeutXQTQPjX UPZt2N+DvcshwWnYttUnhHlFoRvRSV/szoFnSNriuGjvLqnBzZ/rP62BwGf+uadpOF 46MErbR0LCBtg== In-Reply-To: X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:256267 Archived-At: --glEOrdaMFc Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable > > BTW, personally when I suggested to limit the search I was thinking of=20 > `narrow-to-region` (which bounds both N factors in the N=C2=B2 complexity= ). > Indeed, that's another way to cope with that problem, and a better one: diff --git a/lisp/nxml/xmltok.el b/lisp/nxml/xmltok.el index c36d225c7c9..9badd7e4c53 100644 --- a/lisp/nxml/xmltok.el +++ b/lisp/nxml/xmltok.el @@ -734,8 +734,10 @@ xmltok-scan-attributes (atts-needing-normalization nil)) (while (cond ((or (looking-at (xmltok-attribute regexp)) ;; use non-greedy group - (when (looking-at (concat "[^<>\n]+?" - (xmltok-attribute regexp))) + (when (with-restriction + (point) (+ (point) 10000) + (looking-at (concat "[^<>\n]+?" + (xmltok-attribute regexp))= )) (unless recovering (xmltok-add-error "Malformed attribute" (point) With this opening the 4 MB file takes 1.6 seconds. With 5000 instead of=20 10000 it takes 0.8 seconds. > > AFAIK this part of the code is intended mostly when editing XML by hand,= =20 > where attributes aren't expected to be ridiculously long, so limiting to= =20 > a few kB would be perfectly acceptable (and if the search fails it's not= =20 > big deal: when the search succeeds we don't *really* know what it means= =20 > either, it may be a false positive anyway). > Indeed. --glEOrdaMFc--