From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: Killing a frame sometimes kills emacs Date: Thu, 17 Nov 2011 21:05:14 -0500 Message-ID: References: <87d3flnxoo.fsf@thinkpad.tsdh.de> <83fwkhdld0.fsf@gnu.org> <871uw04lr9.fsf@thinkpad.tsdh.de> <87sjog35jj.fsf@thinkpad.tsdh.de> <4E5F7ECD.9060601@swipnet.se> <838vq8e0x5.fsf@gnu.org> <87sjn03tzx.fsf@thinkpad.tsdh.de> <87sjmzbmvv.fsf@thinkpad.tsdh.de> <87vcrvm0dr.fsf@stupidchicken.com> <87aa96ogb3.fsf@thinkpad.tsdh.de> <8762ijjbzu.fsf@tsdh.uni-koblenz.de> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1321581931 30621 80.91.229.12 (18 Nov 2011 02:05:31 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 18 Nov 2011 02:05:31 +0000 (UTC) Cc: Chong Yidong , emacs-devel@gnu.org, schwab@linux-m68k.org, James Cloos , Eli Zaretskii , "Jan D." , Ulrich Mueller To: Tassilo Horn Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Nov 18 03:05:24 2011 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1RRDpU-0005ax-CR for ged-emacs-devel@m.gmane.org; Fri, 18 Nov 2011 03:05:24 +0100 Original-Received: from localhost ([::1]:48993 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RRDpT-00061t-Lc for ged-emacs-devel@m.gmane.org; Thu, 17 Nov 2011 21:05:23 -0500 Original-Received: from eggs.gnu.org ([140.186.70.92]:53276) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RRDpR-00061o-Dj for emacs-devel@gnu.org; Thu, 17 Nov 2011 21:05:22 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RRDpP-0000lo-NJ for emacs-devel@gnu.org; Thu, 17 Nov 2011 21:05:21 -0500 Original-Received: from ironport2-out.teksavvy.com ([206.248.154.181]:51876) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RRDpO-0000lU-Ba; Thu, 17 Nov 2011 21:05:18 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Av0EABu8xU5MCqs//2dsb2JhbABCqkKBBoFyAQEEAScvIwULCzQSFBgNJBMZAYdotkyKFwSIFZlwhEo X-IronPort-AV: E=Sophos;i="4.69,530,1315195200"; d="scan'208";a="148434302" Original-Received: from 76-10-171-63.dsl.teksavvy.com (HELO ceviche.home) ([76.10.171.63]) by ironport2-out.teksavvy.com with ESMTP/TLS/ADH-AES256-SHA; 17 Nov 2011 21:05:15 -0500 Original-Received: by ceviche.home (Postfix, from userid 20848) id 4AFEF660DC; Thu, 17 Nov 2011 21:05:14 -0500 (EST) In-Reply-To: <8762ijjbzu.fsf@tsdh.uni-koblenz.de> (Tassilo Horn's message of "Thu, 17 Nov 2011 11:10:13 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.91 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 206.248.154.181 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:146084 Archived-At: > I did that by using the patch below for about one month. Since then, > the crashes I had are gone, and working with multiple emacs X frames is > fun again. Should I go ahead and commit? Good news, thanks. > --8<---------------cut here---------------start------------->8--- > === modified file 'src/frame.c' > --- src/frame.c 2011-11-17 09:09:20 +0000 > +++ src/frame.c 2011-11-17 10:05:11 +0000 > @@ -1358,7 +1358,11 @@ > /* If needed, delete the terminal that this frame was on. > (This must be done after the frame is killed.) */ > - terminal->reference_count--; > + > + // FIXME: Deleting the terminal crashes emacs because of a GTK > + // bug. See the thread starting with <87d3flnxoo.fsf@thinkpad.tsdh.de> > + // on emacs-devel. > + // terminal->reference_count--; > if (terminal->reference_count == 0) > { > Lisp_Object tmp; > --8<---------------cut here---------------end--------------->8--- To avoid the risk of reaching 0 via wrap-around (yes, I know that creating a billion frames in the life of a single session is unlikely, but still), you could do: /* If needed, delete the terminal that this frame was on. (This must be done after the frame is killed.) */ terminal->reference_count--; #ifdef USE_GTK /* ... (Use C-style not C++ style comments) ... */ if (terminal->reference_count == 0 && terminal->type == output_x_window) terminal->reference_count = 1; #endif if (terminal->reference_count == 0) { Lisp_Object tmp; Alternatively you could get the same result by changing the code that initializes terminal->reference_count so that it starts at 1 rather than at 0. Stefan