Subject: bug#39343: 27.0.50; Thrad signal crashes Emacs with sgmentation fault

From: Alan Third <[email-masked]>
Date: Wed, 29 Jan 2020 20:42:34 +0000

On Wed, Jan 29, 2020 at 12:27:19PM +0100, Christian Johansson wrote:
> Running following works on Linux but not on macOS.
> 
> (let ((loop t)
>       (iterations 1))
>   (while loop
>     (make-thread
>      (lambda()
>        (message "Thread %d" iterations)
>        (signal 'error (list "My error"))))
>     (setq iterations (1+ iterations))))
> 
> Error in console: Fatal error 11: Segmentation faultAbort trap: 6
> 
> It seems to be some kind of issue with quitting threads on macOS which is
> not present on Linux

It’s a stack overflow caused by the main thread getting stuck in a
loop processing calls to ns_send_appdefined which must be coming from
the 2000‐odd threads the script starts.

Presumably it’s the call to ns_run_loop_break in sys_cond_broadcast
that’s doing it.

I don’t think there’s really any way round this other than the massive
rewrite the NS port needs to make it handle threads correctly.

-- 
Alan Third