From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#61514: 30.0.50; sadistically long xml line hangs emacs Date: Mon, 20 Feb 2023 08:19:26 -0500 Message-ID: References: <87lel0c65v.fsf@everybody.org> <838rgvymcd.fsf@gnu.org> <831qmkwmux.fsf@gnu.org> Reply-To: Stefan Monnier Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="4943"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: mah@everybody.org, 61514@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Feb 20 14:20:31 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 1pU65n-00014J-46 for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 20 Feb 2023 14:20:31 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pU65P-00041A-5x; Mon, 20 Feb 2023 08:20:07 -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 1pU65L-0003jr-48 for bug-gnu-emacs@gnu.org; Mon, 20 Feb 2023 08:20: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 1pU65K-0007Dp-Ly for bug-gnu-emacs@gnu.org; Mon, 20 Feb 2023 08:20:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pU65K-0002Xl-Hp for bug-gnu-emacs@gnu.org; Mon, 20 Feb 2023 08:20:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 20 Feb 2023 13:20: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.16768991829740 (code B ref 61514); Mon, 20 Feb 2023 13:20:02 +0000 Original-Received: (at 61514) by debbugs.gnu.org; 20 Feb 2023 13:19:42 +0000 Original-Received: from localhost ([127.0.0.1]:50995 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pU64x-0002Wz-U5 for submit@debbugs.gnu.org; Mon, 20 Feb 2023 08:19:41 -0500 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:4151) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pU64s-0002Wd-QS for 61514@debbugs.gnu.org; Mon, 20 Feb 2023 08:19:38 -0500 Original-Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id ED49B4407F6; Mon, 20 Feb 2023 08:19:28 -0500 (EST) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 52B0C4407DE; Mon, 20 Feb 2023 08:19:27 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1676899167; bh=E+HalXj5QUOPmAgAgG2NNTeRrDvddR2Pj24HVWSkxUQ=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=Yj+e5TOoHddYU3Y1Zh00UwCrXrE86XsxTyYF4gZ2isLHfJqORE53JVMqjyQwlQlCg HUPDnGLlufLtdib6VNCVssYiPWUl8P8zhn7kq8DzjEA3uTwMizzir5ymwTaC9PYCLj AqMwswgiYIX/Xc4KKvlgD7KZuJ2v1wwM09WHoXcxYKpEELZJG9ui2I1+gfIeKM3pWv WNwFu0fOfBIoTKvb5tyjWwbyU21QksTfto9fYe3589oZBsOobIPuwu3kpi+SQxovxq 3JYUcxF6elP8q6ZjIfWciSCU8bZEF69fXZnZ67lQ/0SI4cT/mtpuyDcx6KXK6lJMRR hlW4VowUUk7uw== Original-Received: from pastel (unknown [216.154.34.24]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 27E80123197; Mon, 20 Feb 2023 08:19:27 -0500 (EST) In-Reply-To: <831qmkwmux.fsf@gnu.org> (Eli Zaretskii's message of "Mon, 20 Feb 2023 14:19:18 +0200") 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:256169 Archived-At: >> IIUC the above describes the code where we're stuck inf-looping inside >> `looking-at`? > Not inflooping, but very slowly backtracking, or so it seems. Duh, right. I meant "hang". Sorry for being a bit mushy-brained for a moment. >> Is it the same place where the regexp-stack overflow happens (and with >> the same regexp)? > > It's (almost) the same place, but not the same regexp. The regexp > which causes the stack-overflow message (which is emitted from > set-auto-mode, before entering redisplay) is this: > > "\\(\\(?:\\(xmlns\\)\\|[_[:alpha:]][-._[:alnum:]]*\\)\\(:[_[:alpha:]][-._[:alnum:]]*\\)?\\)[ \r\t\n]*=\\(?:[ \r\t\n]*\\('[^<'&\r\n\t]*\\([&\r\n\t][^<']*\\)?'\\|\"[^<\"&\r\n\t]*\\([&\r\n\t][^<\"]*\\)?\"\\)\\(?:\\([ \r\t\n]*>\\)\\|\\(?:\\([ \r\t\n]*/\\)\\(>\\)?\\)\\|\\([ \r\t\n]+\\)\\)\\)?" > > As you can see, the prepended "[^<>\n]+?" in the regexp which "hangs" > makes all the difference. So the looking-at which fails reasonably > quickly is the first call to looking-at above, whereas the one the > "hangs" is the second one. Yes, it makes a lot of sense now. > Maybe this points out a way out of this misery? I think it does. E.g. there's a chance that using "[^<>\n]+?\\<" instead of "[^<>\n]+?" avoids the hang (not sure if it's the right thing to do for all the regexp that can be returned by `xmltok-attribute`, tho). And for the stack overflow I haven't yet found its origin. Stefan