From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Pip Cet Newsgroups: gmane.emacs.bugs Subject: bug#36609: 27.0.50; Possible race-condition in threading implementation Date: Fri, 12 Jul 2019 19:30:34 +0000 Message-ID: References: <87muhks3b5.fsf@hochschule-trier.de> <83k1cn2z0l.fsf@gnu.org> <83ftnb2wf9.fsf@gnu.org> <83blxz2t43.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="230890"; mail-complaints-to="usenet@blaine.gmane.org" Cc: 36609@debbugs.gnu.org, politza@hochschule-trier.de To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Jul 12 21:32:11 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1hm1H8-000xuv-Kb for geb-bug-gnu-emacs@m.gmane.org; Fri, 12 Jul 2019 21:32:10 +0200 Original-Received: from localhost ([::1]:51998 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hm1H7-00079v-G9 for geb-bug-gnu-emacs@m.gmane.org; Fri, 12 Jul 2019 15:32:09 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:46567) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hm1H2-00078Y-Ew for bug-gnu-emacs@gnu.org; Fri, 12 Jul 2019 15:32:05 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hm1H1-0000tJ-0e for bug-gnu-emacs@gnu.org; Fri, 12 Jul 2019 15:32:04 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:60161) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hm1H0-0000qx-2s for bug-gnu-emacs@gnu.org; Fri, 12 Jul 2019 15:32:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1hm1Gz-0002x4-S0 for bug-gnu-emacs@gnu.org; Fri, 12 Jul 2019 15:32:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Pip Cet Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 12 Jul 2019 19:32:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 36609 X-GNU-PR-Package: emacs Original-Received: via spool by 36609-submit@debbugs.gnu.org id=B36609.156295987811291 (code B ref 36609); Fri, 12 Jul 2019 19:32:01 +0000 Original-Received: (at 36609) by debbugs.gnu.org; 12 Jul 2019 19:31:18 +0000 Original-Received: from localhost ([127.0.0.1]:40749 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hm1GI-0002w3-01 for submit@debbugs.gnu.org; Fri, 12 Jul 2019 15:31:18 -0400 Original-Received: from mail-oi1-f178.google.com ([209.85.167.178]:35379) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hm1GG-0002vp-CC for 36609@debbugs.gnu.org; Fri, 12 Jul 2019 15:31:16 -0400 Original-Received: by mail-oi1-f178.google.com with SMTP id a127so8124639oii.2 for <36609@debbugs.gnu.org>; Fri, 12 Jul 2019 12:31:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=uh18TgPOc3bPBJ4lUI/llHtgVdLs1H48yh++40fsg2U=; b=F19rYLdhK8XMXmJoPOZpufPL3I6ABLzdxwiWADRec+hoHMRAKRUi2dvlYy9khKU+pD +XVAZ5Bti1pFsK6SWPd1YfALS6sWwA8NoO5Okbb3YgQl04j2rLabN6/bJNzJCw65pJHD JTzqykZLDInjVDe6bBon5kt7sjANS0/Zmo0y4SeUkG4FA2IKbod/y6q32S9RUT2SXDBe CM/1H4MghoxrR6fFym2ElheLHYF7WmdWtLZVdz293WFsQG7BybEd5KiUmb8Sd5rv3Omd hvOWbzrPeCpk8zshh6zKhzFwTOFqd5o3ZAftW1s4Zw4SWTh+Mc8vti/j7XIY8sXCUe5G c5tg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=uh18TgPOc3bPBJ4lUI/llHtgVdLs1H48yh++40fsg2U=; b=HwQJKfv2r51jWwQvnMRaQgIkrP0FZTZ31upSBhyUisQZwDktc4zlGgdQ+yB1U76niu zIwc5YZWhHEQmG43HM8XYoZG1MTzzES7UEHIf8vbyWDw0FtC9QeNOlhnl9zawqZWWDp5 Kt29HDADzi8HmZyn7A8wXkyjfeL/8gxMbUnc+LvXJe18ZXSqR2m4t9IMdDSlNDfxNsja CWDuvCYpoR+clpZmrZ/elV7Cw1A+IqnKJe6pFdwvfQbjP4RNlSg7VtPdV8HT6pNLtfqj 2HD8AOZxcLNihYmFzErpG5rsfkYwDIo+EmJuiMkiCa3/tkGqbard4Irk3BA8ArBPLOBy sfgQ== X-Gm-Message-State: APjAAAU64RMC3LI4XzVAD/zyvywPQtR71QE7Ekesye0zr6xaPiVUe+Jh 4a8LEEgAvtN3It2MeAmwp+E20UeN2NDPULUjbSw= X-Google-Smtp-Source: APXvYqzErcMEOyrktymeGNAhcIZjv7s7pPG4/QZxz1CAB80dwOlaznowZRNnPrFgZxLfh/0AB4JeMx4/PnldMBYjdvE= X-Received: by 2002:a05:6808:313:: with SMTP id i19mr6790386oie.30.1562959870729; Fri, 12 Jul 2019 12:31:10 -0700 (PDT) In-Reply-To: <83blxz2t43.fsf@gnu.org> 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: 209.51.188.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:162803 Archived-At: > > > We should either release the global lock before the thread exits, or > > > defer the acting upon the signal until later. We cannot disable the > > > signal handling altogether because it is entirely legitimate to signal > > > another thread, and when we do, that other thread will _always_ be > > > inside thread_select. > > > > Really? What about thread-yield? > > What about it? > > You are asking whether, when thread-signal is executed, the thread > which we are signaling is necessarily parked inside thread_select? If > so, I don't understand your surprise: only one thread can ever be > running, and that is by definition the thread which calls > thread-signal. All the other threads cannot be running, which means > they are parked either in thread_select or in sys_mutex_lock called > from acquire_global_lock. Right? No, they might also be in the sys_thread_yield syscall, having released the global lock but not yet reacquired it: release_global_lock (); sys_thread_yield (); <<<<< here acquire_global_lock (self); > As for thread-yield, I'm not sure I understand how is it related to > the issue we are discussing. I'm not sure how it's relevant to assert that "that other thread will _always_ be inside thread_select". I have an idea where you might be going with that, but that idea wouldn't work (to release the lock from the signalling thread, not the signalled thread that holds it). > If the problem with missing events, > then which events are those, and what bad things will happen if we > miss them? All events that glib knows about but Emacs doesn't. For example, a glib timeout is apparently used to achieve some kind of scroll effect on GTK menus, which is why we call xg_select from xmenu.c. I don't know which libraries use glib-based threads, but I think dbus does, too. I believe, but am not certain, that this also includes X events when using GTK. That would explain the frozen sessions.