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: Sat, 13 Jul 2019 14:37:25 +0000 Message-ID: References: <87muhks3b5.fsf@hochschule-trier.de> <83muhj2zmb.fsf@gnu.org> <83ims72xcj.fsf@gnu.org> <83a7dj2sz9.fsf@gnu.org> <835zo72jmr.fsf@gnu.org> <834l3r2jbe.fsf@gnu.org> <8336jb2fhq.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="0000000000005b37e5058d90f9b8" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="95117"; 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 Sat Jul 13 16:39:16 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 1hmJBC-000OYl-R5 for geb-bug-gnu-emacs@m.gmane.org; Sat, 13 Jul 2019 16:39:15 +0200 Original-Received: from localhost ([::1]:56628 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hmJB8-00062y-1B for geb-bug-gnu-emacs@m.gmane.org; Sat, 13 Jul 2019 10:39:10 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:47918) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hmJB2-0005pi-9b for bug-gnu-emacs@gnu.org; Sat, 13 Jul 2019 10:39:05 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hmJB0-0002sd-KM for bug-gnu-emacs@gnu.org; Sat, 13 Jul 2019 10:39:04 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:34219) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hmJB0-0002sT-GK for bug-gnu-emacs@gnu.org; Sat, 13 Jul 2019 10:39:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1hmJB0-0000hC-DI for bug-gnu-emacs@gnu.org; Sat, 13 Jul 2019 10:39:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Pip Cet Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 13 Jul 2019 14:39:02 +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.15630286942614 (code B ref 36609); Sat, 13 Jul 2019 14:39:02 +0000 Original-Received: (at 36609) by debbugs.gnu.org; 13 Jul 2019 14:38:14 +0000 Original-Received: from localhost ([127.0.0.1]:43039 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hmJAD-0000g5-Du for submit@debbugs.gnu.org; Sat, 13 Jul 2019 10:38:14 -0400 Original-Received: from mail-ot1-f66.google.com ([209.85.210.66]:37957) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hmJA7-0000fa-J2 for 36609@debbugs.gnu.org; Sat, 13 Jul 2019 10:38:08 -0400 Original-Received: by mail-ot1-f66.google.com with SMTP id d17so12379131oth.5 for <36609@debbugs.gnu.org>; Sat, 13 Jul 2019 07:38:07 -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=FAqQN2vS7aqDYXJTpIkMEcxCQY5XmhkSyFZUIkX24Xo=; b=VPCh/AcmZjUvBtdba+5GTT7PZ5Cqj+zw9PFgG6sVQkDRVYLdYsxPpIi3e2qK27voa6 uAg2CUroZ1+7sS+FXbMzSd92QqUxJxCSMs8aBd6hiNE/nY6cRe/TpdJkpQ1otZKdNfI/ XgVKYUc+8ru+uVwhkyyJErIYCoEJ6p5SDDi4yf5C3GrNLsIIYm/D9qBlIzKqyJ1IRGPH czzNEhegRZvWBH6wxVeUWLr5HXQAAievgaKkp6rFDmbR9qAPn8wDAvlxqMy7FcpX8k4D UzwQk0CJI1ROxcGbrHSRfPTdZCpg50UGCxFSLhBsxYMlsQNoxLSkgmdyVC9oBaR8kMnr kRrQ== 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=FAqQN2vS7aqDYXJTpIkMEcxCQY5XmhkSyFZUIkX24Xo=; b=tDeif4CuIQp8NeVTod5VHtFqliJ66W35psZPg3VgEi1/kcRYNtmn0SVjVlfZLZ/fJE atyecbWA5gaffOaV1GWXJYf3MbLEmxu1bXXMsWw3x+3Nl0hhJD1d3Lmft+QdqQtQ0Wp+ f8HLIo0HPjY6ptdq6hQnzMBcAh74P2nYqePKcJSYi1+2y5MEnSYrxlWT7UgAUuRI4GK2 mtBGyug1cyB740cDpysSEW8tfav2yf1u/hlaypw7ENszstLZXCiMTceM0AbaocCvtANk N112+x5cG6czvdH8VQuS6rVwQnZ7/RSGPvP1pD7MVLhrdzxgue4UTo5WRpYOphHLeXUt hdPQ== X-Gm-Message-State: APjAAAU7BVIszUnmLW7S8a7z4nNrrTei8TQ88sRE9jpqK/ApHTO1p1c6 HcnLAH6TBnJL6cIyUasWcVYt2fWyll4iYqbZ1ivsfg== X-Google-Smtp-Source: APXvYqycShPz4iqZw4NaExzvLo18KrEKUyYM3eZKG/QkisMRNtqmO2fIahQdAnGhMQKfOog4g6pFinH24+/VAAaoJcw= X-Received: by 2002:a9d:554b:: with SMTP id h11mr5058923oti.154.1563028681854; Sat, 13 Jul 2019 07:38:01 -0700 (PDT) In-Reply-To: <8336jb2fhq.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:162891 Archived-At: --0000000000005b37e5058d90f9b8 Content-Type: text/plain; charset="UTF-8" On Fri, Jul 12, 2019 at 7:57 PM Eli Zaretskii wrote: > > I'm now convinced that there simply is no safe way to call select() > > from two threads at once when using glib. > > I hope not, although GTK with its idiosyncrasies caused a lot of pain > for the threads implementation in Emacs. Well, I think we're going to have to do one or more of the following: - have a race condition - access glib-locked data from the "wrong" thread (another Emacs thread) - release the glib lock from the "wrong" thread (another Emacs thread) Of these, the second is the best alternative, I think: we simply grab the g_main_context lock globally, acting for all Emacs threads, and the last thread to require it releases it when it leaves xg_select. As long as there's at least one thread in the critical section of xg_select, we hold the lock, but access to the context isn't necessarily from the thread which locked it. > > I think our options are hacking around it and hoping nothing breaks > > (this is what the attached patch does; it releases the main context > > glib lock from the wrong thread soon "after" the other thread called > > select, but there's actually no way to ensure that "after" is > > accurate), or rewriting things so we have a single thread that does > > all the select()ing. > > Hmm... how would this work with your patch? Suppose one thread calls > xg_select, acquires the Glib lock, sets its holding_glib_lock flag, > then releases the global Lisp lock and calls pselect. Since the > global Lisp lock is now up for grabs, some other Lisp thread can > acquire it and start running. And when it starts running, it releases the Glib lock. > If that other thread then calls > xg_select, it will hang forever trying to acquire the Glib lock, > because the first thread that holds it is stuck in pselect. The first thread no longer holds the Glib lock, it was released when we switched threads. > I know very little about GTK and the Glib context lock, but AFAIR we > really must treat that lock as a global one, not a thread-local one. > So I think it's okay for one thread to take the Glib lock, and another > to release it, because Glib just wants to know whether the "rest of > the program" has it, it doesn't care which thread is that which holds > the lock. Okay, that sounds like option #2 above. The attached patch exposes glib externals to the generic code, but it appears to work. If you think the approach is okay, I'll move the glib-specific parts to xgselect.c (if that's okay). --0000000000005b37e5058d90f9b8 Content-Type: text/x-patch; charset="US-ASCII"; name="glib-hack-002.diff" Content-Disposition: attachment; filename="glib-hack-002.diff" Content-Transfer-Encoding: base64 Content-ID: X-Attachment-Id: f_jy1mw7ph0 ZGlmZiAtLWdpdCBhL3NyYy90aHJlYWQuYyBiL3NyYy90aHJlYWQuYwppbmRleCBlMmRlYWRkN2E4 Li4wZGRiNzk0NjBiIDEwMDY0NAotLS0gYS9zcmMvdGhyZWFkLmMKKysrIGIvc3JjL3RocmVhZC5j CkBAIC0xOSw2ICsxOSw5IEBAIENvcHlyaWdodCAoQykgMjAxMi0yMDE5IEZyZWUgU29mdHdhcmUg Rm91bmRhdGlvbiwgSW5jLgogCiAjaW5jbHVkZSA8Y29uZmlnLmg+CiAjaW5jbHVkZSA8c2V0am1w Lmg+CisjaWZkZWYgSEFWRV9HTElCCisjaW5jbHVkZSA8Z2xpYi5oPgorI2VuZGlmCiAjaW5jbHVk ZSAibGlzcC5oIgogI2luY2x1ZGUgImNoYXJhY3Rlci5oIgogI2luY2x1ZGUgImJ1ZmZlci5oIgpA QCAtODIsNyArODUsNyBAQCBwb3N0X2FjcXVpcmVfZ2xvYmFsX2xvY2sgKHN0cnVjdCB0aHJlYWRf c3RhdGUgKnNlbGYpCiAKICAgLyogRG8gdGhpcyBlYXJseSBvbiwgc28gdGhhdCBjb2RlIGJlbG93 IGNvdWxkIHNpZ25hbCBlcnJvcnMgKGUuZy4sCiAgICAgIHVuYmluZF9mb3JfdGhyZWFkX3N3aXRj aC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c2VsZWN0IChpbnQgZmRzX2xpbSwgZmRfc2V0ICpyZmRz LCBmZF9zZXQgKndmZHMsIGZkX3NldCAqZWZkcywKICAgICAgIGVycm5vID0gcHNlbGVjdF9lcnJu bzsKICAgICB9CiAKLSAgaWYgKGNvbnRleHRfYWNxdWlyZWQpCi0gICAgZ19tYWluX2NvbnRleHRf cmVsZWFzZSAoY29udGV4dCk7CisgIGlmIChjdXJyZW50X3RocmVhZCAhPSBOVUxMICYmIGN1cnJl bnRfdGhyZWFkLT5ob2xkaW5nX2dsaWJfbG9jaykKKyAgICBpZiAoLS10aHJlYWRzX2hvbGRpbmdf Z2xpYl9sb2NrID09IDApCisgICAgICB7CisJZ19tYWluX2NvbnRleHRfcmVsZWFzZSAoY29udGV4 dCk7CisJY3VycmVudF90aHJlYWQtPmhvbGRpbmdfZ2xpYl9sb2NrID0gZmFsc2U7CisgICAgICB9 CiAKICAgLyogVG8gbm90IGhhdmUgdG8gcmVjYWxjdWxhdGUgdGltZW91dCwgcmV0dXJuIGxpa2Ug dGhpcy4gICovCiAgIGlmICgob3VyX2ZkcyA+IDAgfHwgKG5mZHMgPT0gMCAmJiB0bW9wID09ICZ0 bW8pKSAmJiAocmV0dmFsID09IDApKQo= --0000000000005b37e5058d90f9b8--