From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: YAMAMOTO Mitsuharu Newsgroups: gmane.emacs.devel Subject: Re: [PATCH] XCloseDisplay already calls XrmDestroyDatabase Date: Mon, 18 May 2009 17:09:08 +0900 Organization: Faculty of Science, Chiba University Message-ID: References: <19e566510808190319r454900a7sc3b5a4e9d6d68f95@mail.gmail.com> <19e566510808200117y21e78086la6240ad72b676cd7@mail.gmail.com> <19e566510808211140n56bec8e7l7ac7d6ae156e29eb@mail.gmail.com> <87k5eataqu.fsf@cyd.mit.edu> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII X-Trace: ger.gmane.org 1242634179 26662 80.91.229.12 (18 May 2009 08:09:39 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 18 May 2009 08:09:39 +0000 (UTC) Cc: =?ISO-8859-1?Q?D=F6nmez?= , Chong Yidong , =?UTF-8?B?xLBzbWFpbCA=?=, emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon May 18 10:09:31 2009 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1M5xub-0005Qr-7Z for ged-emacs-devel@m.gmane.org; Mon, 18 May 2009 10:09:29 +0200 Original-Received: from localhost ([127.0.0.1]:57652 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1M5xua-0003JW-Ky for ged-emacs-devel@m.gmane.org; Mon, 18 May 2009 04:09:28 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1M5xuV-0003Hr-9b for emacs-devel@gnu.org; Mon, 18 May 2009 04:09:23 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1M5xuQ-00039W-5H for emacs-devel@gnu.org; Mon, 18 May 2009 04:09:22 -0400 Original-Received: from [199.232.76.173] (port=58935 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1M5xuP-00039H-W4 for emacs-devel@gnu.org; Mon, 18 May 2009 04:09:18 -0400 Original-Received: from mx20.gnu.org ([199.232.41.8]:33001) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1M5xuP-0007E9-Fv for emacs-devel@gnu.org; Mon, 18 May 2009 04:09:17 -0400 Original-Received: from ntp.math.s.chiba-u.ac.jp ([133.82.132.2] helo=mathmail.math.s.chiba-u.ac.jp) by mx20.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1M5xuM-0005vU-9y for emacs-devel@gnu.org; Mon, 18 May 2009 04:09:14 -0400 Original-Received: from church.math.s.chiba-u.ac.jp (church [133.82.132.36]) by mathmail.math.s.chiba-u.ac.jp (Postfix) with ESMTP id 9515B2C40; Mon, 18 May 2009 17:09:08 +0900 (JST) In-Reply-To: User-Agent: Wanderlust/2.14.0 (Africa) SEMI/1.14.6 (Maruoka) FLIM/1.14.8 (=?ISO-8859-4?Q?Shij=F2?=) APEL/10.6 Emacs/22.3 (sparc-sun-solaris2.8) MULE/5.0 (SAKAKI) X-Detected-Operating-System: by mx20.gnu.org: NetBSD 3.0 (DF) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:110962 Archived-At: >>>>> On Sun, 17 May 2009 17:40:50 -0400, Stefan Monnier said: >>> If we remove the XrmDestroyDatabase call unconditionally, then it >>> causes a memory leak when used with a newer libX11. But that would >>> be better than crashing when used with an older one. >> Or maybe we can dissociate the resource database from the display >> before closing it. >> #ifdef HAVE_XRMSETDATABASE >> XrmSetDatabase (dpyinfo->display, NULL); >> #else >> dpyinfo->display->db = NULL; >> #endif >> Then we can ignore the difference of libX11 at least for normal close. > Sounds OK as well. Here is a patch. If it's OK, I'd like to install it before the next pretest. YAMAMOTO Mitsuharu mituharu@math.s.chiba-u.ac.jp Index: src/xterm.c =================================================================== RCS file: /sources/emacs/emacs/src/xterm.c,v retrieving revision 1.1025 diff -c -p -r1.1025 xterm.c *** src/xterm.c 2 May 2009 20:16:58 -0000 1.1025 --- src/xterm.c 18 May 2009 08:00:51 -0000 *************** x_delete_display (dpyinfo) *** 10613,10625 **** tail->next = tail->next->next; } - /* Xt and GTK do this themselves. */ - #if ! defined (USE_X_TOOLKIT) && ! defined (USE_GTK) - #ifndef AIX /* On AIX, XCloseDisplay calls this. */ - XrmDestroyDatabase (dpyinfo->xrdb); - #endif - #endif - xfree (dpyinfo->x_id_name); xfree (dpyinfo->x_dnd_atoms); xfree (dpyinfo->color_cells); --- 10613,10618 ---- *************** x_delete_terminal (struct terminal *term *** 10740,10745 **** --- 10733,10752 ---- x_destroy_all_bitmaps (dpyinfo); XSetCloseDownMode (dpyinfo->display, DestroyAll); + /* Whether or not XCloseDisplay destroys the associated resource + database depends on the version of libX11. To avoid both + crash and memory leak, we dissociate the database from the + display and then destroy dpyinfo->xrdb ourselves. */ + #ifdef HAVE_XRMSETDATABASE + XrmSetDatabase (dpyinfo->display, NULL); + #else + dpyinfo->display->db = NULL; + #endif + /* We used to call XrmDestroyDatabase from x_delete_display, but + some older versions of libX11 crash if we call it after + closing all the displays. */ + XrmDestroyDatabase (dpyinfo->xrdb); + #ifdef USE_GTK xg_display_close (dpyinfo->display); #else