Subject: bug#1696: 23.0.60; Crash in XFreeColors

From: YAMAMOTO Mitsuharu <[email-masked]>
Date: Thu, 07 May 2009 19:28:54 +0900

>>>>> On Wed, 08 Apr 2009 19:38:33 +0200, Markus Triska <[email-masked]> said:

>> I haven't been able to reproduce this at all, using a GTK build
>> (which I assume is what you are using).  Do you still see the
>> problem occurring?

> Yes, the problem only occurs with GTK, and I still see it with the
> latest Emacs CVS version (both locally and via SSH), on Ubuntu
> jaunty.  Sometimes Emacs loops (as described in etc/PROBLEMS) if I
> try to reproduce it, but at other times it still crashes. I will set
> up an SSH account for you if you want to reproduce it yourself on
> this machine.

Could you try adding the following lines just before the call to
XftFontMatch in xftfont.c?  This is not intended as a final solution,
but just to see if my conjecture is correct.

  {
    int event_base, error_base;
    XRenderQueryExtension (display, &event_base, &error_base);
  }

If this works, then the cause of the problem is the order of adding
X11 extensions by libXft and libXrender (indeed nothing to do with
GTK+).  They both set hooks to XCloseDisplay via XESetCloseDisplay.
These hooks are called in LIFO way with respect to the addition of the
extensions.  If the extension for libXft is added before the one for
libXrender, then that leads to a problematic situation that libXft's
CloseDisplay hook is called later and it adds libXrender's hook again
and causes inconsistency in its internal states.

				     YAMAMOTO Mitsuharu
				[email-masked]