From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Alan Third Newsgroups: gmane.emacs.bugs Subject: bug#25265: make-thread crashes in OS X 10.6 Date: Fri, 30 Dec 2016 22:05:44 +0000 Message-ID: <20161230220544.GA4775@breton.holly.idiocy.org> References: <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> <83bmvxwrp4.fsf@gnu.org> <20161228193633.GA47290@breton.holly.idiocy.org> <83vau2u0a1.fsf@gnu.org> <20161230184532.GA3754@breton.holly.idiocy.org> <83pok9ruop.fsf@gnu.org> 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 1483135579 12140 195.159.176.226 (30 Dec 2016 22:06:19 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 30 Dec 2016 22:06:19 +0000 (UTC) User-Agent: Mutt/1.7.1 (2016-10-04) Cc: charles@aurox.ch, 25265@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Dec 30 23:06:15 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 1cN5JO-0001qv-H0 for geb-bug-gnu-emacs@m.gmane.org; Fri, 30 Dec 2016 23:06:06 +0100 Original-Received: from localhost ([::1]:41646 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cN5JT-00058K-1l for geb-bug-gnu-emacs@m.gmane.org; Fri, 30 Dec 2016 17:06:11 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:53978) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cN5JN-00058B-2w for bug-gnu-emacs@gnu.org; Fri, 30 Dec 2016 17:06:06 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cN5JJ-0004v3-Td for bug-gnu-emacs@gnu.org; Fri, 30 Dec 2016 17:06:05 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:45250) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cN5JJ-0004uv-Pg for bug-gnu-emacs@gnu.org; Fri, 30 Dec 2016 17:06:01 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1cN5JJ-0003aL-Ie for bug-gnu-emacs@gnu.org; Fri, 30 Dec 2016 17:06:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Alan Third Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 30 Dec 2016 22:06: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.148313555513768 (code B ref 25265); Fri, 30 Dec 2016 22:06:01 +0000 Original-Received: (at 25265) by debbugs.gnu.org; 30 Dec 2016 22:05:55 +0000 Original-Received: from localhost ([127.0.0.1]:60649 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cN5JD-0003a0-At for submit@debbugs.gnu.org; Fri, 30 Dec 2016 17:05:55 -0500 Original-Received: from mail-wm0-f52.google.com ([74.125.82.52]:34957) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cN5JB-0003Zm-5v for 25265@debbugs.gnu.org; Fri, 30 Dec 2016 17:05:53 -0500 Original-Received: by mail-wm0-f52.google.com with SMTP id a197so329318750wmd.0 for <25265@debbugs.gnu.org>; Fri, 30 Dec 2016 14:05:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=ZQr6BoficrHDcLBD/lOt7v9UAS+lZld3UpdLmdvfYrs=; b=lh8uhCfYrSRPeD8DnX1JXAFWQHc0toEuNmy3cnSNkN9z7Cvhd33heMNub9fLgZaWjw cqe1MGFTNyQUayjkolXK2OYmzq/uA3iFH4nA6xi6BdtsMg3rw4ARlzBrftEvQvTUtb53 tTqTiVlUFYezv13M6uJ0eepllLyu8a+8KN6Ini9aa3A2/QWlZjD877//tGFaWues884I wcuQRQM4ahmLIoPqVvsfjO1fmmIT40KrhSXFSobVMRtsYWcY6d9fh4n8ORGzS2Wiiz0e TSVzOR9vaT+MDR4Q04M8loAKojyYn3KqrDTa/mUCErXjZt+DiEsj4/ebSA3owKZYSgJh NxhA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition :content-transfer-encoding:in-reply-to:user-agent; bh=ZQr6BoficrHDcLBD/lOt7v9UAS+lZld3UpdLmdvfYrs=; b=EuMVIAeiGzMKSH3pflMgqVOaRdK/IddAPOF/R7Kv0X4NIcOLlrLZN+TuULT4sDEKPP og6eg72JBC8JXd3a29zddEgjWFnyuYTEv9cFpkWAeoGxF1zaWpnW1UGr5eVm3tcWuntU qFpNcXBY1GCEqMrBwwLsgKBO2A8aNbQ+yp6Wu3VAebNA2myLKIIzTIKUUvqq2VVx5Z/B dtoEAb2Kcr+G5kKRgsP4ZUdAcv7dOWHUHv9RsSkFvadcn0xmnsHIdujyJRXYpOt2GX+R ImWRFhghqb4CrbsIFL3rG2xIeilOC5+E9wnrxZieIfah4TK5TeqzM6pR6WQepSTiWtYH tWZA== X-Gm-Message-State: AIkVDXJe6MIbKW+cJK4k34LrGqiWMupAia3dx+i23tPAyKcnlfRZQOnD0nQkPks/xg+buw== X-Received: by 10.28.214.133 with SMTP id n127mr47150610wmg.28.1483135547390; Fri, 30 Dec 2016 14:05:47 -0800 (PST) Original-Received: from breton.holly.idiocy.org (ip6-2001-08b0-03f8-8129-fcf8-7042-dd5f-6680.holly.idiocy.org. [2001:8b0:3f8:8129:fcf8:7042:dd5f:6680]) by smtp.gmail.com with ESMTPSA id cj1sm4677399wjd.46.2016.12.30.14.05.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 30 Dec 2016 14:05:46 -0800 (PST) Content-Disposition: inline In-Reply-To: <83pok9ruop.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: 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:127597 Archived-At: On Fri, Dec 30, 2016 at 11:08:54PM +0200, Eli Zaretskii wrote: > > Date: Fri, 30 Dec 2016 18:45:32 +0000 > > From: Alan Third > > Cc: charles@aurox.ch, 25265@debbugs.gnu.org > > > > Ah! Is this the missing piece of the puzzle? When the [NSApp run] loop > > receives an event, say keyboard input, it creates an emacs_event and > > then raises SIGIO (via hold_event). SIGIO causes ns_read_socket to be > > run, which ALSO tries to run [NSApp run]. > > > > Am I right in thinking that raising SIGIO will cause ns_read_socket to > > be potentially run immediately? Asynchronously? > > I very much hope not. We don't run any non-trivial code from a signal > handler. I'd expect SIGIO just to set a flag, and then the resulting > input be processed when we call unblock_input next time, and the > blocking level gets to zero. Then we run process_pending_signals, > which calls handle_async_input, and that's where ns_read_socket will > be called by gobble_input. OK. I am, again, none the wiser. > > I’ve just commented out the section of ns_read_socket that calls > > [NSApp run] and I can’t see any difference in behaviour. I suspect > > that someone’s doubled up on it when they didn’t need to. > > I cannot help you here. Maybe it's needed for Emacs to be more > responsive? If you run "git log -L" on ns_read_socket, does the > history tell anything about why this call was added? Perhaps some > discussion or bug report? It’s been there since the NS port was integrated, it seems. > > So, my plan of action: > > > > Run [NSApp run] in it’s own thread with no flow control (unless it’s > > important that emacs events are only created at specific times?) > > How will that thread communicate the events to Emacs? I’m hoping using the same method as it does now. It creates emacs events from the NS events, and then fires SIGIO. I have run into a problem almost right away, though. I don’t know how to go about creating this thread. The NSApp loop needs to run in the ‘main’ thread on macOS. I understand the main thread is always the original thread, so if I want to use it for the NSApp loop, I need to move Emacs’ normal operation into a child thread. I don’t have any experience with pthreads and can’t see any obvious way of doing it (and I think, from my experiments, it breaks unexec or something). Is it possible, or can you think of a better way of handling this? Thanks! -- Alan Third