From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.bugs Subject: bug#16585: c-invalidate-state-cache fails if called when narrowed Date: Sat, 8 Feb 2014 22:37:17 +0000 Message-ID: <20140208223717.GA4063__2234.43555082685$1391899724$gmane$org@acm.acm> References: <52E862C0.3010608@dancol.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1391899710 3268 80.91.229.3 (8 Feb 2014 22:48:30 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 8 Feb 2014 22:48:30 +0000 (UTC) Cc: 16585@debbugs.gnu.org To: Daniel Colascione Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Feb 08 23:48:37 2014 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1WCGhP-0007u0-8W for geb-bug-gnu-emacs@m.gmane.org; Sat, 08 Feb 2014 23:48:35 +0100 Original-Received: from localhost ([::1]:48261 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WCGhO-0003HD-OM for geb-bug-gnu-emacs@m.gmane.org; Sat, 08 Feb 2014 17:48:34 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:48443) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WCGhB-0003Gv-Ru for bug-gnu-emacs@gnu.org; Sat, 08 Feb 2014 17:48:31 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WCGh2-0008Hq-D8 for bug-gnu-emacs@gnu.org; Sat, 08 Feb 2014 17:48:21 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:44296) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WCGgs-0008GN-9p; Sat, 08 Feb 2014 17:48:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1WCGgr-0008Bj-Oe; Sat, 08 Feb 2014 17:48:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Alan Mackenzie Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org, bug-cc-mode@gnu.org Resent-Date: Sat, 08 Feb 2014 22:48:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 16585 X-GNU-PR-Package: emacs,cc-mode X-GNU-PR-Keywords: X-Debbugs-Original-Cc: bug-emacs Original-Received: via spool by submit@debbugs.gnu.org id=B.139189967231459 (code B ref -1); Sat, 08 Feb 2014 22:48:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 8 Feb 2014 22:47:52 +0000 Original-Received: from localhost ([127.0.0.1]:58315 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WCGgh-0008BK-V4 for submit@debbugs.gnu.org; Sat, 08 Feb 2014 17:47:52 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:46611) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WCGgg-0008BD-F4 for submit@debbugs.gnu.org; Sat, 08 Feb 2014 17:47:51 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WCGgW-00088A-QO for submit@debbugs.gnu.org; Sat, 08 Feb 2014 17:47:50 -0500 Original-Received: from lists.gnu.org ([2001:4830:134:3::11]:50602) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WCGgW-000884-O4 for submit@debbugs.gnu.org; Sat, 08 Feb 2014 17:47:40 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:48315) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WCGgP-0003Em-CR for bug-gnu-emacs@gnu.org; Sat, 08 Feb 2014 17:47:40 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WCGgI-00082m-1u for bug-gnu-emacs@gnu.org; Sat, 08 Feb 2014 17:47:33 -0500 Original-Received: from colin.muc.de ([193.149.48.1]:46815 helo=mail.muc.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WCGgH-00082T-P2 for bug-gnu-emacs@gnu.org; Sat, 08 Feb 2014 17:47:25 -0500 Original-Received: (qmail 72467 invoked by uid 3782); 8 Feb 2014 22:40:42 -0000 Original-Received: from acm.muc.de (pD951823D.dip0.t-ipconnect.de [217.81.130.61]) by colin.muc.de (tmda-ofmipd) with ESMTP; Sat, 08 Feb 2014 23:40:41 +0100 Original-Received: (qmail 4547 invoked by uid 1000); 8 Feb 2014 22:37:17 -0000 Content-Disposition: inline In-Reply-To: <52E862C0.3010608@dancol.org> User-Agent: Mutt/1.5.21 (2010-09-15) X-Delivery-Agent: TMDA/1.1.12 (Macallan) X-Primary-Address: acm@muc.de X-detected-operating-system: by eggs.gnu.org: FreeBSD 8.x X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.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-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:84994 Archived-At: Hi, Daniel. On Tue, Jan 28, 2014 at 06:09:04PM -0800, Daniel Colascione wrote: > c-invalidate-state-cache can fail if called in a narrowed region: we end > up calling c-clear-char-property for bob even if that's before > point-min, causing remote-text-properties to raise (args-out-of-range 1 2). > We get into this situation when expanding yasnippet snippets; we're > calling c-invalidate-state-cache from c-before-change. > To repro manually, first write this to some buffer. > #include > void foo() { > } > Then (this is important) run M-x c-mode. After starting the mode, move > point to inside foo's body and eval (save-restriction (narrow-to-region > (point-at-bol) (point-at-eol)) (c-invalidate-state-cache (point))). You > should break into the debugger. Thanks for this crystal clear bug report, and for taking the trouble to debug it. > The patch below seems correct and fixes the problem for me, but it'd be > nice if Alan could take a look at it before I push it to trunk. The > version of c-invalidate-state-cache in cc-mode trunk is very different. I don't think (but I'm not quite sure) that this patch is correct, since it leaves c-invalidate-state-cache-1 running widened. That might well lead to incorrect "state cache" manipulations. Instead I've widened the buffer around the two calls which clear and set the text properties. Would you please try out the following patch, which should fix the problem. === modified file 'lisp/progmodes/cc-defs.el' *** lisp/progmodes/cc-defs.el 2014-02-02 10:25:29 +0000 --- lisp/progmodes/cc-defs.el 2014-02-08 22:21:01 +0000 *************** *** 1293,1302 **** ;; suppressed. `(unwind-protect (c-save-buffer-state () ! (c-clear-cpp-delimiters ,beg ,end) ,`(c-with-cpps-commented-out ,@forms)) (c-save-buffer-state () ! (c-set-cpp-delimiters ,beg ,end)))) (defsubst c-intersect-lists (list alist) ;; return the element of ALIST that matches the first element found --- 1293,1306 ---- ;; suppressed. `(unwind-protect (c-save-buffer-state () ! (save-restriction ! (widen) ! (c-clear-cpp-delimiters ,beg ,end)) ,`(c-with-cpps-commented-out ,@forms)) (c-save-buffer-state () ! (save-restriction ! (widen) ! (c-set-cpp-delimiters ,beg ,end))))) (defsubst c-intersect-lists (list alist) ;; return the element of ALIST that matches the first element found -- Alan Mackenzie (Nuremberg, Germany).