From: "Gerd Möllmann" <gerd.moellmann@gmail.com>
To: Alan Third <alan@idiocy.org>
Cc: Po Lu <luangruo@yahoo.com>,
75275@debbugs.gnu.org, Eli Zaretskii <eliz@gnu.org>,
stefankangas@gmail.com
Subject: bug#75275: 30.0.92; `make-thread` bug on macOS 15.2
Date: Thu, 02 Jan 2025 15:03:54 +0100 [thread overview]
Message-ID: <m234i1ia7p.fsf@gmail.com> (raw)
In-Reply-To: <Z3aadivS90hcvXCM@faroe.holly.idiocy.org> (Alan Third's message of "Thu, 2 Jan 2025 13:53:58 +0000")
Alan Third <alan@idiocy.org> writes:
> On Thu, Jan 02, 2025 at 02:05:44PM +0100, Gerd Möllmann wrote:
>> Alan Third <alan@idiocy.org> writes:
>>
>> > No, none of that needs to run when we're not in the main thread.
>> > fd_handler run pselect in a separate thread because the NS main thread
>> > has to run the ns main thread run loop to handle incoming IO from the
>> > window system.
>> >
>> > The NS run loop can emulate parts of pselect, but not the whole thing,
>> > so we are required to run both the NS runloop and pselect
>> > simultaneously, hence fd_handler. If we don't need to run the runloop,
>> > i.e. we're in a non-main thread, then we can just run pselect directly
>> > and ignore fd_handler.
>>
>> So IIUC, you'd write this in ns_select_1
>>
>> if (![NSThread isMainThread]
>> || (timeout && timeout->tv_sec == 0 && timeout->tv_nsec == 0))
>> thread_select (pselect, nfds, readfds, writefds,
>> exceptfds, timeout, sigmask);
>>
>> as return "return thread_select(...)"?
>
> I don't know. The code that in Emacs 29 looked like:
>
> if (NSApp == nil
> || ![NSThread isMainThread]
> || (timeout && timeout->tv_sec == 0 && timeout->tv_nsec == 0))
> return thread_select (pselect, nfds, readfds, writefds,
> exceptfds, timeout, sigmask);
> else
> {
> struct timespec t = {0, 0};
> thread_select (pselect, 0, NULL, NULL, NULL, &t, sigmask);
> }
>
> Now looks like:
>
> /* emacs -nw doesn't have an NSApp, so we're done. */
> if (NSApp == nil)
> return thread_select (pselect, nfds, readfds, writefds, exceptfds,
> timeout, sigmask);
>
> if (![NSThread isMainThread]
> || (timeout && timeout->tv_sec == 0 && timeout->tv_nsec == 0))
> thread_select (pselect, nfds, readfds, writefds,
> exceptfds, timeout, sigmask);
> else
> {
> struct timespec t = {0, 0};
> thread_select (pselect, 0, NULL, NULL, NULL, &t, sigmask);
> }
>
> and I don't know why. The change (9370a4763aa) has no bug report
> listed and I'm pretty sure I wasn't asked about it, so I have to
> assume Po Lu had some reason for the main thread and timeout checks to
> result in falling-through to the rest of the function.
OK, let's see if Po Lu remembers.
>> One strange thing about threads having their own event queue is that the
>> message Stefan sees comes from the NSApplicaiton::run in ns_select_1. Be
>> that at it may.
>
> Indeed, ns_select_1 is being run in a sub-thread and it therefore runs
> a thread-specific run queue which has no events in it. It requires an
> event to be sent to it so it will stop but none ever is because we
> only ever send events to the main thread's event queue.
What I meant was the the NSApplication::run in ns_select_1 in Stefan's
case seems to call something complaining about being called in the wrong
thread. I guess it would also complain if there were an event in the
queue. I don't know. This whole code gets on my nerves :-).
next prev parent reply other threads:[~2025-01-02 14:03 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-02 4:57 bug#75275: 30.0.92; `make-thread` bug on macOS 15.2 Stefan Kangas
2025-01-02 5:46 ` Gerd Möllmann
2025-01-02 5:55 ` Gerd Möllmann
2025-01-02 6:47 ` Stefan Kangas
2025-01-02 7:12 ` Gerd Möllmann
2025-01-02 14:35 ` Stefan Kangas
2025-01-02 14:38 ` Gerd Möllmann
2025-01-02 14:45 ` Gerd Möllmann
2025-01-02 15:19 ` Stefan Kangas
2025-01-02 16:06 ` Alan Third
2025-01-02 16:47 ` Alan Third
2025-01-02 16:58 ` Eli Zaretskii
2025-01-02 17:09 ` Gerd Möllmann
2025-01-02 17:22 ` Eli Zaretskii
2025-01-02 17:25 ` Gerd Möllmann
2025-01-02 17:42 ` Alan Third
2025-01-02 17:48 ` Gerd Möllmann
2025-01-02 17:37 ` Alan Third
2025-01-02 17:46 ` Gerd Möllmann
2025-01-02 17:52 ` Gerd Möllmann
2025-01-02 19:26 ` Alan Third
2025-01-02 19:59 ` Gerd Möllmann
2025-01-02 16:46 ` Eli Zaretskii
2025-01-02 7:53 ` Eli Zaretskii
2025-01-02 7:58 ` Stefan Kangas
2025-01-02 7:13 ` Eli Zaretskii
2025-01-02 7:30 ` Gerd Möllmann
2025-01-02 8:28 ` Eli Zaretskii
2025-01-02 8:33 ` Gerd Möllmann
2025-01-02 8:41 ` Gerd Möllmann
2025-01-02 8:55 ` Eli Zaretskii
2025-01-02 10:04 ` Gerd Möllmann
2025-01-02 11:03 ` Alan Third
2025-01-02 13:05 ` Gerd Möllmann
2025-01-02 13:53 ` Alan Third
2025-01-02 14:03 ` Gerd Möllmann [this message]
2025-01-02 14:17 ` Alan Third
2025-01-02 15:31 ` Eli Zaretskii
2025-01-02 15:37 ` Gerd Möllmann
2025-01-02 15:55 ` Alan Third
2025-01-02 16:08 ` Gerd Möllmann
2025-01-02 8:51 ` Gerd Möllmann
2025-01-02 7:31 ` Stefan Kangas
2025-01-02 8:31 ` Eli Zaretskii
2025-01-02 10:31 ` Michael Albinus via Bug reports for GNU Emacs, the Swiss army knife of text editors
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m234i1ia7p.fsf@gmail.com \
--to=gerd.moellmann@gmail.com \
--cc=75275@debbugs.gnu.org \
--cc=alan@idiocy.org \
--cc=eliz@gnu.org \
--cc=luangruo@yahoo.com \
--cc=stefankangas@gmail.com \
/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 public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).