From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Ken Raeburn Newsgroups: gmane.emacs.bugs Subject: bug#25247: 26.0.50; Concurrency crashes with XLib Date: Fri, 30 Dec 2016 02:19:29 -0500 Message-ID: <06A3A860-6057-4932-A654-F7663B432DEB@raeburn.org> References: <87bmw4w9i2.fsf@gmail.com> <83a8bn27qn.fsf@gnu.org> <87h95vmi7b.fsf@gmail.com> <83wperyrgj.fsf@gnu.org> <878tr651a9.fsf@gmail.com> <83mvfmzq9n.fsf@gnu.org> <87shp7j790.fsf_-_@gmail.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 (Mac OS X Mail 9.3 \(3124\)) Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1483082413 26833 195.159.176.226 (30 Dec 2016 07:20:13 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 30 Dec 2016 07:20:13 +0000 (UTC) Cc: 25247@debbugs.gnu.org To: Tino Calancha Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Dec 30 08:20:09 2016 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cMrTz-0006At-Oa for geb-bug-gnu-emacs@m.gmane.org; Fri, 30 Dec 2016 08:20:07 +0100 Original-Received: from localhost ([::1]:38704 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cMrU4-0002w8-CX for geb-bug-gnu-emacs@m.gmane.org; Fri, 30 Dec 2016 02:20:12 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:46099) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cMrTx-0002uV-SJ for bug-gnu-emacs@gnu.org; Fri, 30 Dec 2016 02:20:06 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cMrTu-0000HN-MF for bug-gnu-emacs@gnu.org; Fri, 30 Dec 2016 02:20:05 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:44123) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cMrTu-0000HH-JX for bug-gnu-emacs@gnu.org; Fri, 30 Dec 2016 02:20:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1cMrTu-0006ML-8l for bug-gnu-emacs@gnu.org; Fri, 30 Dec 2016 02:20:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Ken Raeburn Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 30 Dec 2016 07:20:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 25247 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 25247-submit@debbugs.gnu.org id=B25247.148308237824411 (code B ref 25247); Fri, 30 Dec 2016 07:20:02 +0000 Original-Received: (at 25247) by debbugs.gnu.org; 30 Dec 2016 07:19:38 +0000 Original-Received: from localhost ([127.0.0.1]:59522 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cMrTW-0006Le-LE for submit@debbugs.gnu.org; Fri, 30 Dec 2016 02:19:38 -0500 Original-Received: from mail-qk0-f193.google.com ([209.85.220.193]:32807) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cMrTV-0006LR-4J for 25247@debbugs.gnu.org; Fri, 30 Dec 2016 02:19:37 -0500 Original-Received: by mail-qk0-f193.google.com with SMTP id n21so37892719qka.0 for <25247@debbugs.gnu.org>; Thu, 29 Dec 2016 23:19:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raeburn-org.20150623.gappssmtp.com; s=20150623; h=subject:mime-version:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=+Yl+6yrFuqhsNjtRSf9rqbqOI+8Rn91AvNfERHYZroc=; b=hPT//s+xOKejmcZIZ7PFyor6B9q69ds9etyg+HrcT1Wc93v5PhNMbnxqI5I5B6jwa0 MTj2v8+cZumHuEbU5BVK///+yv5Du3PjLQub/5OUUkwYAVdvOgBMZJy+on4NLdYBGTva 8DR1odbnBSNj74onhKyCQoxsrjtEYWnuYq7pWadQg42eFp/Qr+mWE4W+6QNsqCefk9po erWGAM9c6g1aM2kYNy64wNesn3TcF6g8DUe991nwaYfRNvWQNxZHwoplhoc04my9y69R hOua/Azx8zri89VqbcZ7y/D6KeNxGGtgS48ENQP7H7cPe8YF/XOh+qvYC5iElLlnTcTE Ff+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:mime-version:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=+Yl+6yrFuqhsNjtRSf9rqbqOI+8Rn91AvNfERHYZroc=; b=RLZ+xaowB3Y7RbjiMM+yC9vyawHI9vyLTZ9j3dqml8OpKQDW0llz073s4uuV5NEjBg D6wD2SwFIeKlXnrr/iZcl0TZnJoj84pMr//3gx7QUeSIXUFdeyBZHVPnkK3pvOaJTsFL L+3CBS1CZ49ls3pwbfpSCjSUn7dLc9no8mjZ1zTvQ7nF3aobjetcFYVOPRM7KnNKyqF+ e1RlZiGjd04q0ObeWBpC9t8hzTnssUXzIP0vmtP6iAQG/QbUYh14+w4b9PtwZ2lgQm3I xN4iW9MO1EwBDLEmwq+3a0QSeiOLlEFbWMjYx4ZjttpXT5XXNzSdEHppW81P5MOpB1RF f3iw== X-Gm-Message-State: AIkVDXI/XmBQbOnKxlV2cmMJNewAv1qb1xz+WV1W+P8RvKtphfX1pcmH8R+gfCqJGttwHw== X-Received: by 10.55.135.69 with SMTP id j66mr43791107qkd.31.1483082371594; Thu, 29 Dec 2016 23:19:31 -0800 (PST) Original-Received: from [192.168.23.52] (c-50-138-183-136.hsd1.ma.comcast.net. [50.138.183.136]) by smtp.gmail.com with ESMTPSA id 29sm34702433qtu.21.2016.12.29.23.19.30 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 29 Dec 2016 23:19:30 -0800 (PST) In-Reply-To: <87shp7j790.fsf_-_@gmail.com> X-Mailer: Apple Mail (2.3124) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:127571 Archived-At: I=E2=80=99m still looking through yesterday=E2=80=99s 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=E2=80=99t have GTK installed. I fixed that, = and got crashes fairly often with Tino=E2=80=99s recipe. In the cases I=E2=80=99ve 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 =E2=80=94 Tino=E2=80=99s basic test = works, but if I resize the window Emacs may stop responding to X input, = for reasons I haven=E2=80=99t tracked down yet. Tino, could you please try the patch below and see if it fixes some of = the crashes you=E2=80=99re seeing? As for Eli=E2=80=99s comments about moving the locking code into = xgselect.c, I think that=E2=80=99s going to be needed. I=E2=80=99ve got = a patch in my private repository from a while back, waiting for some = cleanup, that started doing something like that, but didn=E2=80=99t = cover the Mac ns_select version because I=E2=80=99m 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 =E2=80=9Ccurrent=E2= =80=9D 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 Date: Thu Dec 29 20:56:31 2016 -0500 Initialize thread support for Xlib. =20 * 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); =20 +#ifdef THREADS_ENABLED + /* This must be called before any other Xlib routines. */ + if (XInitThreads () =3D=3D 0) + fprintf (stderr, + "Warning: An error occurred initializing X11 thread = support!\n"); +#endif + #ifdef USE_X_TOOLKIT XtToolkitInitialize (); =20