all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: Dönmez <ismail@namtrac.org>,
	"Chong Yidong" <cyd@stupidchicken.com>,
	emacs-devel@gnu.org
Subject: Re: [PATCH] XCloseDisplay already calls XrmDestroyDatabase
Date: Mon, 18 May 2009 17:09:08 +0900	[thread overview]
Message-ID: <wld4a6n87v.wl%mituharu@math.s.chiba-u.ac.jp> (raw)
In-Reply-To: <jwvvdnzbe7u.fsf-monnier+emacs@gnu.org>

>>>>> On Sun, 17 May 2009 17:40:50 -0400, Stefan Monnier <monnier@iro.umontreal.ca> 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




  reply	other threads:[~2009-05-18  8:09 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-19 10:19 [PATCH] XCloseDisplay already calls XrmDestroyDatabase İsmail Dönmez
2008-08-20  8:17 ` İsmail Dönmez
2008-08-21 18:40   ` İsmail Dönmez
2008-08-21 19:43     ` Chong Yidong
2008-07-20 20:51       ` bug#581: 23.0.60; OSX: server crashes when quitting emacsclient Markus Triska
     [not found]         ` <handler.581.B.121658711315039.ack@emacsbugs.donarmstrong.com>
2008-08-08 12:08           ` bug#581: Acknowledgement (23.0.60; OSX: server crashes when quitting emacsclient) Markus Triska
2008-08-09  1:02             ` OFFICE ZERO
2008-08-09 14:12             ` OFFICE ZERO
2008-08-21 19:50         ` bug#581: marked as done " Emacs bug Tracking System
2009-05-13  3:27       ` [PATCH] XCloseDisplay already calls XrmDestroyDatabase YAMAMOTO Mitsuharu
2009-05-13 23:48         ` YAMAMOTO Mitsuharu
2009-05-17 21:40           ` Stefan Monnier
2009-05-18  8:09             ` YAMAMOTO Mitsuharu [this message]
2009-05-18 13:29               ` Chong Yidong
2009-05-17 21:40         ` Stefan Monnier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=wld4a6n87v.wl%mituharu@math.s.chiba-u.ac.jp \
    --to=mituharu@math.s.chiba-u.ac.jp \
    --cc=cyd@stupidchicken.com \
    --cc=emacs-devel@gnu.org \
    --cc=ismail@namtrac.org \
    --cc=monnier@iro.umontreal.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.