all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Ken Raeburn <raeburn@raeburn.org>
To: Tino Calancha <tino.calancha@gmail.com>
Cc: 25247@debbugs.gnu.org
Subject: bug#25247: 26.0.50; Concurrency crashes with XLib
Date: Fri, 30 Dec 2016 02:19:29 -0500	[thread overview]
Message-ID: <06A3A860-6057-4932-A654-F7663B432DEB@raeburn.org> (raw)
In-Reply-To: <87shp7j790.fsf_-_@gmail.com>

I’m still looking through yesterday’s set of stack traces, but in my experimenting I was able to reproduce some crashes once I noticed my build had automatically configured itself for the Lucid toolkit when I didn’t have GTK installed.  I fixed that, and got crashes fairly often with Tino’s recipe.

In the cases I’ve hit, it appears that Xlib is getting called via Glib callbacks with lots of GTK, GDK, and Cairo library frames on the stack, in one of the threads calling xg_select, and in the main thread, redisplay is calling into Xlib (e.g., XSetClipRectangles) to draw text on the screen.  If I add a call to XInitThreads, the crashes stop.  However, it may not be enough — Tino’s basic test works, but if I resize the window Emacs may stop responding to X input, for reasons I haven’t tracked down yet.

Tino, could you please try the patch below and see if it fixes some of the crashes you’re seeing?

As for Eli’s comments about moving the locking code into xgselect.c, I think that’s going to be needed.  I’ve got a patch in my private repository from a while back, waiting for some cleanup, that started doing something like that, but didn’t cover the Mac ns_select version because I’m unfamiliar with that code.  The unblock_input code accesses global variables like interrupt_input_blocked and pending_signals, but it can be called from xg_select without holding the global lock.  I think I also hit a case where current_thread was null due to the exiting of the “current” Lisp thread, and something called via unblock_input tried to use it to access one of the now-per-Lisp-thread variables.

Ken


commit e333e1ab48a0c938aba18ec22b3d94273078a982
Author: Ken Raeburn <raeburn@raeburn.org>
Date:   Thu Dec 29 20:56:31 2016 -0500

    Initialize thread support for Xlib.
    
    * src/xterm.c (x_initialize) [THREADS_ENABLED]: Call XInitThreads
    before doing anything else with X.

diff --git a/src/xterm.c b/src/xterm.c
index bdc21e6de0..6f79a7d094 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -12762,6 +12762,13 @@ x_initialize (void)
   /* Try to use interrupt input; if we can't, then start polling.  */
   Fset_input_interrupt_mode (Qt);
 
+#ifdef THREADS_ENABLED
+  /* This must be called before any other Xlib routines.  */
+  if (XInitThreads () == 0)
+    fprintf (stderr,
+            "Warning: An error occurred initializing X11 thread support!\n");
+#endif
+
 #ifdef USE_X_TOOLKIT
   XtToolkitInitialize ();
 






  parent reply	other threads:[~2016-12-30  7:19 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-22 10:20 bug#25247: 26.0.50; Concurrency crashes Tino Calancha
2016-12-22 17:28 ` Eli Zaretskii
2016-12-23  3:34   ` Tino Calancha
2016-12-23  8:34     ` Eli Zaretskii
2016-12-23 11:32       ` Tino Calancha
2016-12-23 14:14         ` Eli Zaretskii
2016-12-29 11:37           ` bug#25247: 26.0.50; Concurrency crashes with XLib Tino Calancha
2016-12-29 17:44             ` Eli Zaretskii
2016-12-30  3:13               ` Tino Calancha
2016-12-30  7:19             ` Ken Raeburn [this message]
2016-12-30  8:37               ` Eli Zaretskii
2016-12-30  9:41                 ` Eli Zaretskii
2016-12-30 10:30                   ` Elias Mårtenson
2016-12-30 11:05                     ` Eli Zaretskii
2016-12-30 11:21                       ` Elias Mårtenson
2016-12-30 18:54                         ` Eli Zaretskii
2016-12-30 20:40                           ` Eli Zaretskii
2016-12-31 11:05                         ` Eli Zaretskii
2016-12-31 15:34                           ` Elias Mårtenson
2016-12-31 15:51                             ` Eli Zaretskii
2016-12-31 16:24                               ` Elias Mårtenson
2016-12-31 17:18                                 ` Eli Zaretskii
2016-12-31 17:28                                   ` Elias Mårtenson
2016-12-31 18:06                                     ` Eli Zaretskii
2016-12-31 18:16                                       ` Elias Mårtenson
2016-12-31 18:29                                         ` Eli Zaretskii
2016-12-31 18:38                                           ` Eli Zaretskii
2016-12-30 13:45                   ` Tino Calancha
2016-12-30 16:57                     ` Eli Zaretskii
2017-01-06  0:03                       ` npostavs
2017-01-06  7:48                         ` Eli Zaretskii
2016-12-23  9:34   ` bug#25247: 26.0.50; Concurrency crashes Ken Raeburn
2016-12-23 10:04     ` Eli Zaretskii

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=06A3A860-6057-4932-A654-F7663B432DEB@raeburn.org \
    --to=raeburn@raeburn.org \
    --cc=25247@debbugs.gnu.org \
    --cc=tino.calancha@gmail.com \
    /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.