From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#25172: 26.0.50; Concurrency feature, sit-for doesn't work (crashing and unexpected behaviour) Date: Mon, 12 Dec 2016 19:37:19 +0200 Message-ID: <838trlcals.fsf@gnu.org> References: <838trme4jr.fsf@gnu.org> Reply-To: Eli Zaretskii NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: blaine.gmane.org 1481565758 7956 195.159.176.226 (12 Dec 2016 18:02:38 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 12 Dec 2016 18:02:38 +0000 (UTC) Cc: 25172@debbugs.gnu.org, clement.pit@gmail.com To: Elias =?UTF-8?Q?M=C3=A5rtenson?= Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Dec 12 19:02:30 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 1cGUvm-0000k4-1G for geb-bug-gnu-emacs@m.gmane.org; Mon, 12 Dec 2016 19:02:30 +0100 Original-Received: from localhost ([::1]:60417 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cGUvq-0001te-Av for geb-bug-gnu-emacs@m.gmane.org; Mon, 12 Dec 2016 13:02:34 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:44500) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cGUX9-0007VU-Lh for bug-gnu-emacs@gnu.org; Mon, 12 Dec 2016 12:37:04 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cGUX8-0002fN-J4 for bug-gnu-emacs@gnu.org; Mon, 12 Dec 2016 12:37:03 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:52323) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cGUX8-0002fD-FP for bug-gnu-emacs@gnu.org; Mon, 12 Dec 2016 12:37:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1cGUX8-00033P-9Z for bug-gnu-emacs@gnu.org; Mon, 12 Dec 2016 12:37:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 12 Dec 2016 17:37:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 25172 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 25172-submit@debbugs.gnu.org id=B25172.148156421411723 (code B ref 25172); Mon, 12 Dec 2016 17:37:02 +0000 Original-Received: (at 25172) by debbugs.gnu.org; 12 Dec 2016 17:36:54 +0000 Original-Received: from localhost ([127.0.0.1]:39489 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cGUX0-00032z-4k for submit@debbugs.gnu.org; Mon, 12 Dec 2016 12:36:54 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:53311) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cGUWz-00032m-3c for 25172@debbugs.gnu.org; Mon, 12 Dec 2016 12:36:53 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cGUWo-0002W0-PL for 25172@debbugs.gnu.org; Mon, 12 Dec 2016 12:36:47 -0500 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:60458) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cGUWo-0002Vq-Li; Mon, 12 Dec 2016 12:36:42 -0500 Original-Received: from 84.94.185.246.cable.012.net.il ([84.94.185.246]:4756 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1cGUWn-0003j7-Ti; Mon, 12 Dec 2016 12:36:42 -0500 In-reply-to: (message from Elias =?UTF-8?Q?M=C3=A5rtenson?= on Mon, 12 Dec 2016 12:50:24 +0800) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] 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:126925 Archived-At: > From: Elias MÃ¥rtenson > Date: Mon, 12 Dec 2016 12:50:24 +0800 > Cc: Eli Zaretskii , 25172@debbugs.gnu.org > > I tried with the latest version (a92a027d58cb4df5bb6c7e3c546a72183a192f45) > and I'm still getting the same error. > > The stack trace is as follows: > [...] > #34 0x0000000000578a22 in emacs_abort () at sysdep.c:2342 > #35 0x0000000000564247 in unblock_input_to (level=-1) at keyboard.c:7167 > #36 0x000000000056425e in unblock_input () at keyboard.c:7183 > #37 0x000000000069c5e4 in xg_select (fds_lim=15, rfds=0x7fffe59e19a0, > wfds=0x7fffe59e1920, efds=0x0, timeout=0x7fffe59e1900, sigmask=0x0) at > xgselect.c:162 xg_select uses block_input/unblock_input, something other *select implementations used by Emacs don't do (as those others are system APIs). block_input/unblock_input manipulate a global variable that is not incremented and decremented atomically, so it's fundamentally thread-unsafe. Moreover, some places in Emacs reset that global variable to zero (although I don't believe those places are part of your scenario). The above is especially important because the calls to the *select functions are about the only place in Emacs where several threads can run in parallel, because they are called by thread_select like this: release_global_lock (); sa->result = (sa->func) (sa->max_fds, sa->rfds, sa->wfds, sa->efds, sa->timeout, sa->sigmask); acquire_global_lock (self); So between the call to release_global_lock, which allows another thread to grab the lock, and the subsequent call to acquire_global_lock several threads could run and more or less simultaneously call the *select function. If that function is xg_select, these threads might step on each other's toes by calling block_input/unblock_input in parallel. This could easily cause the global variable to become negative, which then causes the above abort. Long story short, could you please try removing the calls to block_input/unblock_input from xgselect.c, and see if that solves these crashes? (These calls were introduced to fix a rare and elusive bug, but I don't think you will see that bug unless you do what that bug's recipe calls for. And anyway, this removal is just so we see whether this is indeed the reason for the problem, I don't really suggest to remove them for good.) Thanks.