From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: =?utf-8?Q?Gerd_M=C3=B6llmann?= Newsgroups: gmane.emacs.devel Subject: Re: master 4ac4cec652f: Prevent freezes on macOS (bug#69561) Date: Wed, 13 Mar 2024 09:48:28 +0100 Message-ID: References: <171031025289.32157.8913441761015064536@vcs2.savannah.gnu.org> <20240313061054.71155C1FB4A@vcs2.savannah.gnu.org> <87wmq6vam3.fsf@yahoo.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="27598"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: emacs-devel@gnu.org, Gerd =?utf-8?Q?M=C3=B6llmann?= To: Po Lu Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Wed Mar 13 09:49:22 2024 Return-path: Envelope-to: ged-emacs-devel@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 1rkKIb-0006uP-Vz for ged-emacs-devel@m.gmane-mx.org; Wed, 13 Mar 2024 09:49:22 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rkKI1-0002Dm-VQ; Wed, 13 Mar 2024 04:48:46 -0400 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 1rkKHq-0002DH-7C for emacs-devel@gnu.org; Wed, 13 Mar 2024 04:48:35 -0400 Original-Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rkKHo-0008P1-Cx; Wed, 13 Mar 2024 04:48:33 -0400 Original-Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-413eb7cf7dfso1185565e9.0; Wed, 13 Mar 2024 01:48:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1710319710; x=1710924510; darn=gnu.org; h=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=mTQP4u7z0q+d3bvRX+OmfkQX3GkhFrj6XfAixQRG5uY=; b=BJjtErYZ9hE3rHYK+/lf8JRSLIugLZcNXk+JuFbTtPDplGmFexP+BL2r39bDGaGCQy mSdOHb2ar46LjdwRIGK/9n8gtYkGNZGwUzPa9ACbF8okwOwbIXozx/9V5zjpogzmeL3W nrmwslkI4tn8jYAH3QrCg+fLMFTp5Okuo/kXKhkLmCE9AOsLZMvIMo3O5mCUT7iZuRN+ syM+Tsn0e0TDAzpxz7nAe3KSC7+in81ArgJIVYqxgRcIYZ4KrWYXXW3PMz3P1EW9kwAA 2cDU5jPXbPk3cnAEh2dcpe2QCgEw/Qyua7nUzMbJpdNUDkBScnUX51gC6xYhlhG4cK0/ /ggQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710319710; x=1710924510; h=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=mTQP4u7z0q+d3bvRX+OmfkQX3GkhFrj6XfAixQRG5uY=; b=FIMrI7D8jtXbm1WBBtw896Wlp2sjmSfzVmY8n2g5gA4H1Zht/aeBbWmLEa37B/FSpr +KPywmabzxSOgOhgfMjU60n7A7Ta/3idFuTjUYKKo6x1hlxYWzQEr2IWaNJancoO3x1J 4TDXMQNT7HCEc4c19wlQjTUIaIL2ZQ8ZoOAeP3BP7weCynQdx9MtuupA5QrtNp6HI2ql wRzBad3xS3RingIxqs6nb7RQAlExU/B0AsfOGw6s9IlokbuOAKdCRRfwJCcwLCNgEvNN BFqhKzHJPgKNbyOs1jLa8prvaBCxMNf4/XolnxEzb/F1UBIKgT8CMcl9fm0ywj8FqwbV Ps+g== X-Forwarded-Encrypted: i=1; AJvYcCW69wTtpgpMZ1EDmr2bTK16CcDw5rFKBOy/ja9L9Pc6AKgENTWsFp67DThKy7stz75AofwxHEuQ/1Sc8Lg= X-Gm-Message-State: AOJu0YzZ9LRVnORui7jiNkqll7XLs3oqNda4sJgpdSp3nM/vEsBuWuXZ mhl3Sful+9nx2L8t7fLeYaJ+sEYpZbGXXXjz/0rldNg9B0tHx/qLWLjI2Uyp X-Google-Smtp-Source: AGHT+IE5gPSfmMMzLdd2Vx8nj0OS89FKQiOjb4AdPX8XvvujNcPzzxOXdoB/ktHhzvXc8Do7ZbotIA== X-Received: by 2002:a05:600c:310b:b0:412:f243:3699 with SMTP id g11-20020a05600c310b00b00412f2433699mr1685656wmo.18.1710319709833; Wed, 13 Mar 2024 01:48:29 -0700 (PDT) Original-Received: from Pro.fritz.box (pd9e36f1a.dip0.t-ipconnect.de. [217.227.111.26]) by smtp.gmail.com with ESMTPSA id o18-20020a05600c4fd200b004132f9cf053sm1601793wmq.33.2024.03.13.01.48.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Mar 2024 01:48:29 -0700 (PDT) In-Reply-To: <87wmq6vam3.fsf@yahoo.com> (Po Lu's message of "Wed, 13 Mar 2024 15:45:08 +0800") Received-SPF: pass client-ip=2a00:1450:4864:20::32c; envelope-from=gerd.moellmann@gmail.com; helo=mail-wm1-x32c.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:317028 Archived-At: Po Lu writes: > Gerd Moellmann writes: > >> if (NSApp == nil >> || ![NSThread isMainThread] >> || (timeout && timeout->tv_sec == 0 && timeout->tv_nsec == 0)) >> - return thread_select (pselect, nfds, readfds, writefds, >> - exceptfds, timeout, sigmask); >> + thread_select (pselect, nfds, readfds, writefds, >> + exceptfds, timeout, sigmask); > > Far be it from me to offer advice on code I know very little about, but > on the surface this appears to force non-main threads to enter [NSApp > run] whenever they enter select. Is this really the desired behavior? > > I should think that this function, being provided by the toolkit for the > purpose of running its event loop, must be called by strictly one thread > at a time. Well, let me first make the usual disclaimer that I don't know much about about Cocoa. (And don't really want to, I must admit ;-)). I couldn't find much advice which I'd call definite on using Cocoa from multiple threads, except https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/Multithreading/ThreadSafetySummary/ThreadSafetySummary.html#:~:text=Guidelines%20for%20using%20Cocoa%20from,are%20generally%20not%20thread%2Dsafe. I interpret this as meaning that it's possible to do this, considering that Emacs' threads run one at a time only, AFAIU. If that's no longer the case, we have a problem, I agree.