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#25265: make-thread crashes in OS X 10.6 Date: Tue, 27 Dec 2016 13:13:11 +0200 Message-ID: <83bmvxwrp4.fsf@gnu.org> References: <83r34xxlke.fsf@gnu.org> <83d1ggxayi.fsf@gnu.org> <20161226130917.GA36471@breton.holly.idiocy.org> <8337hay9fl.fsf@gnu.org> <20161226205632.GA36805@breton.holly.idiocy.org> <83k2alx20b.fsf@gnu.org> <20161227104424.GA45039@breton.holly.idiocy.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 1482837254 20816 195.159.176.226 (27 Dec 2016 11:14:14 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 27 Dec 2016 11:14:14 +0000 (UTC) Cc: charles@aurox.ch, 25265@debbugs.gnu.org To: Alan Third Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Dec 27 12:14: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 1cLphn-0004JU-EM for geb-bug-gnu-emacs@m.gmane.org; Tue, 27 Dec 2016 12:14:07 +0100 Original-Received: from localhost ([::1]:53635 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cLphq-0003Ao-Ji for geb-bug-gnu-emacs@m.gmane.org; Tue, 27 Dec 2016 06:14:10 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:52784) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cLphl-0003Ae-Al for bug-gnu-emacs@gnu.org; Tue, 27 Dec 2016 06:14:06 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cLphi-00056c-3K for bug-gnu-emacs@gnu.org; Tue, 27 Dec 2016 06:14:05 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:40923) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cLphi-00056L-0A for bug-gnu-emacs@gnu.org; Tue, 27 Dec 2016 06:14:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1cLphh-0002rB-P5 for bug-gnu-emacs@gnu.org; Tue, 27 Dec 2016 06:14:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 27 Dec 2016 11:14:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 25265 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 25265-submit@debbugs.gnu.org id=B25265.148283721210934 (code B ref 25265); Tue, 27 Dec 2016 11:14:01 +0000 Original-Received: (at 25265) by debbugs.gnu.org; 27 Dec 2016 11:13:32 +0000 Original-Received: from localhost ([127.0.0.1]:56322 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cLphE-0002qI-9o for submit@debbugs.gnu.org; Tue, 27 Dec 2016 06:13:32 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:33494) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cLphD-0002q5-6X for 25265@debbugs.gnu.org; Tue, 27 Dec 2016 06:13:31 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cLph3-0004tT-Rn for 25265@debbugs.gnu.org; Tue, 27 Dec 2016 06:13:26 -0500 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:51254) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cLph3-0004tJ-Of; Tue, 27 Dec 2016 06:13:21 -0500 Original-Received: from 84.94.185.246.cable.012.net.il ([84.94.185.246]:2348 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1cLph2-0007K4-Jt; Tue, 27 Dec 2016 06:13:21 -0500 In-reply-to: <20161227104424.GA45039@breton.holly.idiocy.org> (message from Alan Third on Tue, 27 Dec 2016 10:44:24 +0000) 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:127491 Archived-At: > Date: Tue, 27 Dec 2016 10:44:24 +0000 > From: Alan Third > Cc: charles@aurox.ch, 25265@debbugs.gnu.org > > OK, I’ve ended up just using printf and it looks like in this thread > current_thread is null. This happens in only one place: run_thread, after a thread exits. And yes, it's a bad idea to rely on current_thread being non-NULL in code that is run when other threads could be running. More generally, this means calling unbind_to, i.e. unwinding the Lisp stack, is not going to work in this context at all, because that in effect runs Lisp when more than one thread could run their code. > > > > [NSApp run]; > > > > > > > > Can this part and its surrounding code be made thread-safe? > > > > > > I think this particular method call has to be done *only* from the > > > main thread. I imagine that could be a problem. > > > > It could be a problem, yes. But what does this do, exactly, and why > > does it need to be called as part of ns_select? > > It runs an event loop that picks up all GUI events and then dispatches > them. It’s part of NextStep. It’s unclear to me why it’s run in > ns_select, but presumably it’s because it needs to be run somewhere > and whoever wrote it thought that was a good place. > > If we need to, I expect we could move it to its own thread. That seems > to be a known pattern in the GNUStep/Cocoa world. That's probably the only reasonable way. But why does it use record_unwind_protect and unbind_to in the first place? What happens if the user presses C-g while the event loop runs? > I’m pretty sure that Emacs doesn’t even use ns_select when it’s run > in the terminal, though. Actually, I think it has to use ns_select, because subprocesses are still supported on a text terminal, and reading their output calls ns_select. Likewise network connections.