From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.bugs Subject: bug#716: Bug in buffer-swap-text Date: Tue, 23 Dec 2008 12:23:54 -0500 Message-ID: References: <4950DD60.4080202@gnu.org> <4950FAF6.808@f2s.com> <49510053.6020805@f2s.com> Reply-To: Stefan Monnier , 716@emacsbugs.donarmstrong.com NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1230054378 27843 80.91.229.12 (23 Dec 2008 17:46:18 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 23 Dec 2008 17:46:18 +0000 (UTC) Cc: Magnus Henoch , 716@emacsbugs.donarmstrong.com To: Jason Rumney Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Dec 23 18:47:24 2008 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1LFBLk-0004NH-F2 for geb-bug-gnu-emacs@m.gmane.org; Tue, 23 Dec 2008 18:47:20 +0100 Original-Received: from localhost ([127.0.0.1]:49167 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LFBKX-0003h6-QU for geb-bug-gnu-emacs@m.gmane.org; Tue, 23 Dec 2008 12:46:05 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LFBKT-0003ga-Im for bug-gnu-emacs@gnu.org; Tue, 23 Dec 2008 12:46:01 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LFBKR-0003fn-Eo for bug-gnu-emacs@gnu.org; Tue, 23 Dec 2008 12:46:00 -0500 Original-Received: from [199.232.76.173] (port=35912 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LFBKR-0003fi-AI for bug-gnu-emacs@gnu.org; Tue, 23 Dec 2008 12:45:59 -0500 Original-Received: from rzlab.ucr.edu ([138.23.92.77]:42356) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1LFBKQ-0004Cn-Qj for bug-gnu-emacs@gnu.org; Tue, 23 Dec 2008 12:45:59 -0500 Original-Received: from rzlab.ucr.edu (rzlab.ucr.edu [127.0.0.1]) by rzlab.ucr.edu (8.13.8/8.13.8/Debian-3) with ESMTP id mBNHhKoG014183; Tue, 23 Dec 2008 09:43:20 -0800 Original-Received: (from debbugs@localhost) by rzlab.ucr.edu (8.13.8/8.13.8/Submit) id mBNHU3X4009337; Tue, 23 Dec 2008 09:30:03 -0800 X-Loop: owner@emacsbugs.donarmstrong.com Resent-From: Stefan Monnier Resent-To: bug-submit-list@donarmstrong.com Resent-CC: Emacs Bugs , owner@emacsbugs.donarmstrong.com Resent-Date: Tue, 23 Dec 2008 17:30:03 +0000 Resent-Message-ID: Resent-Sender: owner@emacsbugs.donarmstrong.com X-Emacs-PR-Message: followup 716 X-Emacs-PR-Package: emacs,w32 X-Emacs-PR-Keywords: Original-Received: via spool by 716-submit@emacsbugs.donarmstrong.com id=B716.12300530447595 (code B ref 716); Tue, 23 Dec 2008 17:30:03 +0000 Original-Received: (at 716) by emacsbugs.donarmstrong.com; 23 Dec 2008 17:24:04 +0000 X-Spam-Bayes: score:0.5 Bayes not run. spammytokens:Tokens not available. hammytokens:Tokens not available. Original-Received: from ironport2-out.teksavvy.com (ironport2-out.pppoe.ca [206.248.154.182]) by rzlab.ucr.edu (8.13.8/8.13.8/Debian-3) with ESMTP id mBNHO0Tk007564 for <716@emacsbugs.donarmstrong.com>; Tue, 23 Dec 2008 09:24:02 -0800 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApsEAAqtUElMCqh5/2dsb2JhbACBbL1/WJFrhkOBYg X-IronPort-AV: E=Sophos;i="4.36,272,1228107600"; d="scan'208";a="31419873" Original-Received: from 76-10-168-121.dsl.teksavvy.com (HELO pastel.home) ([76.10.168.121]) by ironport2-out.teksavvy.com with ESMTP; 23 Dec 2008 12:23:54 -0500 Original-Received: by pastel.home (Postfix, from userid 20848) id DE6BA8780; Tue, 23 Dec 2008 12:23:54 -0500 (EST) In-Reply-To: <49510053.6020805@f2s.com> (Jason Rumney's message of "Tue, 23 Dec 2008 23:14:27 +0800") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 3) Resent-Date: Tue, 23 Dec 2008 12:46:00 -0500 X-BeenThere: bug-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:23453 Archived-At: >>> One possible variable here is the way that buffer space is allocated. On >>> Windows, it seems REL_ALLOC is defined. I presume GNU/Linux defines >>> USE_MMAP_FOR_BUFFERS which would cause it to take a different code path >>> around the point where we see a crash on Windows, and as Magnus Henoch >>> saw on NetBSD/powerpc also (though we don't have a stack trace for that >>> crash, so can't tell for sure it is crashing in the same place). >> The following patch seems to fix the problem, does it look correct to >> others who might understand ralloc.c and buffer_swap_text better than >> I do? > Sorry, once more with context: Your analysis sounds right, thank you. I'd suggest to use another r_alloc primitve, something like r_alloc_reset_variable, so you could do r_alloc_reset_variable(¤t_buffer->own_text.beg); r_alloc_reset_variable(&other_buffer->own_text.beg); after the swap. It could use the untested patch below. WDYT? Stefan === modified file 'src/ralloc.c' --- src/ralloc.c 2008-11-21 19:14:07 +0000 +++ src/ralloc.c 2008-12-23 17:23:02 +0000 @@ -402,7 +402,7 @@ while (p != NIL_BLOC) { - if (p->variable == ptr && p->data == *ptr) + if (p->data == *ptr) return p; p = p->next; @@ -1223,6 +1223,15 @@ #endif /* DEBUG */ +/* Change the variable of the bloc pointed from `p' to be `p'. */ +void r_alloc_reset_variable (POINTER *p) +{ + bloc_ptr bloc = find_bloc (p); + if (bloc == NIL_BLOC) + abort (); + bloc->variable = p; +} + /***********************************************************************