From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Newsgroups: gmane.emacs.bugs Subject: bug#4175: 23.1; nxml-mode: Internal error in rng-validate-mode triggered Date: Sun, 10 Jul 2022 13:00:27 +0200 Message-ID: <29C2A7FC-4ADF-4479-A6A7-ED6992767D63@acm.org> References: <87tyz9qaqd.fsf@stupidchicken.com> <87r5u9r3io.fsf@thialfi.karme.de> <83bn7m8kfo.fsf@gnu.org> <87lh6qz188.fsf@gmx.net> <83oabm6ssd.fsf@gnu.org> Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.120.0.1.13\)) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="29851"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Eli Zaretskii , Stephen Berman , 4175@debbugs.gnu.org, ahyatt@gmail.com To: Stefan Kangas Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Jul 10 13:01:19 2022 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 1oAUgg-0007c9-Uw for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 10 Jul 2022 13:01:19 +0200 Original-Received: from localhost ([::1]:54120 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oAUgf-0003my-Ps for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 10 Jul 2022 07:01:17 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:56984) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oAUgR-0003mY-0k for bug-gnu-emacs@gnu.org; Sun, 10 Jul 2022 07:01:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:42433) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oAUgQ-0003xN-Oe for bug-gnu-emacs@gnu.org; Sun, 10 Jul 2022 07:01:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oAUgQ-0007KV-IW for bug-gnu-emacs@gnu.org; Sun, 10 Jul 2022 07:01:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 10 Jul 2022 11:01:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 4175 X-GNU-PR-Package: emacs Original-Received: via spool by 4175-submit@debbugs.gnu.org id=B4175.165745084026683 (code B ref 4175); Sun, 10 Jul 2022 11:01:02 +0000 Original-Received: (at 4175) by debbugs.gnu.org; 10 Jul 2022 11:00:40 +0000 Original-Received: from localhost ([127.0.0.1]:36330 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oAUg3-0006vx-Iv for submit@debbugs.gnu.org; Sun, 10 Jul 2022 07:00:40 -0400 Original-Received: from mail1474c50.megamailservers.eu ([91.136.14.74]:36026 helo=mail102c50.megamailservers.eu) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oAUg0-0006mc-U1 for 4175@debbugs.gnu.org; Sun, 10 Jul 2022 07:00:38 -0400 X-Authenticated-User: mattiase@bredband.net DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=megamailservers.eu; s=maildub; t=1657450830; bh=UjYI4TNQAOJhGaLbPPQg7QI1Q3SQbEsgwDRRnetNOms=; h=Subject:From:In-Reply-To:Date:Cc:References:To:From; b=d84TeUi1PKEdfQ0LAzzSxCxx1e973KPNTAFi3SxjD3IRP6JyAZWEQULUY2LHYU71C YABmrJUsSMZ9FTg9AWo5yZ5Iju61y9zH8CVyCkGvCvP0l3VIkPgR/PsXifLo7rq4tL uhiUrr+XORk+8k629wIj3yS+FIE9yItICo7UfGMo= Feedback-ID: mattiase@acm.or Original-Received: from smtpclient.apple (c188-150-171-71.bredband.tele2.se [188.150.171.71]) (authenticated bits=0) by mail102c50.megamailservers.eu (8.14.9/8.13.1) with ESMTP id 26AB0Rui101140; Sun, 10 Jul 2022 11:00:28 +0000 In-Reply-To: X-Mailer: Apple Mail (2.3654.120.0.1.13) X-CTCH-RefID: str=0001.0A782F29.62CAB14E.0004, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0 X-CTCH-VOD: Unknown X-CTCH-Spam: Unknown X-CTCH-Score: 0.000 X-CTCH-Flags: 0 X-CTCH-ScoreCust: 0.000 X-Origin-Country: SE 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" Xref: news.gmane.io gmane.emacs.bugs:236558 Archived-At: The bug is still very much there: I can reproduce it by reducing = emacs_re_max_failures from 40000 to 4000. It's just a matter of file = size. The failing regexp (used at xmltok.el:735) is, after rx = conversion, (rx (group (| (group "xmlns") (: (in "_" alpha) (* (in "._-" alnum)))) (? (group ":" (in "_" alpha) (* (in "._-" alnum))))) (* (in "\t\n\r ")) "=3D" (? (* (in "\t\n\r ")) (group (| (: "'" (* (not (in "\t\n\r&'<"))) (? (group (in "\t\n\r&") (* (not (in "'<"))))) "'") (: "\"" (* (not (in "\t\n\r\"&<"))) ;; (? (group ;; (in "\t\n\r&") ;; (* (not (in "\"<"))))) ;; "\""))) (| (group (* (in "\t\n\r ")) ">") (: (group (* (in "\t\n\r ")) "/") (? (group ">"))) (group (+ (in "\t\n\r ")))))) and the overflow likely occurs somewhere in the ;;-marked section above, = while parsing the big d=3D"..." attribute value. That value isn't huge = (55 KiB) and in any case our parser clearly shouldn't need stack space = in proportional to an XML attribute value. (The default stack limit = fails with attributes around 300 KiB in size, which is not big for an = SVG file.) Isolated test case: (let ((s (concat "'" (make-string 300000 ?a) "'"))) (string-match (rx "'" (* (not (in "\t\n\r&'<"))) (? (group (in "\t\n\r&") (* (not (in "'<"))))) "'") s)) I suggest you rewrite the attribute parser so that it doesn't eat regexp = stack. For instance, (rx "'" (* (not (in "'<"))) "'") doesn't consume stack (thanks to the on_failure_keep_string_jump = optimisation). The parser needs to be a little more complex than that = and validate entities (the &xyz; things) and detect (and recover from) = common errors such as missing end quotes, so a single regexp isn't = sufficient.