all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Alan Third <alan@idiocy.org>
To: Eli Zaretskii <eliz@gnu.org>
Cc: charles@aurox.ch, 25265@debbugs.gnu.org
Subject: bug#25265: make-thread crashes in OS X 10.6
Date: Mon, 26 Dec 2016 13:09:17 +0000	[thread overview]
Message-ID: <20161226130917.GA36471@breton.holly.idiocy.org> (raw)
In-Reply-To: <83d1ggxayi.fsf@gnu.org>

On Sun, Dec 25, 2016 at 05:52:37PM +0200, Eli Zaretskii wrote:
> > Date: Sat, 24 Dec 2016 19:51:13 +0200
> > From: Eli Zaretskii <eliz@gnu.org>
> > Cc: 25265@debbugs.gnu.org
> > 
> > I see that ns_select calls block/unblock_input, which makes it unsafe
> > when more than one thread is running.  It's quite possible that this
> > is the reason.
> > 
> > I hope some NS expert could take a look at this and fix this.
> 
> One idea is to write an implementation of block_input and
> unblock_input that uses atomic increment and decrement functions, then
> use those only in ns_select.
> 
> Could someone with access to NS please try that?

I’ve just tried the below patch and it doesn’t make any difference: it
still hangs immediately.

Back in October Ken Raeburn listed some things that need done in
ns_select which are probably relevant:

https://lists.gnu.org/archive/html/emacs-devel/2016-10/msg00525.html

2 files changed, 23 insertions(+)
src/blockinput.h |  8 ++++++++
src/keyboard.c   | 15 +++++++++++++++

modified   src/blockinput.h
@@ -49,10 +49,18 @@ extern volatile int interrupt_input_blocked;
 
 /* Begin critical section. */
 
+#ifdef NS_IMPL_COCOA
+#include <libkern/OSAtomic.h>
+#endif
+
 INLINE void
 block_input (void)
 {
+#ifdef NS_IMPL_COCOA
+  OSAtomicIncrement32(&interrupt_input_blocked);
+#else
   interrupt_input_blocked++;
+#endif
 }
 
 extern void unblock_input (void);
modified   src/keyboard.c
@@ -54,6 +54,10 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 #include <sys/ioctl.h>
 #endif /* not MSDOS */
 
+#ifdef NS_IMPL_COCOA
+#include <libkern/OSAtomic.h>
+#endif
+
 #if defined USABLE_FIONREAD && defined USG5_4
 # include <sys/filio.h>
 #endif
@@ -7183,7 +7187,18 @@ unblock_input_to (int level)
 void
 unblock_input (void)
 {
+#ifdef NS_IMPL_COCOA
+  OSAtomicDecrement32(&interrupt_input_blocked);
+  if (interrupt_input_blocked == 0)
+    {
+      if (pending_signals && !fatal_error_in_progress)
+	process_pending_signals ();
+    }
+  else if (interrupt_input_blocked < 0)
+    emacs_abort ();
+#else  
   unblock_input_to (interrupt_input_blocked - 1);
+#endif
 }
 
 /* Undo any number of BLOCK_INPUT calls,


-- 
Alan Third





  reply	other threads:[~2016-12-26 13:09 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-24 11:06 bug#25265: make-thread crashes in OS X 10.6 Charles A. Roelli
2016-12-24 17:51 ` Eli Zaretskii
2016-12-25 15:52   ` Eli Zaretskii
2016-12-26 13:09     ` Alan Third [this message]
2016-12-26 15:52       ` Eli Zaretskii
2016-12-26 20:56         ` Alan Third
2016-12-27  7:30           ` Eli Zaretskii
2016-12-27 10:44             ` Alan Third
2016-12-27 11:13               ` Eli Zaretskii
2016-12-28 19:36                 ` Alan Third
2016-12-29 17:12                   ` Eli Zaretskii
2016-12-30 18:45                     ` Alan Third
2016-12-30 21:08                       ` Eli Zaretskii
2016-12-30 22:05                         ` Alan Third
2016-12-31  9:20                           ` Eli Zaretskii
2016-12-31 16:09                             ` bug#25265: [PATCH] Rework NS event handling (bug#25265) Alan Third
2016-12-31 16:25                               ` Eli Zaretskii
2016-12-31 16:46                                 ` Alan Third
2017-01-01 15:03                               ` Alan Third
2017-01-01 15:42                                 ` Eli Zaretskii
2017-03-06 20:02 ` bug#25265: make-thread crashes in OS X 10.6 Alan Third
2017-03-08 20:17   ` Charles A. Roelli
2017-03-14 14:49     ` Alan Third
2017-05-02 20:49 ` Alan Third
2017-06-12 19:32   ` Charles A. Roelli
2017-06-13 20:46     ` Alan Third
2017-06-15 18:57       ` Charles A. Roelli
2017-06-15 19:04         ` Alan Third
2017-06-15 19:14           ` Noam Postavsky
2017-06-16 19:45           ` Alan Third
2017-06-16 20:05             ` Noam Postavsky
2017-06-16 20:51               ` Alan Third
2017-06-18 13:05                 ` Charles A. Roelli
2017-06-18 14:01                   ` Alan Third
2017-06-19 18:34                     ` Charles A. Roelli
2017-07-01 12:04                       ` Alan Third
2017-07-04  6:59                         ` Charles A. Roelli
2017-07-04 12:04                           ` npostavs
     [not found]                             ` <20170705193642.GA18888@breton.holly.idiocy.org>
2017-07-06  9:25                               ` Charles A. Roelli
2017-07-06 17:10                               ` Charles A. Roelli

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20161226130917.GA36471@breton.holly.idiocy.org \
    --to=alan@idiocy.org \
    --cc=25265@debbugs.gnu.org \
    --cc=charles@aurox.ch \
    --cc=eliz@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.