From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.devel Subject: Re: [PATCH] Protect against an infloop in python-mode Date: Fri, 24 Mar 2017 17:53:18 +0000 Message-ID: <20170324175318.GA2254@acm> References: <20170228213149.15842-1-phst@google.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: blaine.gmane.org 1490378118 5587 195.159.176.226 (24 Mar 2017 17:55:18 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 24 Mar 2017 17:55:18 +0000 (UTC) User-Agent: Mutt/1.7.2 (2016-11-26) Cc: Philipp Stephani , emacs-devel@gnu.org To: Philipp Stephani Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Mar 24 18:55:14 2017 Return-path: Envelope-to: ged-emacs-devel@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 1crTQd-0000nb-B1 for ged-emacs-devel@m.gmane.org; Fri, 24 Mar 2017 18:55:11 +0100 Original-Received: from localhost ([::1]:34336 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1crTQj-0005hn-Al for ged-emacs-devel@m.gmane.org; Fri, 24 Mar 2017 13:55:17 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:39420) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1crTPW-0005PY-CF for emacs-devel@gnu.org; Fri, 24 Mar 2017 13:54:03 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1crTPR-0005JE-DP for emacs-devel@gnu.org; Fri, 24 Mar 2017 13:54:02 -0400 Original-Received: from ocolin.muc.de ([193.149.48.4]:29186 helo=mail.muc.de) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1crTPR-0005Ik-6i for emacs-devel@gnu.org; Fri, 24 Mar 2017 13:53:57 -0400 Original-Received: (qmail 35739 invoked by uid 3782); 24 Mar 2017 17:53:55 -0000 Original-Received: from acm.muc.de (p548C6C41.dip0.t-ipconnect.de [84.140.108.65]) by colin.muc.de (tmda-ofmipd) with ESMTP; Fri, 24 Mar 2017 18:53:54 +0100 Original-Received: (qmail 3390 invoked by uid 1000); 24 Mar 2017 17:53:18 -0000 Content-Disposition: inline In-Reply-To: X-Delivery-Agent: TMDA/1.1.12 (Macallan) X-Primary-Address: acm@muc.de X-detected-operating-system: by eggs.gnu.org: FreeBSD 9.x [fuzzy] X-Received-From: 193.149.48.4 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:213303 Archived-At: Hello, Philipp. On Thu, Mar 23, 2017 at 22:08:15 +0000, Philipp Stephani wrote: > Philipp Stephani schrieb am Di., 28. Feb. 2017 um > 22:32 Uhr: > > There appears to be an edge case caused by using `syntax-ppss' in a > > narrowed buffer during JIT lock inside of Python triple-quote strings. > > Unfortunately it is impossible to reproduce without manually > > destroying the syntactic information in the Python buffer, but it has > > been observed in practice. In that case it can happen that the syntax > > caches get sufficiently out of whack so that there appear to be > > overlapping strings in the buffer. As Python has no nested strings, > > this situation is impossible and leads to an infloop in > > `python-nav-end-of-statement'. Protect against this by checking > > whether the search for the end of the current string makes progress. I think it's fair to say that syntax-ppss doesn't work in narrowed buffers. This has been known for a long time now - I raised bug #22983 about this topic over a year ago, yet despite repeated requests from myself, there are no signs this is going to be fixed any time soon. I "welcome" your misfortune, as it shows that the flaws in syntax-ppss in narrowed buffers occur in real situations, not just test cases. Presumably, diagnosing the bug took up quite a lot of your valuable time. Let's get bug #22983 fixed. > > * python.el (python-nav-end-of-statement): Protect against infloop. > > * progmodes/python-tests.el > > (python-tests--python-nav-end-of-statement--infloop): Add unit test. > Pushed as 4fbd330fae. -- Alan Mackenzie (Nuremberg, Germany).