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 16:06:25 +0000 Message-ID: References: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="q6gNDNEXHHafaEcm" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="40228"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Gerd =?UTF-8?Q?M=C3=B6llmann?= , 75275@debbugs.gnu.org, Eli Zaretskii To: Stefan Kangas Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Jan 02 17:07:24 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 1tTNjH-000AFX-Gk for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 02 Jan 2025 17:07:23 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tTNiy-0002AJ-EL; Thu, 02 Jan 2025 11:07: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 1tTNiw-0002A6-F0 for bug-gnu-emacs@gnu.org; Thu, 02 Jan 2025 11:07:02 -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 1tTNiw-00084u-5f for bug-gnu-emacs@gnu.org; Thu, 02 Jan 2025 11:07:02 -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=nIMuyauwbyM4wMuKEQPaeLCDofS4ORd/rppGEF7jtLg=; b=uusRtwYlbKgudSeP+So5Rlkh6vZJr4/ebqO0B0aYQnE/rBGOSmEJp/SnRphvl10/7dBFXhUywKmkx20oQ4IGg/7CBu07BmIJIq31ON2IaBG1Bqg03R5ztbmaoSI+T2BjCnHGHpcWN2eOpetIF7sR4EbYmlMudGRjRlTzvs6YkNNeZ1NAzf1EXjTySG0FlZHjJcthiOV5SojynfJnDjXSmTHzO2oaXciYdA8clHV70kLtESg7t1JvpDhH16KuKX+bXigKz4H4NuW1Y5lfZD7JlP0IiIUWQzeoNB/640rUUTY/t7Vswh4O0/uUyPDDUu1jgvBYOWe4z0BSG2GzBN0Y8A==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tTNiv-0000WR-Ok for bug-gnu-emacs@gnu.org; Thu, 02 Jan 2025 11:07:01 -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 16:07:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 75275 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: confirmed Original-Received: via spool by 75275-submit@debbugs.gnu.org id=B75275.17358339981957 (code B ref 75275); Thu, 02 Jan 2025 16:07:01 +0000 Original-Received: (at 75275) by debbugs.gnu.org; 2 Jan 2025 16:06:38 +0000 Original-Received: from localhost ([127.0.0.1]:46254 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tTNiX-0000VV-OH for submit@debbugs.gnu.org; Thu, 02 Jan 2025 11:06:38 -0500 Original-Received: from dane.soverin.net ([2a10:de80:1:4092:b9e9:2296:0:1]:33077) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1tTNiU-0000VA-J0 for 75275@debbugs.gnu.org; Thu, 02 Jan 2025 11:06:36 -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 4YPBQp74vPzKh; Thu, 2 Jan 2025 16:06:26 +0000 (UTC) Original-Received: from smtp.soverin.net (smtp.soverin.net [10.10.4.100]) by soverin.net (Postfix) with ESMTPSA id 4YPBQp3ykYzC8; Thu, 2 Jan 2025 16:06:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=idiocy.org; s=soverin; t=1735833986; bh=ci/XmvFlNckshaXPIUcuicM+tfR/efr6FZqb+aCoZ6Y=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=j6YTGG8tHhtJ9E5xyfcTtztvcWwtS9CCEfOb6VRP+lk2CXdESJ6Czw3cB2BwgmA+H 0/nnwS70fD7ufVUgfU25AJx+ubkJms9M+oykKztPSoHkklTwcnwrKJAIgURLXbztpq 6ZUyD1nQmxfn+RtVYa2UaJoi4b+5ijipdgVy34VSI3relbgfB94kGgRbyOJA+KVjR5 4ul4ipr51B/UUHZFZdVOZHwKtFIPbiUPVZVsX/K8WyXIQgXLPLbLsbRzHESFHsfXn5 z5OCgi1bAukgQWL4pEnY/6ZZ7EOdPeA2vv/BJ42ykucKClIj9D0fgpQnyUZaruL9Km YcNPMo2CblXFw== X-CM-Envelope: MS4xfHUuyHLlZ9mGKpLn9l+KkLJ3uAMKNuGwQXyWCis1Ku5XKDj/DhsfH7nxpcBbOo16iph7mOnSVpO73gOvQyMKoTw1IxSbSA9YXcNyNzxYJA6RUUJLPjT/ eJeJiCDryjr5nZZwzEDZAkqp59owAwIaOp2/zUBAPgraJ16arfldTjbmrIj/5iXv1bOL7pykmeZTBkyR5XuqveEZUzyN6HdvQU0OsFv62vixx0d7qBaXup8f G6NJyPguE1sHTW4BKvJpIGM74I2yiUuOI2RhQpdSK9U+YXVDfbi/bUVnJDTfiOhPgV7qWigbGTTrncE51Z0IU6K9YtlfyjVMXvHBcpHGUTw= X-CM-Analysis: v=2.4 cv=e8f8Sbp/ c=1 sm=1 tr=0 ts=6776b982 a=SEWtJhW1qPLXjQrMhrOCWw==:617 a=xqWC_Br6kY4A:10 a=IyVuqPy-3UG8q-HI7ZcA:9 a=CjuIK1q_8ugA:10 a=hIj89exaAAAA:8 a=Bjl_9Qrc-hz0sYYJxfEA:9 a=lS9wXHQM5UdnNJ4u63Ry:22 Mail-Followup-To: Alan Third , Stefan Kangas , Gerd =?UTF-8?Q?M=C3=B6llmann?= , 75275@debbugs.gnu.org, Eli Zaretskii 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:298186 Archived-At: --q6gNDNEXHHafaEcm Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Thu, Jan 02, 2025 at 09:19:36AM -0600, Stefan Kangas wrote: > That patch fixes it for me, indeed. Thanks! Hi Stefan, any chance you could check this version? I have a suspicion that Gerd's will break C-g again. I'm not sure this will be suitable for Emacs 30 though as it's a slightly larger change. The C-g thing is hard to test as I think it relied on Gerd's machine randomly hanging and him hammering C-g and it doing nothing. I'm not sure how to replicate that original hang. -- Alan Third --q6gNDNEXHHafaEcm Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="0001-Fix-C-g-handling-on-NS-bug-75275.patch" >From 528dcb934485a5a1331b4cf851216a3750df3210 Mon Sep 17 00:00:00 2001 From: Alan Third Date: Thu, 2 Jan 2025 15:56:20 +0000 Subject: [PATCH] Fix C-g handling on NS (bug#75275) * src/nsterm.m (ns_select_1): Remove function. (ns_select): Reinstate by copying the contents of ns_select_1 back in. Add check for C-g at top. Stop fall-through to NS run loop when not required. ([EmacsView showFontPanel]): Just call [NSApp run] directly, calling ns_select for this makes ns_select more complex. --- src/nsterm.m | 44 ++++++++++++++++++-------------------------- 1 file changed, 18 insertions(+), 26 deletions(-) diff --git a/src/nsterm.m b/src/nsterm.m index a4398e79211..652eee1f988 100644 --- a/src/nsterm.m +++ b/src/nsterm.m @@ -4826,9 +4826,9 @@ Function modeled after x_draw_glyph_string_box (). static int -ns_select_1 (int nfds, fd_set *readfds, fd_set *writefds, - fd_set *exceptfds, struct timespec *timeout, - sigset_t *sigmask, BOOL run_loop_only) +ns_select (int nfds, fd_set *readfds, fd_set *writefds, + fd_set *exceptfds, struct timespec *timeout, + sigset_t *sigmask) /* -------------------------------------------------------------------------- Replacement for select, checking for events -------------------------------------------------------------------------- */ @@ -4837,6 +4837,7 @@ Function modeled after x_draw_glyph_string_box (). int t, k, nr = 0; struct input_event event; char c; + NSEvent *ev; NSTRACE_WHEN (NSTRACE_GROUP_EVENTS, "ns_select"); @@ -4844,15 +4845,16 @@ Function modeled after x_draw_glyph_string_box (). check_native_fs (); #endif - /* If there are input events pending, store them so that Emacs can - recognize C-g. (And we must make sure [NSApp run] is called in - this function, so that C-g has a chance to land in - hold_event_q.) */ - if (hold_event_q.nr > 0) + /* Check if there are any C-g events on the queue. */ + while ([NSThread isMainThread] + && (ev = [NSApp nextEventMatchingMask:NSEventMaskKeyDown + untilDate:nil + inMode:NSDefaultRunLoopMode + dequeue:NO])) { - for (int i = 0; i < hold_event_q.nr; ++i) - kbd_buffer_store_event_hold (&hold_event_q.q[i], NULL); - hold_event_q.nr = 0; + if ([ev modifierFlags] == NSEventModifierFlagControl + && [[ev charactersIgnoringModifiers] isEqualToString:@"g"]) + Vquit_flag = Qt; } eassert (nfds <= FD_SETSIZE); @@ -4863,13 +4865,10 @@ Function modeled after x_draw_glyph_string_box (). } /* 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] + if (NSApp == nil + || ![NSThread isMainThread] || (timeout && timeout->tv_sec == 0 && timeout->tv_nsec == 0)) - thread_select (pselect, nfds, readfds, writefds, + return thread_select (pselect, nfds, readfds, writefds, exceptfds, timeout, sigmask); else { @@ -4992,14 +4991,6 @@ Function modeled after x_draw_glyph_string_box (). return result; } -int -ns_select (int nfds, fd_set *readfds, fd_set *writefds, - fd_set *exceptfds, struct timespec *timeout, - sigset_t *sigmask) -{ - return ns_select_1 (nfds, readfds, writefds, exceptfds, - timeout, sigmask, NO); -} #ifdef HAVE_PTHREAD void @@ -6790,7 +6781,8 @@ - (Lisp_Object) showFontPanel && [[fm fontPanel: YES] isVisible] #endif ) - ns_select_1 (0, NULL, NULL, NULL, &timeout, NULL, YES); + + [NSApp run]; unblock_input (); if (font_panel_result) -- 2.41.0 --q6gNDNEXHHafaEcm--