From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Alan Third Newsgroups: gmane.emacs.bugs Subject: bug#75275: 30.0.92; `make-thread` bug on macOS 15.2 Date: Thu, 2 Jan 2025 13:53:58 +0000 Message-ID: References: <86bjwplmc1.fsf@gnu.org> <865xmxlivo.fsf@gnu.org> <86y0ztk323.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="6234"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Po Lu , 75275@debbugs.gnu.org, Eli Zaretskii , stefankangas@gmail.com To: Gerd =?UTF-8?Q?M=C3=B6llmann?= Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Jan 02 14:55:23 2025 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1tTLfX-0001Qw-Ba for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 02 Jan 2025 14:55:23 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tTLfJ-0002U7-3Q; Thu, 02 Jan 2025 08:55:09 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tTLfE-0002T7-IT for bug-gnu-emacs@gnu.org; Thu, 02 Jan 2025 08:55:04 -0500 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tTLfE-0002D5-7m for bug-gnu-emacs@gnu.org; Thu, 02 Jan 2025 08:55:04 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=In-Reply-To:MIME-Version:References:From:Date:To:Subject; bh=0BSKz/RcIIvh8rQJ38q697h9DuapeKt+TnsNlJPWG/8=; b=lftiahBd1tVdz1wlOwTp0jSImAblzefTdXqrHdwjm3ln+Vr/nOV6dxob/m7VQYg19cZ2RFgft0+m+FUSSL1Iofv+GLbySqoVcBBVnAopql5a0jC9XR+nlyOgb4y2kC/Z+r4B9mprNaW7GnXVs4cNZNQg4d07Hkt5I83Gcxsd4RSDiwmUGXm9wvUndrvJ1LwE324HxDHT6dkBQWhJPwRC9KuchnrKS61m9GEI+iV7VKMIiy4t1sJ7HnM/CNJeXc0/bw22ZB223Q0ZCLH03ZBQnc3VffA+LX9/2l5Vo5K7lvxt4nTl7Pol/vWom9VyfyIrUk2iv+eOtDSN8baTg1/FtQ==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tTLfD-0001Hz-Tq for bug-gnu-emacs@gnu.org; Thu, 02 Jan 2025 08:55:03 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Alan Third Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 02 Jan 2025 13:55:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 75275 X-GNU-PR-Package: emacs Original-Received: via spool by 75275-submit@debbugs.gnu.org id=B75275.17358260564875 (code B ref 75275); Thu, 02 Jan 2025 13:55:03 +0000 Original-Received: (at 75275) by debbugs.gnu.org; 2 Jan 2025 13:54:16 +0000 Original-Received: from localhost ([127.0.0.1]:43208 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tTLeR-0001GZ-Dz for submit@debbugs.gnu.org; Thu, 02 Jan 2025 08:54:16 -0500 Original-Received: from dane.soverin.net ([185.233.34.149]:35483) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1tTLeJ-0001Fg-OI for 75275@debbugs.gnu.org; Thu, 02 Jan 2025 08:54:13 -0500 Original-Received: from smtp.soverin.net (c04smtp-lb01.int.sover.in [10.10.4.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by dane.soverin.net (Postfix) with ESMTPS id 4YP7V01gLfzySk; Thu, 2 Jan 2025 13:54:00 +0000 (UTC) Original-Received: from smtp.soverin.net (smtp.soverin.net [10.10.4.99]) by soverin.net (Postfix) with ESMTPSA id 4YP7Tz2gGzzL7; Thu, 2 Jan 2025 13:53:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=idiocy.org; s=soverin; t=1735826040; bh=2orCO/vaM4OVEmJtSrnb1LAWYBuO8ab1zmlVFc7cD3E=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Zj3lyAfS15QhzTMl87HoyxhWeUHRvH8IfsNfCOSNdsDAK35fE15RNjEtEXwUjela0 PPvWPmhprkI/U83L4KLAuVfyuQ4yU9dQuUDbbk0qZINv6fmC3otuGqNtE9E3daMBus 5BLnTA8z+8gI2QUTT19VCK2vuKHv58tfHmUVrHRSMSPI3ROqQ8jH2IH3ggKvwmq5w6 scVslp57rduds1Av9bR1k7Hj/G5xsuEga6UXpIyOP4BvRYrb5aAjbCf9ZIFwbeY82C UvH+fJdHSFXd5O8xLOBxYI24jnMDuhil29v9j4almZN04LEBrqfrVkaHKCDnBhsIva WhgrDN0Tg3Qkw== X-CM-Envelope: MS4xfC8IpSF9oVblggsLRiAY/l5kFZnYtqm2e2M52/SUJvMAPGHSvVT3PHnu5Q1xfRD3s2bXUSKKftuB+/kqLFZwe2BElL/umYInTbGk6/cMQs7PFTr1I1Qg lePXfyiSMg8TWKgSASFR3ccKAD7Qa/so7uhe2LCSNPVxunLnYiEhgZ58TXk4HG5yUqV68HDWj5BVSeHSUFIwEDqGvos52xOSvC/ej+RbbqveSrQi1zs0WvEi VSlZ85m4G+Xh2nnz58edSsIZ0ygEpBD4RbwbYKmHBdfUvDFuE1K2qH6glBGsm9uLf2wg4CzgJ7q4COKBJqffP2wXpH5wfMXa1wb0Ia3kYYs= X-CM-Analysis: v=2.4 cv=UsCZN/wB c=1 sm=1 tr=0 ts=67769a77 a=UbsBXRcqaZ6D9kgPt/Dvnw==:617 a=xqWC_Br6kY4A:10 a=8nJEP1OIZ-IA:10 a=VdSt8ZQiCzkA:10 a=hIj89exaAAAA:8 a=-rFPl6gYrVxbYPGSLJkA:9 a=3ZKOabzyN94A:10 a=wPNLvfGTeEIA:10 a=lS9wXHQM5UdnNJ4u63Ry:22 a=9MSFP0l5Dcwi9NrB_JPx:22 Original-Received: from localhost (faroe.holly.idiocy.org [local]) by faroe.holly.idiocy.org (OpenSMTPD) with ESMTPA id b6ec9783; Thu, 2 Jan 2025 13:53:58 +0000 (UTC) Mail-Followup-To: Alan Third , Gerd =?UTF-8?Q?M=C3=B6llmann?= , Eli Zaretskii , stefankangas@gmail.com, 75275@debbugs.gnu.org, Po Lu Content-Disposition: inline In-Reply-To: X-Spampanel-Class: ham X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:298165 Archived-At: On Thu, Jan 02, 2025 at 02:05:44PM +0100, Gerd Möllmann wrote: > Alan Third 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. > 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. -- Alan Third