Subject: Re: bug#75275: 30.0.92; `make-thread` bug on macOS 15.2

From: Gerd Möllmann <[email-masked]>
Date: Thu, 02 Jan 2025 06:55:51 +0100

Gerd Möllmann <[email-masked]> writes:

> Stefan Kangas <[email-masked]> writes:
>
>> I have run into a bug with make-thread on macOS 15.2, running on an M2.
>>
>> I can reproduce the issue consistently both on emacs-30 and master by
>> evaluating this in emacs -Q:
>>
>>     (make-thread (lambda () (sleep-for 1)) "bug")
>>
>> This leads to Emacs freezing up completely within a fraction of a
>> second.  I have time to move point once or maybe twice before it gets
>> non-responsive, let's say within a few tenths of a second.
>
> Curious question: Do you see a beach ball?
>
>> When I kill the process in the lldb window with Ctrl+C, I can get the
>> following (this is on emacs-30):
>>
>>     frame #12: 0x0000000100403fec emacs`-[EmacsApp
>> run](self=0x0000000156610fe0, _cmd="run") at nsterm.m:5938:7
>>     frame #13: 0x00000001004024b0 emacs`ns_select_1(nfds=0,
>> readfds=0x00000001708c26bc, writefds=0x00000001708c263c,
>> exceptfds=0x0000000000000000, timeout=0x00000001708c2610,
>> sigmask=0x0000000000000000, run_loop_only=NO) at nsterm.m:4954:3
>>     frame #14: 0x000000010040202c emacs`ns_select(nfds=0,
>> readfds=0x00000001708c26bc, writefds=0x00000001708c263c,
>> exceptfds=0x0000000000000000, timeout=0x00000001708c2610,
>> sigmask=0x0000000000000000) at nsterm.m:5006:10
>
> I'm asking because of bug#72496. The part of the backtrace above reminds
> me a bit of what I trued to describe in that bug: EmacsApp.run never
> returning to ns_select_1. Can you see if it ever returns?

This is what Apple says about Cocoa thread-safety

https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/Multithreading/ThreadSafetySummary/ThreadSafetySummary.html#:~:text=Guidelines%20for%20using%20Cocoa%20from,are%20generally%20not%20thread%2Dsafe.