From unknown Sun Jun 22 22:45:31 2025 X-Loop: help-debbugs@gnu.org Subject: bug#16585: c-invalidate-state-cache fails if called when narrowed Resent-From: Daniel Colascione Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 29 Jan 2014 02:10:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 16585 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: 16585@debbugs.gnu.org Cc: Alan Mackenzie X-Debbugs-Original-To: bug-emacs Received: via spool by submit@debbugs.gnu.org id=B.139096137221134 (code B ref -1); Wed, 29 Jan 2014 02:10:01 +0000 Received: (at submit) by debbugs.gnu.org; 29 Jan 2014 02:09:32 +0000 Received: from localhost ([127.0.0.1]:39707 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1W8Kap-0005Un-Bx for submit@debbugs.gnu.org; Tue, 28 Jan 2014 21:09:31 -0500 Received: from eggs.gnu.org ([208.118.235.92]:47685) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1W8Kam-0005Ua-P6 for submit@debbugs.gnu.org; Tue, 28 Jan 2014 21:09:29 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1W8Kag-0002nn-CB for submit@debbugs.gnu.org; Tue, 28 Jan 2014 21:09:23 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=BAYES_20,T_DKIM_INVALID autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:33611) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W8Kag-0002nj-8r for submit@debbugs.gnu.org; Tue, 28 Jan 2014 21:09:22 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49398) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W8Kaf-0002wC-43 for bug-gnu-emacs@gnu.org; Tue, 28 Jan 2014 21:09:22 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1W8Kad-0002nK-RZ for bug-gnu-emacs@gnu.org; Tue, 28 Jan 2014 21:09:20 -0500 Received: from dancol.org ([2600:3c01::f03c:91ff:fedf:adf3]:39512) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W8Kad-0002mN-GR for bug-gnu-emacs@gnu.org; Tue, 28 Jan 2014 21:09:19 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=dancol.org; s=x; h=Content-Transfer-Encoding:Content-Type:Subject:CC:To:MIME-Version:From:Date:Message-ID; bh=Ty3WM9JhkOi8vdvmVxOvSWpGGSyAm6ynyD1mByBgwlU=; b=SXc1orOqvbZv/i17nn7Al+ePgvsdJCCT6cDUfF2KdOkZx8Zl/uX0OrQY7yT9Lz7ZGmXzlT1A8se1e1TL7wRmN9LaxJT6HAs2hHMieA6rMCdG+/S79BFoYf+PZFzjQnIMuGfR0WVvkx1QJI/dMMg8e0iY9eLgHerKUwzv+Z9GFERP6TS4mE2EdRruXH+L9fC4rWdcTLwXxFebVib5GEa0apqnOQwOgWGxtSE2BFqY/IDFkcIltGrv4d39QcgkaYGuWeb/B8HJ65gTZYQVJjNlzliCNALmYtCYG0bi5VUOmEjl7STyk/GpiUHFVEH+koUzMKTlasZh2v/57TNojXaeRA==; Received: from [2620:0:1cfe:a1:2b5:6dff:fe05:24f5] by dancol.org with esmtpsa (TLS1.0:DHE_RSA_CAMELLIA_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1W8KaW-0004cg-6M; Tue, 28 Jan 2014 18:09:12 -0800 Message-ID: <52E862C0.3010608@dancol.org> Date: Tue, 28 Jan 2014 18:09:04 -0800 From: Daniel Colascione User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -4.1 (----) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -4.1 (----) 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. 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. === modified file 'lisp/progmodes/cc-engine.el' --- lisp/progmodes/cc-engine.el 2014-01-19 12:32:47 +0000 +++ lisp/progmodes/cc-engine.el 2014-01-29 02:07:44 +0000 @@ -3318,15 +3318,17 @@ ;; of all parens in preprocessor constructs, except for any such construct ;; containing point. We can then call `c-invalidate-state-cache-1' without ;; worrying further about macros and template delimiters. - (c-with-<->-as-parens-suppressed - (if (and c-state-old-cpp-beg - (< c-state-old-cpp-beg here)) - (c-with-all-but-one-cpps-commented-out - c-state-old-cpp-beg - (min c-state-old-cpp-end here) - (c-invalidate-state-cache-1 here)) - (c-with-cpps-commented-out - (c-invalidate-state-cache-1 here))))) + (save-restriction + (widen) + (c-with-<->-as-parens-suppressed + (if (and c-state-old-cpp-beg + (< c-state-old-cpp-beg here)) + (c-with-all-but-one-cpps-commented-out + c-state-old-cpp-beg + (min c-state-old-cpp-end here) + (c-invalidate-state-cache-1 here)) + (c-with-cpps-commented-out + (c-invalidate-state-cache-1 here)))))) (defmacro c-state-maybe-marker (place marker) ;; If PLACE is non-nil, return a marker marking it, otherwise nil. From unknown Sun Jun 22 22:45:31 2025 X-Loop: help-debbugs@gnu.org Subject: bug#16585: c-invalidate-state-cache fails if called when narrowed Resent-From: Glenn Morris Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org, bug-cc-mode@gnu.org Resent-Date: Wed, 29 Jan 2014 02:50:02 +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: To: Daniel Colascione Cc: 16585@debbugs.gnu.org, Alan Mackenzie Received: via spool by 16585-submit@debbugs.gnu.org id=B16585.139096379124891 (code B ref 16585); Wed, 29 Jan 2014 02:50:02 +0000 Received: (at 16585) by debbugs.gnu.org; 29 Jan 2014 02:49:51 +0000 Received: from localhost ([127.0.0.1]:39720 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1W8LDr-0006TO-6h for submit@debbugs.gnu.org; Tue, 28 Jan 2014 21:49:51 -0500 Received: from fencepost.gnu.org ([208.118.235.10]:58287) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1W8LDq-0006TH-7f for 16585@debbugs.gnu.org; Tue, 28 Jan 2014 21:49:50 -0500 Received: from rgm by fencepost.gnu.org with local (Exim 4.71) (envelope-from ) id 1W8LDo-0005kW-LY; Tue, 28 Jan 2014 21:49:48 -0500 From: Glenn Morris References: <52E862C0.3010608@dancol.org> X-Spook: Bellcore DES FSF Indigo halcon counter intelligence X-Ran: y&KsV{m`6A#l__r6sI1kYYE:Bic,`C*As>)ls*_s~H5(?I$HU|qA1}nsQQo[$Xp}g&f@qh X-Hue: magenta X-Attribution: GM Date: Tue, 28 Jan 2014 21:49:48 -0500 In-Reply-To: <52E862C0.3010608@dancol.org> (Daniel Colascione's message of "Tue, 28 Jan 2014 18:09:04 -0800") Message-ID: <6jeh3rsdrn.fsf@fencepost.gnu.org> User-Agent: Gnus (www.gnus.org), GNU Emacs (www.gnu.org/software/emacs/) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Spam-Score: -5.5 (-----) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.5 (-----) See also http://debbugs.gnu.org/13713 . BTW, if you use Package: emacs,cc-mode at the start of the initial report, all mails will also go to bug-cc-mode. From unknown Sun Jun 22 22:45:31 2025 X-Loop: help-debbugs@gnu.org Subject: bug#16585: c-invalidate-state-cache fails if called when narrowed Resent-From: Daniel Colascione Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org, bug-cc-mode@gnu.org Resent-Date: Sun, 02 Feb 2014 02:13:02 +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: To: Glenn Morris Cc: 16585@debbugs.gnu.org, acm@muc.de X-Debbugs-Original-Cc: 16585@debbugs.gnu.org, Alan Mackenzie , bug-cc-mode@gnu.org Received: via spool by 16585-submit@debbugs.gnu.org id=B16585.13913071555578 (code B ref 16585); Sun, 02 Feb 2014 02:13:02 +0000 Received: (at 16585) by debbugs.gnu.org; 2 Feb 2014 02:12:35 +0000 Received: from localhost ([127.0.0.1]:45537 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1W9mXz-0001Ru-1p for submit@debbugs.gnu.org; Sat, 01 Feb 2014 21:12:35 -0500 Received: from dancol.org ([96.126.100.184]:48668) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1W9mXw-0001Ri-5l for 16585@debbugs.gnu.org; Sat, 01 Feb 2014 21:12:33 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=dancol.org; s=x; h=Content-Transfer-Encoding:Content-Type:In-Reply-To:References:Subject:CC:To:MIME-Version:From:Date:Message-ID; bh=390YDWbx8Zm38vYZC4pSYywo7fL6l6845DnxFTlSuoY=; b=HjC3ghl67vhCWj4twHtJHSADXDnp3Hr51uojolhda6wKH//yGXqSDdbZEPA6Qull1v0OAW4fAKtPhFE0IRFzsRen0oiD3WGi9KOn5dcLOml92DQN+JO9yEjiZjQ5gJJfAH4Wqxl9/1JWndUpCIpUHyW8lYfSwPdNHLo9bN1yHAHM5G2ythUSE6H+K2KcsA0szC8UnAuhpkmk8TbXQ6z16EX7yrR6WMZk0HgVAnJKt8Dr/njTcmDaPI495+Gi11O4crlhjDrE8KDvCB9TESQ3OyspfUHzwHZY1CCfE27mH4QPYd81mP8D1isIifDyl+7O4d5rVfI7MLx67TwuaCdAGg==; Received: from [2601:8:b240:b7::e5a] by dancol.org with esmtpsa (TLS1.0:DHE_RSA_CAMELLIA_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1W9mXu-000140-IF; Sat, 01 Feb 2014 18:12:30 -0800 Message-ID: <52EDA98D.8070802@dancol.org> Date: Sat, 01 Feb 2014 18:12:29 -0800 From: Daniel Colascione User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 MIME-Version: 1.0 References: <52E862C0.3010608@dancol.org> <6jeh3rsdrn.fsf@fencepost.gnu.org> In-Reply-To: <6jeh3rsdrn.fsf@fencepost.gnu.org> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: -0.5 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.5 (/) On 01/28/2014 06:49 PM, Glenn Morris wrote: > > See also http://debbugs.gnu.org/13713 . > > BTW, if you use > > Package: emacs,cc-mode > > at the start of the initial report, all mails will also go to bug-cc-mode. > Thanks. Adding bug-cc-mode manually now. I'd like to commit the change to Emacs before release. From unknown Sun Jun 22 22:45:31 2025 X-Loop: help-debbugs@gnu.org Subject: bug#16585: c-invalidate-state-cache fails if called when narrowed Resent-From: Alan Mackenzie Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org, bug-cc-mode@gnu.org Resent-Date: Wed, 05 Feb 2014 23:20:02 +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: To: Daniel Colascione Cc: 16585@debbugs.gnu.org, rgm@gnu.org X-Debbugs-Original-Cc: bug-cc-mode@gnu.org, 16585@debbugs.gnu.org, Glenn Morris Received: via spool by 16585-submit@debbugs.gnu.org id=B16585.139164237027227 (code B ref 16585); Wed, 05 Feb 2014 23:20:02 +0000 Received: (at 16585) by debbugs.gnu.org; 5 Feb 2014 23:19:30 +0000 Received: from localhost ([127.0.0.1]:51375 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WBBkg-000754-8o for submit@debbugs.gnu.org; Wed, 05 Feb 2014 18:19:30 -0500 Received: from colin.muc.de ([193.149.48.1]:47303 helo=mail.muc.de) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WBBke-00074w-7D for 16585@debbugs.gnu.org; Wed, 05 Feb 2014 18:19:28 -0500 Received: (qmail 29786 invoked by uid 3782); 5 Feb 2014 23:19:27 -0000 Received: from acm.muc.de (pD951B331.dip0.t-ipconnect.de [217.81.179.49]) by colin.muc.de (tmda-ofmipd) with ESMTP; Thu, 06 Feb 2014 00:19:26 +0100 Received: (qmail 5224 invoked by uid 1000); 5 Feb 2014 23:16:07 -0000 Date: Wed, 5 Feb 2014 23:16:07 +0000 Message-ID: <20140205231607.GD3381@acm.acm> References: <52E862C0.3010608@dancol.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii 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) From: Alan Mackenzie X-Primary-Address: acm@muc.de X-Spam-Score: -1.2 (-) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.2 (-) 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. > 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 think I'd like to check that nothing can go awry in c-invalidate-state-cache-1 with the widened buffer. Give me a day or two. -- Alan Mackenzie (Nuremberg, Germany). From unknown Sun Jun 22 22:45:31 2025 X-Loop: help-debbugs@gnu.org Subject: bug#16585: c-invalidate-state-cache fails if called when narrowed 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: To: Daniel Colascione Cc: 16585@debbugs.gnu.org X-Debbugs-Original-Cc: bug-emacs Received: via spool by submit@debbugs.gnu.org id=B.139189967231459 (code B ref -1); Sat, 08 Feb 2014 22:48:01 +0000 Received: (at submit) by debbugs.gnu.org; 8 Feb 2014 22:47:52 +0000 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 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 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 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-0.0 required=5.0 tests=BAYES_40 autolearn=disabled version=3.3.2 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 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 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 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 Received: (qmail 72467 invoked by uid 3782); 8 Feb 2014 22:40:42 -0000 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 Received: (qmail 4547 invoked by uid 1000); 8 Feb 2014 22:37:17 -0000 Date: Sat, 8 Feb 2014 22:37:17 +0000 Message-ID: <20140208223717.GA4063@acm.acm> References: <52E862C0.3010608@dancol.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii 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) From: Alan Mackenzie 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-Received-From: 2001:4830:134:3::11 X-Spam-Score: -4.3 (----) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -4.3 (----) 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). From unknown Sun Jun 22 22:45:31 2025 X-Loop: help-debbugs@gnu.org Subject: bug#16585: c-invalidate-state-cache fails if called when narrowed 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 23:01:02 +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: To: Daniel Colascione Cc: 16585@debbugs.gnu.org Received: via spool by 16585-submit@debbugs.gnu.org id=B16585.1391900428331 (code B ref 16585); Sat, 08 Feb 2014 23:01:02 +0000 Received: (at 16585) by debbugs.gnu.org; 8 Feb 2014 23:00:28 +0000 Received: from localhost ([127.0.0.1]:58331 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WCGst-00005E-5U for submit@debbugs.gnu.org; Sat, 08 Feb 2014 18:00:27 -0500 Received: from colin.muc.de ([193.149.48.1]:51244 helo=mail.muc.de) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WCGsp-00004s-Le for 16585@debbugs.gnu.org; Sat, 08 Feb 2014 18:00:24 -0500 Received: (qmail 74020 invoked by uid 3782); 8 Feb 2014 23:00:22 -0000 Received: from acm.muc.de (pD951823D.dip0.t-ipconnect.de [217.81.130.61]) by colin.muc.de (tmda-ofmipd) with ESMTP; Sun, 09 Feb 2014 00:00:21 +0100 Received: (qmail 5177 invoked by uid 1000); 8 Feb 2014 22:57:02 -0000 Date: Sat, 8 Feb 2014 22:57:02 +0000 Message-ID: <20140208225702.GC4063@acm.acm> References: <52E862C0.3010608@dancol.org> <20140208223717.GA4063@acm.acm> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20140208223717.GA4063@acm.acm> User-Agent: Mutt/1.5.21 (2010-09-15) X-Delivery-Agent: TMDA/1.1.12 (Macallan) From: Alan Mackenzie X-Primary-Address: acm@muc.de X-Spam-Score: -1.2 (-) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.2 (-) Hi, Daniel. On Sat, Feb 08, 2014 at 10:37:17PM +0000, Alan Mackenzie wrote: [ .... ] > 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. I just forgot to say, after applying the patch, please compile first cc-defs.el, then cc-engine.el. -- Alan Mackenzie (Nuremberg, Germany). From unknown Sun Jun 22 22:45:31 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.503 (Entity 5.503) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: Daniel Colascione Subject: bug#16585: closed (Re: [Emacs-diffs] trunk r116378: Fix c-invalidate-state-cache on narrowed buffers.) Message-ID: References: <53002884.1030103@dancol.org> <52E862C0.3010608@dancol.org> X-Gnu-PR-Message: they-closed 16585 X-Gnu-PR-Package: emacs,cc-mode Reply-To: 16585@debbugs.gnu.org Date: Sun, 16 Feb 2014 02:56:03 +0000 Content-Type: multipart/mixed; boundary="----------=_1392519363-23047-1" This is a multi-part message in MIME format... ------------=_1392519363-23047-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #16585: c-invalidate-state-cache fails if called when narrowed which was filed against the emacs,cc-mode package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 16585@debbugs.gnu.org. --=20 16585: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D16585 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1392519363-23047-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 16585-done) by debbugs.gnu.org; 16 Feb 2014 02:55:08 +0000 Received: from localhost ([127.0.0.1]:54085 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WErso-0005yQ-W9 for submit@debbugs.gnu.org; Sat, 15 Feb 2014 21:55:07 -0500 Received: from dancol.org ([96.126.100.184]:40394) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WErsm-0005yE-JT for 16585-done@debbugs.gnu.org; Sat, 15 Feb 2014 21:55:05 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=dancol.org; s=x; h=Content-Transfer-Encoding:Content-Type:In-Reply-To:References:Subject:To:MIME-Version:From:Date:Message-ID; bh=/aI8CRpj0Sj9hx25lnIOXl0608iq8p5eNMN+ASYBMRQ=; b=YxmS201G/eAoCK9oJ0F//xUvlNU6SphIGofsmAv9kS38Faux9dRL7X4c/PTRNJ1y1jZyK2JB4Y1x/lyYOD2QT/p/HVm7ND/zxrk1dnvemkgKYhkWoKTkScKgQPbrb1IS2lLG2xm/m9EwZ8RNjhf5braWpaQEyVAMFfOZIwCyiACe+LoxyzAocyu4xT8Ene4vZ0zGF2X1sjmjtI1Ruo9xuYIMCHXYkUQLt5UvQzdEUGBGaSuQvbJ8/CLBSBt9Q0w3PTrPIqCRI37RcrfoPQgOFPw5PWyqdAGzTHLJTYjIg2QHxY4tZz9sL/K+41ebrI2tKqRB/+CoZUwnalEbrUTVmw==; Received: from c-76-104-210-106.hsd1.wa.comcast.net ([76.104.210.106] helo=[192.168.1.51]) by dancol.org with esmtpsa (TLS1.0:DHE_RSA_CAMELLIA_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1WErsk-00079C-4u; Sat, 15 Feb 2014 18:55:02 -0800 Message-ID: <53002884.1030103@dancol.org> Date: Sat, 15 Feb 2014 18:55:00 -0800 From: Daniel Colascione User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 MIME-Version: 1.0 To: Alan Mackenzie , emacs-devel@gnu.org, 16585-done@debbugs.gnu.org Subject: Re: [Emacs-diffs] trunk r116378: Fix c-invalidate-state-cache on narrowed buffers. References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: -0.6 (/) X-Debbugs-Envelope-To: 16585-done X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.6 (/) Thanks. Seems fixed now. On 02/09/2014 04:38 AM, Alan Mackenzie wrote: > ------------------------------------------------------------ > revno: 116378 > revision-id: acm@muc.de-20140209123425-ms311yngryt01jls > parent: rgm@gnu.org-20140209112300-kf0j1tnx3rj0efyn > committer: Alan Mackenzie > branch nick: trunk > timestamp: Sun 2014-02-09 12:34:25 +0000 > message: > Fix c-invalidate-state-cache on narrowed buffers. > progmodes/cc-defs.el (c-with-all-but-one-cpps-commented-out): Widen when > setting and clearing the CPP delimiter properties. > modified: > lisp/ChangeLog changelog-20091113204419-o5vbwnq5f7feedwu-1432 > lisp/progmodes/cc-defs.el ccdefs.el-20091113204419-o5vbwnq5f7feedwu-1226 > > > > _______________________________________________ > Emacs-diffs mailing list > Emacs-diffs@gnu.org > https://lists.gnu.org/mailman/listinfo/emacs-diffs > ------------=_1392519363-23047-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 29 Jan 2014 02:09:32 +0000 Received: from localhost ([127.0.0.1]:39707 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1W8Kap-0005Un-Bx for submit@debbugs.gnu.org; Tue, 28 Jan 2014 21:09:31 -0500 Received: from eggs.gnu.org ([208.118.235.92]:47685) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1W8Kam-0005Ua-P6 for submit@debbugs.gnu.org; Tue, 28 Jan 2014 21:09:29 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1W8Kag-0002nn-CB for submit@debbugs.gnu.org; Tue, 28 Jan 2014 21:09:23 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=BAYES_20,T_DKIM_INVALID autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:33611) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W8Kag-0002nj-8r for submit@debbugs.gnu.org; Tue, 28 Jan 2014 21:09:22 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49398) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W8Kaf-0002wC-43 for bug-gnu-emacs@gnu.org; Tue, 28 Jan 2014 21:09:22 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1W8Kad-0002nK-RZ for bug-gnu-emacs@gnu.org; Tue, 28 Jan 2014 21:09:20 -0500 Received: from dancol.org ([2600:3c01::f03c:91ff:fedf:adf3]:39512) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W8Kad-0002mN-GR for bug-gnu-emacs@gnu.org; Tue, 28 Jan 2014 21:09:19 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=dancol.org; s=x; h=Content-Transfer-Encoding:Content-Type:Subject:CC:To:MIME-Version:From:Date:Message-ID; bh=Ty3WM9JhkOi8vdvmVxOvSWpGGSyAm6ynyD1mByBgwlU=; b=SXc1orOqvbZv/i17nn7Al+ePgvsdJCCT6cDUfF2KdOkZx8Zl/uX0OrQY7yT9Lz7ZGmXzlT1A8se1e1TL7wRmN9LaxJT6HAs2hHMieA6rMCdG+/S79BFoYf+PZFzjQnIMuGfR0WVvkx1QJI/dMMg8e0iY9eLgHerKUwzv+Z9GFERP6TS4mE2EdRruXH+L9fC4rWdcTLwXxFebVib5GEa0apqnOQwOgWGxtSE2BFqY/IDFkcIltGrv4d39QcgkaYGuWeb/B8HJ65gTZYQVJjNlzliCNALmYtCYG0bi5VUOmEjl7STyk/GpiUHFVEH+koUzMKTlasZh2v/57TNojXaeRA==; Received: from [2620:0:1cfe:a1:2b5:6dff:fe05:24f5] by dancol.org with esmtpsa (TLS1.0:DHE_RSA_CAMELLIA_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1W8KaW-0004cg-6M; Tue, 28 Jan 2014 18:09:12 -0800 Message-ID: <52E862C0.3010608@dancol.org> Date: Tue, 28 Jan 2014 18:09:04 -0800 From: Daniel Colascione User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 MIME-Version: 1.0 To: bug-emacs Subject: c-invalidate-state-cache fails if called when narrowed Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -4.1 (----) X-Debbugs-Envelope-To: submit Cc: Alan Mackenzie X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -4.1 (----) 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. 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. === modified file 'lisp/progmodes/cc-engine.el' --- lisp/progmodes/cc-engine.el 2014-01-19 12:32:47 +0000 +++ lisp/progmodes/cc-engine.el 2014-01-29 02:07:44 +0000 @@ -3318,15 +3318,17 @@ ;; of all parens in preprocessor constructs, except for any such construct ;; containing point. We can then call `c-invalidate-state-cache-1' without ;; worrying further about macros and template delimiters. - (c-with-<->-as-parens-suppressed - (if (and c-state-old-cpp-beg - (< c-state-old-cpp-beg here)) - (c-with-all-but-one-cpps-commented-out - c-state-old-cpp-beg - (min c-state-old-cpp-end here) - (c-invalidate-state-cache-1 here)) - (c-with-cpps-commented-out - (c-invalidate-state-cache-1 here))))) + (save-restriction + (widen) + (c-with-<->-as-parens-suppressed + (if (and c-state-old-cpp-beg + (< c-state-old-cpp-beg here)) + (c-with-all-but-one-cpps-commented-out + c-state-old-cpp-beg + (min c-state-old-cpp-end here) + (c-invalidate-state-cache-1 here)) + (c-with-cpps-commented-out + (c-invalidate-state-cache-1 here)))))) (defmacro c-state-maybe-marker (place marker) ;; If PLACE is non-nil, return a marker marking it, otherwise nil. ------------=_1392519363-23047-1-- From unknown Sun Jun 22 22:45:31 2025 X-Loop: help-debbugs@gnu.org Subject: bug#16585: c-invalidate-state-cache fails if called when narrowed Resent-From: Alan Mackenzie Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org, bug-cc-mode@gnu.org Resent-Date: Sun, 16 Feb 2014 09:18:02 +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: To: 16585-done@debbugs.gnu.org Received: via spool by 16585-done@debbugs.gnu.org id=D16585.139254227710846 (code D ref 16585); Sun, 16 Feb 2014 09:18:02 +0000 Received: (at 16585-done) by debbugs.gnu.org; 16 Feb 2014 09:17:57 +0000 Received: from localhost ([127.0.0.1]:54257 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WExrJ-0002oq-I1 for submit@debbugs.gnu.org; Sun, 16 Feb 2014 04:17:57 -0500 Received: from colin.muc.de ([193.149.48.1]:54704 helo=mail.muc.de) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WExrF-0002og-CH for 16585-done@debbugs.gnu.org; Sun, 16 Feb 2014 04:17:54 -0500 Received: (qmail 26566 invoked by uid 3782); 16 Feb 2014 09:17:51 -0000 Received: from acm.muc.de (pD95187DA.dip0.t-ipconnect.de [217.81.135.218]) by colin.muc.de (tmda-ofmipd) with ESMTP; Sun, 16 Feb 2014 10:17:51 +0100 Received: (qmail 3065 invoked by uid 1000); 16 Feb 2014 09:14:28 -0000 Date: Sun, 16 Feb 2014 09:14:28 +0000 Message-ID: <20140216091428.GA3058@acm.acm> References: <52E862C0.3010608@dancol.org> <6jeh3rsdrn.fsf@fencepost.gnu.org> <52EDA98D.8070802@dancol.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <52EDA98D.8070802@dancol.org> User-Agent: Mutt/1.5.21 (2010-09-15) X-Delivery-Agent: TMDA/1.1.12 (Macallan) From: Alan Mackenzie X-Primary-Address: acm@muc.de X-Spam-Score: -1.4 (-) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.4 (-) Bug fixed. -- Alan Mackenzie (Nuremberg, Germany).