From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Gerd =?UTF-8?Q?M=C3=B6llmann?= Newsgroups: gmane.emacs.bugs Subject: bug#75275: 30.0.92; `make-thread` bug on macOS 15.2 Date: Thu, 02 Jan 2025 15:03:54 +0100 Message-ID: References: <86bjwplmc1.fsf@gnu.org> <865xmxlivo.fsf@gnu.org> <86y0ztk323.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="5301"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: Po Lu , 75275@debbugs.gnu.org, Eli Zaretskii , stefankangas@gmail.com To: Alan Third Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Jan 02 15:04:18 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 1tTLoA-0001EO-D8 for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 02 Jan 2025 15:04:18 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tTLnw-0003sj-NW; Thu, 02 Jan 2025 09:04:04 -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 1tTLnv-0003sS-K5 for bug-gnu-emacs@gnu.org; Thu, 02 Jan 2025 09:04:03 -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 1tTLnv-0003dY-AD for bug-gnu-emacs@gnu.org; Thu, 02 Jan 2025 09:04:03 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:Date:References:In-Reply-To:From:To:Subject; bh=d1psWu4N2skRWGLTXhrR8X+KltzZz5l7LOqrLV+U8iQ=; b=W1V7u09SfrSzl1Yu4G7CeXb7jDdsGhQYfavBq65ZcAps1GwEjyfQxXVGhzUXG/u1scbLTBzJI2rc7NPY+yOHjxZB6283KM0/6ZN3gcgH3ZMD7rWIJrIOvEalgkh3yFszNwptZOO49KKyDISDaZm4kWhzcflvMsIjiUn/891izULud2elv4O0Nt5KTmQp4WNjP/YJjZrWBXURgI4O9nLZbmqTdNjholiH7LQKSDhkeDMWAFjAn0IdHaMhF7G8X68nXagd+tx6XpMxBlwOSbsQcPGR/kee3t1n2qLo9JtfR2Tms+bnwn006deHhs8xYXfK0P1qGB48SV8RfKx2I+fabw==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tTLnv-0001pk-3R for bug-gnu-emacs@gnu.org; Thu, 02 Jan 2025 09:04:03 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Gerd =?UTF-8?Q?M=C3=B6llmann?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 02 Jan 2025 14:04: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.17358266397031 (code B ref 75275); Thu, 02 Jan 2025 14:04:03 +0000 Original-Received: (at 75275) by debbugs.gnu.org; 2 Jan 2025 14:03:59 +0000 Original-Received: from localhost ([127.0.0.1]:43253 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tTLnq-0001pL-Ix for submit@debbugs.gnu.org; Thu, 02 Jan 2025 09:03:58 -0500 Original-Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]:47382) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1tTLnp-0001pB-8H for 75275@debbugs.gnu.org; Thu, 02 Jan 2025 09:03:57 -0500 Original-Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-4364a37a1d7so120281585e9.3 for <75275@debbugs.gnu.org>; Thu, 02 Jan 2025 06:03:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1735826636; x=1736431436; darn=debbugs.gnu.org; h=content-transfer-encoding:mime-version:user-agent:message-id:date :references:in-reply-to:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=d1psWu4N2skRWGLTXhrR8X+KltzZz5l7LOqrLV+U8iQ=; b=NwDK42I5alwm1OtiQGI2dfQy9i2mhW4yCstpD1gFW/rph7BsiyV3ZZG298BRwHuc0K ku/S04Lo78b1SgEWVJVG5LHWqW0v6iYuBsXWpW4OQ5rh8UiQ2Qk1HS/Swp+t08xGs9TK QYx7gGKj3gqQeXmO2hkin6d9bYAG2n0bcAqNM2dXqr4JX3znsorl/JK47hD75vUO+aUT XSdP16/3GM7GNYq8ck2/T+N6lijKd3BDegEFAP35/ZhUmApewkOzlNGA2A7cbSf1DtdY OMmpjdODOQrPUjQRrUmjA0ZDuUSP4hw046dK7/ugdms8cAZZ6MtBL9LrIW42IDikKa5b DacA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735826636; x=1736431436; h=content-transfer-encoding:mime-version:user-agent:message-id:date :references:in-reply-to:subject:cc:to:from:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=d1psWu4N2skRWGLTXhrR8X+KltzZz5l7LOqrLV+U8iQ=; b=SmdQ1raOFoNcrC2l8TM4mC2zFHoHbKtVg1j79X9Ev33E9PWBwUxdWYEsyE67KGQ5Z8 5o6qGOx/mcdg1HpUCByDP3DRjVsLvvW4idBXsxralGyJnzmmGsoFmzmFGZ38KK38cmMD lWh/gjFjE9QvGryQJO6VaN+fVpuImB15GX1XUzrLLJViMeuCwS7nJGcPWH52gRhc4jza O0Zgr9JegnydvZGRZQcZTZvwspBtrPG/ghP0JMytWbrZl7yMLkMVTYwSzu/d7lo7pGvN ffVzhxRSwdvPOO8yl8GGRx4Em77hD+ahlodRWkXSLt2XV0VbvEB5EX5+JAkaje46sD8K n0Jw== X-Forwarded-Encrypted: i=1; AJvYcCW8PVeN+K1bD0d29fMr3SZRIHicmcBo4qycFoMLHRQ7q8oq+1rTOO1SrepMPgIqMcoVuuyxFA==@debbugs.gnu.org X-Gm-Message-State: AOJu0YxFYQU+wAS4GWR0JK7mTfrhrm25oxXYg3W7LJpTQLXaQWRFCdZG +AMhSb7MNDsDOwYkuQIccDPF/lFXCsp4OyKINSrahZAdH4mrPzLz X-Gm-Gg: ASbGncsCnPm/bVCsLvHpyPHTQo96nnyz3PLLcfxTDPsvTLbRb5y2FP0oABeCq9z4NLi M0fkIbC0NaHOzsex2yUh8pt4r8krjlSjks9DpP9Tw09WHBlGxobEupBtPN7kq58Hqx4WPzSFQPC /NAtT65hrHgBjbwd7+aBgmMXgc9ApgUgQZ5SjnCxoshEshSflArsGw4k2wNo9GjMQCo62npNn0o 1ZZ/5AsrF8fXT1F/QpjVB8wjmro6CwdB5QttGywI/8yU9lC+IZXszn3Awe4tlAADtobBHJhBCn0 FkVgtigqPYQZSgzOxZOSBa5lqAn/4QuqlOnuYkbYwUBBjKAKNo7V5zUhRCdsxgVv X-Google-Smtp-Source: AGHT+IHAdgLPpwTpNLn6Ti4Embfdoi0QBEjrnIbWBX96Cre/WdEeyCI0RNXcVuJYWKhrCGplKvFF9g== X-Received: by 2002:a05:600c:3b9d:b0:434:f739:7ce2 with SMTP id 5b1f17b1804b1-436686436ecmr366947875e9.8.1735826635828; Thu, 02 Jan 2025 06:03:55 -0800 (PST) Original-Received: from pro2 (p200300e0b7290d009d701914d6a76d9d.dip0.t-ipconnect.de. [2003:e0:b729:d00:9d70:1914:d6a7:6d9d]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-436612899f0sm453727745e9.38.2025.01.02.06.03.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Jan 2025 06:03:55 -0800 (PST) In-Reply-To: (Alan Third's message of "Thu, 2 Jan 2025 13:53:58 +0000") 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:298168 Archived-At: Alan Third writes: > On Thu, Jan 02, 2025 at 02:05:44PM +0100, Gerd M=C3=B6llmann wrote: >> Alan Third writes: >>=20 >> > 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. >>=20 >> So IIUC, you'd write this in ns_select_1 >>=20 >> if (![NSThread isMainThread] >> || (timeout && timeout->tv_sec =3D=3D 0 && timeout->tv_nsec =3D=3D= 0)) >> thread_select (pselect, nfds, readfds, writefds, >> exceptfds, timeout, sigmask); >>=20 >> as return "return thread_select(...)"? > > I don't know. The code that in Emacs 29 looked like: > > if (NSApp =3D=3D nil > || ![NSThread isMainThread] > || (timeout && timeout->tv_sec =3D=3D 0 && timeout->tv_nsec =3D=3D = 0)) > return thread_select (pselect, nfds, readfds, writefds, > exceptfds, timeout, sigmask); > else > { > struct timespec t =3D {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 =3D=3D nil) > return thread_select (pselect, nfds, readfds, writefds, exceptfds, > timeout, sigmask); > > if (![NSThread isMainThread] > || (timeout && timeout->tv_sec =3D=3D 0 && timeout->tv_nsec =3D=3D = 0)) > thread_select (pselect, nfds, readfds, writefds, > exceptfds, timeout, sigmask); > else > { > struct timespec t =3D {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 :-).