From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#31551: 27.0.50; emacs hangs in hexl-mode on modula2 files Date: Tue, 05 Jun 2018 18:30:57 +0300 Message-ID: <83r2ll9rny.fsf@gnu.org> References: Reply-To: Eli Zaretskii NNTP-Posting-Host: blaine.gmane.org X-Trace: blaine.gmane.org 1528212983 1465 195.159.176.226 (5 Jun 2018 15:36:23 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 5 Jun 2018 15:36:23 +0000 (UTC) Cc: 31551@debbugs.gnu.org To: Alexandre Adolphe , Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Jun 05 17:36:18 2018 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fQE0Q-0000Ds-Lr for geb-bug-gnu-emacs@m.gmane.org; Tue, 05 Jun 2018 17:36:18 +0200 Original-Received: from localhost ([::1]:47581 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fQE2X-000081-Px for geb-bug-gnu-emacs@m.gmane.org; Tue, 05 Jun 2018 11:38:29 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:41404) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fQDvL-0002cr-Kx for bug-gnu-emacs@gnu.org; Tue, 05 Jun 2018 11:31:04 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fQDvK-0005XL-Mb for bug-gnu-emacs@gnu.org; Tue, 05 Jun 2018 11:31:03 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:55691) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fQDvK-0005XB-J2 for bug-gnu-emacs@gnu.org; Tue, 05 Jun 2018 11:31:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1fQDvK-0004oc-AG for bug-gnu-emacs@gnu.org; Tue, 05 Jun 2018 11:31:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 05 Jun 2018 15:31:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 31551 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 31551-submit@debbugs.gnu.org id=B31551.152821265918500 (code B ref 31551); Tue, 05 Jun 2018 15:31:02 +0000 Original-Received: (at 31551) by debbugs.gnu.org; 5 Jun 2018 15:30:59 +0000 Original-Received: from localhost ([127.0.0.1]:35354 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fQDvH-0004oK-04 for submit@debbugs.gnu.org; Tue, 05 Jun 2018 11:30:59 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:50311) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fQDvF-0004o7-S9 for 31551@debbugs.gnu.org; Tue, 05 Jun 2018 11:30:58 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fQDv5-0005Hj-M0 for 31551@debbugs.gnu.org; Tue, 05 Jun 2018 11:30:52 -0400 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:45882) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fQDv5-0005HZ-HV; Tue, 05 Jun 2018 11:30:47 -0400 Original-Received: from [176.228.60.248] (port=3924 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1fQDv5-0000pk-0K; Tue, 05 Jun 2018 11:30:47 -0400 In-reply-to: (message from Alexandre Adolphe on Tue, 22 May 2018 15:24:09 +0200) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 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.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:147028 Archived-At: > From: Alexandre Adolphe > Date: Tue, 22 May 2018 15:24:09 +0200 > > I run into an issue lately while trying to use the hexl-mode with > a modula2 file that I found and emacs starts to hang after the > hexl-mode starts. I tested it on emacs 24.5, 25.2 and master. > > To reproduce the issue you can use : > echo "abcd" > test.MOD > emacs -Q --eval '(show-paren-mode 1)' test.MOD > M-x hexl-mode > > --> emacs hangs and use 100% cpu. It only happen on the first character so > we can run out the hang with multiple C-g + an arrow key. > > I dig into the issue and it appears that the was because of the > show-paren-mode and the fact that the ":" character have meaning in > modula-2-mode. Emacs is stuck in the loop of the > m2-smie-refine-colon function because after the "00000000" that start > the hexl buffer there is no more sexp to parse so the tok variable is > empty but the (forward-sexp -1) call does not fail. > > I fixed that myself by stopping the loop if the point is at the beginning > of the buffer. Not sure if it correct but here is the diff : Hmm... I think there's a more serious issue at hand here. Hexl mode is not a normal major mode: it doesn't undo the effects of the previous major mode. So what happens here is that the display is entirely inappropriate for Modula2 sources, but the syntactic setup made by m2-mode is still in effect, and that setup attaches special meaning to ':' when scanning for parentheses. In addition, Hexl mode does nothing to prevent point from entering the parts of the buffer that are "outside the Hexl region", such as the address column (which ends in a colon ':'). Hexl mode only redefines some interactive cursor movement commands to avoid entering the non-Hexl portions, but try "C-u 1 M-x goto-char RET", and Emacs will happily go to the "forbidden" area. (Even some cursor motion commands are not intercepted: e.g., try backward-word.) So Lisp programs can easily move point into portions of the buffer that have nothing to do with the actual file contents. On top of that, show-paren-mode will happily turn itself on in a buffer under Hexl mode, although it makes no sense to me: the Hexl display shows no parens to work with. The fact that syntactical customizations of a mode stay in effect when the display changes so radically sounds like a potential cause of many trouble. So perhaps the right solution would be to temporarily disable mode syntax while in Hexl mode. Stefan, can you take a look and comment?