From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#16433: Test case for newline cache corruption Date: Mon, 26 May 2014 22:28:22 +0300 Message-ID: <83vbssibl5.fsf@gnu.org> References: Reply-To: Eli Zaretskii NNTP-Posting-Host: plane.gmane.org X-Trace: ger.gmane.org 1401132565 21139 80.91.229.3 (26 May 2014 19:29:25 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 26 May 2014 19:29:25 +0000 (UTC) Cc: 16433@debbugs.gnu.org To: Ken Olum Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon May 26 21:29:17 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 1Wp0aC-0006Ea-Md for geb-bug-gnu-emacs@m.gmane.org; Mon, 26 May 2014 21:29:16 +0200 Original-Received: from localhost ([::1]:58204 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wp0aC-0005Zx-A0 for geb-bug-gnu-emacs@m.gmane.org; Mon, 26 May 2014 15:29:16 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:49700) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wp0a4-0005Z1-5n for bug-gnu-emacs@gnu.org; Mon, 26 May 2014 15:29:13 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Wp0Zy-0005gc-OH for bug-gnu-emacs@gnu.org; Mon, 26 May 2014 15:29:08 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:33612) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wp0Zy-0005gY-Km for bug-gnu-emacs@gnu.org; Mon, 26 May 2014 15:29:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1Wp0Zy-0007r3-1c for bug-gnu-emacs@gnu.org; Mon, 26 May 2014 15:29: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: Mon, 26 May 2014 19:29:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 16433 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: moreinfo Original-Received: via spool by 16433-submit@debbugs.gnu.org id=B16433.140113250730139 (code B ref 16433); Mon, 26 May 2014 19:29:01 +0000 Original-Received: (at 16433) by debbugs.gnu.org; 26 May 2014 19:28:27 +0000 Original-Received: from localhost ([127.0.0.1]:60722 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Wp0ZO-0007q3-QV for submit@debbugs.gnu.org; Mon, 26 May 2014 15:28:27 -0400 Original-Received: from mtaout24.012.net.il ([80.179.55.180]:34764) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Wp0ZL-0007pf-IF for 16433@debbugs.gnu.org; Mon, 26 May 2014 15:28:24 -0400 Original-Received: from conversion-daemon.mtaout24.012.net.il by mtaout24.012.net.il (HyperSendmail v2007.08) id <0N67005004C2IY00@mtaout24.012.net.il> for 16433@debbugs.gnu.org; Mon, 26 May 2014 22:25:02 +0300 (IDT) Original-Received: from HOME-C4E4A596F7 ([87.69.4.28]) by mtaout24.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0N67006PY4LQQ100@mtaout24.012.net.il>; Mon, 26 May 2014 22:25:02 +0300 (IDT) In-reply-to: X-012-Sender: halo1@inter.net.il 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:89511 Archived-At: > From: Ken Olum > Cc: 16433@debbugs.gnu.org > Date: Mon, 26 May 2014 11:29:22 -0400 > > Also, is your build optimized or not? More generally, what are the > values of system-configuration and system-configuration-options in the > build where you reproduce this? If your build options are different > from mine, especially the optimization switches, perhaps that is part > of the issue somehow. > > All I did was to download the trunk distribution and say "make". This means the build is optimized. This might get in the way when we will need to use GDB, but for now it's OK. Below please find a simple patch that adds instrumentation to the cache operations. The trace goes to the *Messages* buffer. Please apply the patch, then run your recipe, and show the trace for it. (It is best to mark the place in *Messages* where you actually start and end the recipe with some prominent string, because the newline cache is consulted _a_lot_.) Thanks. === modified file 'src/region-cache.c' --- a/src/region-cache.c 2014-05-03 08:24:51 +0000 +++ b/src/region-cache.c 2014-05-26 19:26:53 +0000 @@ -459,6 +459,15 @@ invalidate_region_cache (struct buffer *buf, struct region_cache *c, ptrdiff_t head, ptrdiff_t tail) { + char buff[1024]; + + if (c == buf->newline_cache) + { + sprintf (buff, "invalidate_region_cache (%s, %d, %d, %d)", + SSDATA (BVAR (buf, name)), + BUF_BEG (buf) + head, BUF_Z (buf) - tail, BUF_Z (buf)); + message_dolog (buff, strlen (buff), false, true); + } /* Let chead = c->beg_unchanged, and ctail = c->end_unchanged. If z-tail < beg+chead by a large amount, or @@ -474,8 +483,14 @@ > PRESERVE_THRESHOLD) || ((BUF_BEG (buf) + head) - (BUF_Z (buf) - c->end_unchanged) > PRESERVE_THRESHOLD)) - revalidate_region_cache (buf, c); - + { + revalidate_region_cache (buf, c); + if (c == buf->newline_cache) + message_dolog (" (revalidated)\n", sizeof (" (revalidated)\n") - 1, + false, true); + } + else if (c == buf->newline_cache) + message_dolog ("\n", 1, false, true); if (head < c->beg_unchanged) c->beg_unchanged = head; @@ -666,6 +681,15 @@ know_region_cache (struct buffer *buf, struct region_cache *c, ptrdiff_t start, ptrdiff_t end) { + char buff[1024]; + + if (c == buf->newline_cache) + { + sprintf (buff, "know_region_cache (%s, %d, %d, %d)\n", + SSDATA (BVAR (buf, name)), start, end, BUF_Z (buf)); + message_dolog (buff, strlen (buff), false, true); + } + revalidate_region_cache (buf, c); set_cache_region (c, start, end, 1);