From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: YAMAMOTO Mitsuharu Newsgroups: gmane.emacs.bugs Subject: bug#3399: Crash in multi-TTY mode Date: Wed, 27 May 2009 17:27:05 +0900 Organization: Faculty of Science, Chiba University Message-ID: References: <8369-76746@sneakemail.com> Reply-To: YAMAMOTO Mitsuharu , 3399@emacsbugs.donarmstrong.com 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 1243414180 11948 80.91.229.12 (27 May 2009 08:49:40 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 27 May 2009 08:49:40 +0000 (UTC) To: Shannon Jones , 3399@emacsbugs.donarmstrong.com Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed May 27 10:49:37 2009 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 1M9EpE-0007Ba-R2 for geb-bug-gnu-emacs@m.gmane.org; Wed, 27 May 2009 10:49:32 +0200 Original-Received: from localhost ([127.0.0.1]:38922 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1M9EpE-0000Oz-DW for geb-bug-gnu-emacs@m.gmane.org; Wed, 27 May 2009 04:49:28 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1M9Ep7-0000NG-JL for bug-gnu-emacs@gnu.org; Wed, 27 May 2009 04:49:21 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1M9Ep2-0000LN-Cg for bug-gnu-emacs@gnu.org; Wed, 27 May 2009 04:49:20 -0400 Original-Received: from [199.232.76.173] (port=37427 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1M9Ep1-0000LB-R7 for bug-gnu-emacs@gnu.org; Wed, 27 May 2009 04:49:16 -0400 Original-Received: from rzlab.ucr.edu ([138.23.92.77]:42468) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1M9Ep0-0004Ur-KZ for bug-gnu-emacs@gnu.org; Wed, 27 May 2009 04:49:15 -0400 Original-Received: from rzlab.ucr.edu (rzlab.ucr.edu [127.0.0.1]) by rzlab.ucr.edu (8.14.3/8.14.3/Debian-5) with ESMTP id n4R8nCRX008832; Wed, 27 May 2009 01:49:12 -0700 Original-Received: (from debbugs@localhost) by rzlab.ucr.edu (8.14.3/8.14.3/Submit) id n4R8Z40A006920; Wed, 27 May 2009 01:35:04 -0700 X-Loop: owner@emacsbugs.donarmstrong.com Resent-From: YAMAMOTO Mitsuharu Resent-To: bug-submit-list@donarmstrong.com Resent-CC: Emacs Bugs Resent-Date: Wed, 27 May 2009 08:35:04 +0000 Resent-Message-ID: Resent-Sender: owner@emacsbugs.donarmstrong.com X-Emacs-PR-Message: followup 3399 X-Emacs-PR-Package: emacs X-Emacs-PR-Keywords: Original-Received: via spool by 3399-submit@emacsbugs.donarmstrong.com id=B3399.12434128326143 (code B ref 3399); Wed, 27 May 2009 08:35:04 +0000 Original-Received: (at 3399) by emacsbugs.donarmstrong.com; 27 May 2009 08:27:12 +0000 X-Spam-Bayes: score:0.5 Bayes not run. spammytokens:Tokens not available. hammytokens:Tokens not available. Original-Received: from mathmail.math.s.chiba-u.ac.jp (ntp.math.s.chiba-u.ac.jp [133.82.132.2]) by rzlab.ucr.edu (8.14.3/8.14.3/Debian-5) with ESMTP id n4R8R7QZ006138 for <3399@emacsbugs.donarmstrong.com>; Wed, 27 May 2009 01:27:08 -0700 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 ABA412C40; Wed, 27 May 2009 17:27:05 +0900 (JST) In-Reply-To: <8369-76746@sneakemail.com> User-Agent: Wanderlust/2.14.0 (Africa) SEMI/1.14.6 (Maruoka) FLIM/1.14.8 =?UTF-8?Q?(Shij=C5=8D)?= APEL/10.6 Emacs/22.3 (sparc-sun-solaris2.8) MULE/5.0 (SAKAKI) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 3) Resent-Date: Wed, 27 May 2009 04:49:20 -0400 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:28226 Archived-At: >>>>> On 27 May 2009 02:44:23 -0000, "Shannon Jones" said: > I'm almost embarrassed to report this, since it's rather strange and > most likely unique to my setup. Still, it involves a crash so I > thought it would be worthwhile to see if anyone else can reproduce > it. I could reproduce it on GTK+/Mac OS X with the following steps. $ emacs -nw -Q M-x server-start RET $ emacsclient -c C-x 5 0 (on the X11 frame) The problematic scenario is: 1. XGetDefault is called in several GTK+ initialization steps. It sets the XlibDisplayDfltRMDB bit in dpy->flags but dpy->db remains to be NULL in some cases (InitDefaults may return NULL). GetDflt.c (libX11-1.2.1): char * XGetDefault( Display *dpy, /* display for defaults.... */ char _Xconst *prog, /* name of program for option */ register _Xconst char *name) /* name of option program wants */ { /* to get, for example, "font" */ : /* * see if database has ever been initialized. Lookups can be done * without locks held. */ LockDisplay(dpy); if (dpy->db == NULL) { dpy->db = InitDefaults(dpy); dpy->flags |= XlibDisplayDfltRMDB; } UnlockDisplay(dpy); : } 2. x_term_init calls XrmSetDatabase, but it doesn't reset the XlibDisplayDfltRMDB bit if display->db is NULL. As a result, display->db holds a new database but XlibDisplayDfltRMDB is still set. Xrm.c (libX11-1.2.1): void XrmSetDatabase( Display *display, XrmDatabase database) { LockDisplay(display); /* destroy database if set up imlicitely by XGetDefault() */ if (display->db && (display->flags & XlibDisplayDfltRMDB)) { XrmDestroyDatabase(display->db); display->flags &= ~XlibDisplayDfltRMDB; } display->db = database; UnlockDisplay(display); } 3. x_delete_terminal does XrmSetDatabase(dpyinfo->display, NULL) to dissociate the database from the display. Because XlibDisplayDfltRMDB is set, it destroys the database to be dissociated. 4. x_delete_terminal then calls XrmSetDatabase and destroys the dissociated database again. This causes crash. I think this a bug in libX11. It should either 1) not set XlibDisplayDfltRMDB in XGetDefault unless dpy->db becomes non-NULL or 2) reset XlibDisplayDfltRMDB in XrmSetDatabase even if the previous database is NULL. Below is a possible workaround. Unfortunately, we need to touch some X11 internal data structures. 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.1026 diff -c -p -r1.1026 xterm.c *** src/xterm.c 19 May 2009 00:26:46 -0000 1.1026 --- src/xterm.c 27 May 2009 07:59:20 -0000 *************** along with GNU Emacs. If not, see display, xrm_option, resource_name, EMACS_CLASS); + /* This is a workaround for a bug in some versions of libX11. + XGetDefault may set XlibDisplayDfltRMDB (1L << 7) in dpy->flags + (dpyinfo->display->private16) even when dpy->db + (dpyinfo->display->db) remains to be NULL, and XrmSetDatabase + doesn't clear the flag if dpy->db is NULL. This causes crash in + the XrmDestroyDatabase call from x_delete_terminal because the + preceding XrmSetDatabase call destroys the associated database + because of the XlibDisplayDfltRMDB flag. */ + if (dpyinfo->display->db == NULL) + dpyinfo->display->private16 &= ~(1L << 7); #ifdef HAVE_XRMSETDATABASE XrmSetDatabase (dpyinfo->display, xrdb); #else