From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Jason Rumney Newsgroups: gmane.emacs.bugs Subject: bug#716: Bug in buffer-swap-text Date: Tue, 23 Dec 2008 23:14:27 +0800 Message-ID: <49510053.6020805@f2s.com> References: <4950DD60.4080202@gnu.org> <4950FAF6.808@f2s.com> Reply-To: Jason Rumney , 716@emacsbugs.donarmstrong.com NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------080709070700060602090603" X-Trace: ger.gmane.org 1230046063 1207 80.91.229.12 (23 Dec 2008 15:27:43 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 23 Dec 2008 15:27:43 +0000 (UTC) Cc: Magnus Henoch , Stefan Monnier To: Jason Rumney , 716@emacsbugs.donarmstrong.com Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Dec 23 16:28:49 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 1LF9AK-0001Lz-Ng for geb-bug-gnu-emacs@m.gmane.org; Tue, 23 Dec 2008 16:27:25 +0100 Original-Received: from localhost ([127.0.0.1]:52636 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LF997-0006e9-UH for geb-bug-gnu-emacs@m.gmane.org; Tue, 23 Dec 2008 10:26:09 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LF990-0006aZ-Sp for bug-gnu-emacs@gnu.org; Tue, 23 Dec 2008 10:26:02 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LF98z-0006YA-Si for bug-gnu-emacs@gnu.org; Tue, 23 Dec 2008 10:26:02 -0500 Original-Received: from [199.232.76.173] (port=52447 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LF98z-0006XR-9X for bug-gnu-emacs@gnu.org; Tue, 23 Dec 2008 10:26:01 -0500 Original-Received: from rzlab.ucr.edu ([138.23.92.77]:36370) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1LF98y-000815-Fb for bug-gnu-emacs@gnu.org; Tue, 23 Dec 2008 10:26:01 -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 mBNFNKqE031059; Tue, 23 Dec 2008 07:23:20 -0800 Original-Received: (from debbugs@localhost) by rzlab.ucr.edu (8.13.8/8.13.8/Submit) id mBNFK6j9029633; Tue, 23 Dec 2008 07:20:06 -0800 X-Loop: owner@emacsbugs.donarmstrong.com Resent-From: Jason Rumney Original-Sender: Jason Rumney Resent-To: bug-submit-list@donarmstrong.com Resent-CC: Emacs Bugs , owner@emacsbugs.donarmstrong.com Resent-Date: Tue, 23 Dec 2008 15:20:05 +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.123004530527848 (code B ref 716); Tue, 23 Dec 2008 15:20:05 +0000 Original-Received: (at 716) by emacsbugs.donarmstrong.com; 23 Dec 2008 15:15:05 +0000 X-Spam-Bayes: score:0.5 Bayes not run. spammytokens:Tokens not available. hammytokens:Tokens not available. Original-Received: from ti-out-0910.google.com (ti-out-0910.google.com [209.85.142.185]) by rzlab.ucr.edu (8.13.8/8.13.8/Debian-3) with ESMTP id mBNFEwt1027707 for <716@emacsbugs.donarmstrong.com>; Tue, 23 Dec 2008 07:15:01 -0800 Original-Received: by ti-out-0910.google.com with SMTP id b6so1851726tic.1 for <716@emacsbugs.donarmstrong.com>; Tue, 23 Dec 2008 07:14:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:sender:message-id:date:from :user-agent:mime-version:to:cc:subject:references:in-reply-to :content-type; bh=/Zp4uDGKS2+HmEqR+9bjdgq/MtnjgKrDw8b2bt2UdTM=; b=CoUU7C8aB9EoUifI+qCAPDCAnHSToNRGckxDK7dCX2q3KOZKqkE3G1xtpX6Cst4Zjf cbDQlS/zG35V8j1xJHNHlRh1hKm8pHS1eQFOcrp2iqPC2iJwGosK/SJGc+/r35BIfwmW eLNFwedl1g46ka6yIEdv52+4yf45Arc/x3m5w= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=sender:message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type; b=CcbLBmaIDl2R15uXAq6UjzzVlwin7x+ZfrcpZRqNfI1+YWti7MMo1eY7TGHnfgpdJ5 oMPRNpHg7ARNlXB7L8tWezBS7PvnzETV/WkMjWLt56QLp+uLhH4a6EVOvf2j+4rXNbbA Eg/heUzx81ipQ30TvcrWKJxqN9DrFxUEavRus= Original-Received: by 10.110.105.5 with SMTP id d5mr7106581tic.47.1230045298091; Tue, 23 Dec 2008 07:14:58 -0800 (PST) Original-Received: from ?192.168.1.3? ([118.101.181.97]) by mx.google.com with ESMTPS id j5sm326837tid.38.2008.12.23.07.14.55 (version=TLSv1/SSLv3 cipher=RC4-MD5); Tue, 23 Dec 2008 07:14:57 -0800 (PST) User-Agent: Thunderbird 2.0.0.18 (Windows/20081105) In-Reply-To: <4950FAF6.808@f2s.com> X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 3) Resent-Date: Tue, 23 Dec 2008 10:26:01 -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:23448 Archived-At: This is a multi-part message in MIME format. --------------080709070700060602090603 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Jason Rumney wrote: > Jason Rumney wrote: >> 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: --------------080709070700060602090603 Content-Type: text/plain; name="bug716.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="bug716.diff" Index: buffer.c =================================================================== RCS file: /sources/emacs/emacs/src/buffer.c,v retrieving revision 1.575 diff -c -r1.575 buffer.c *** buffer.c 9 Dec 2008 23:08:05 -0000 1.575 --- buffer.c 23 Dec 2008 14:37:33 -0000 *************** *** 2182,2187 **** --- 2182,2192 ---- return byte_pos; } + #ifdef REL_ALLOC + extern void r_alloc_prepare_to_swap_pointers P_ ((POINTER_TYPE **, + POINTER_TYPE **)); + #endif + DEFUN ("buffer-swap-text", Fbuffer_swap_text, Sbuffer_swap_text, 1, 1, 0, doc: /* Swap the text between current buffer and BUFFER. */) *************** *** 2220,2225 **** --- 2225,2235 ---- current_buffer->field = tmp##field; \ } while (0) + #ifdef REL_ALLOC + r_alloc_prepare_to_swap_pointers (¤t_buffer->own_text.beg, + &other_buffer->own_text.beg); + #endif + swapfield (own_text, struct buffer_text); eassert (current_buffer->text == ¤t_buffer->own_text); eassert (other_buffer->text == &other_buffer->own_text); Index: ralloc.c =================================================================== RCS file: /sources/emacs/emacs/src/ralloc.c,v retrieving revision 1.69 diff -c -r1.69 ralloc.c *** ralloc.c 21 Nov 2008 12:14:07 -0000 1.69 --- ralloc.c 23 Dec 2008 14:40:52 -0000 *************** *** 1223,1228 **** --- 1223,1251 ---- #endif /* DEBUG */ + /* Swap relocatable data between two pointers. + This is used by buffer_swap_text. Since buffer_swap_text swaps the + whole text structure in one go, this function has been written to only + update the internal pointers back to the variables, ready for when the + swap is actually done. It must be called before the pointers are + swapped so that the state is consistent when find_bloc is called. */ + void + r_alloc_prepare_to_swap_pointers (p1, p2) + POINTER *p1, *p2; + { + bloc_ptr bloc1, bloc2; + bloc1 = find_bloc (p1); + bloc2 = find_bloc (p2); + if (bloc1 == NIL_BLOC || bloc2 == NIL_BLOC) + abort (); + + /* Swap internal pointers back to the variables. */ + bloc1->variable = p2; + bloc2->variable = p1; + + /* It would be cleaner to do the actual swap here too, but it would + complicate buffer_swap_text. */ + } /*********************************************************************** --------------080709070700060602090603--