From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Helmut Eller Newsgroups: gmane.emacs.devel Subject: Re: igc, macOS avoiding signals Date: Mon, 30 Dec 2024 11:27:58 +0100 Message-ID: <87cyh9mpn5.fsf@gmail.com> References: <799DDBC5-2C14-4476-B1E0-7BA2FE9E7901@toadstyle.org> <86ed1rswup.fsf@gnu.org> <87h66loc17.fsf@gmail.com> <878qrxoayj.fsf@gmail.com> <8734i5o6wc.fsf@gmail.com> 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="1925"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: Eli Zaretskii , spd@toadstyle.org, pipcet@protonmail.com, emacs-devel@gnu.org To: Gerd =?utf-8?Q?M=C3=B6llmann?= Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon Dec 30 11:28:55 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 1tSD15-0000Qi-DU for ged-emacs-devel@m.gmane-mx.org; Mon, 30 Dec 2024 11:28:55 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tSD0J-0008CU-FZ; Mon, 30 Dec 2024 05:28:07 -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 1tSD0F-0008CE-Bo for emacs-devel@gnu.org; Mon, 30 Dec 2024 05:28:03 -0500 Original-Received: from mail-ed1-x529.google.com ([2a00:1450:4864:20::529]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tSD0D-0007Hn-Nn; Mon, 30 Dec 2024 05:28:03 -0500 Original-Received: by mail-ed1-x529.google.com with SMTP id 4fb4d7f45d1cf-5d3dce16a3dso15862797a12.1; Mon, 30 Dec 2024 02:28:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1735554480; x=1736159280; darn=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=DllVol9qZtt4eTdFqxmf4JV6mooeP25UPscAD5Xuddk=; b=Hxe+moYJkAT9XJGNwdAdoquRV5tNHuJI30vkZECzlcD/1d4B7AbRFRimcz7eEssAGQ IgHPB+sLRBC/FEgrWsUli3ytkE/Dl3HP77K0kTPntXF/sb+2cXa04M5DhwWEfB8rwIIe HQIuY5vwInJALKo2ZJ6lwAAgl5lUKzwA/TjwENp3QRyCEvrQ7pBwhJJoltSBk/JbJ+2g qTlMrDLGK/ONn0HtihfxVlB0dRHg136Q6GLJz/Sh8fOGPZEk386qlU3coQ2GR79snsuZ Nq8aEsHwodQhCoi7mkVawIQfl9bue+4v4qj14fbTXzgWnywohBkSzu5sQ/KqJobNKV0w q9gA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735554480; x=1736159280; 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=DllVol9qZtt4eTdFqxmf4JV6mooeP25UPscAD5Xuddk=; b=EQSLtbrNTL2Gbjf14L6fCSkuM5xYS/Lh46d+iRkliJH6+GqjQLwtWOUgh9kix2HID9 QDxcsvqyNQ5HEKBUuuUQrDoIAYv80ZndUaE4dKgAgoh0NhIDByUh8WTvmiPEKH682CuF /FGkdRGp/ucG5nhxIrnfvS2QfzskFjKdd11Brg4dWYkJ5UbvzGB/KPYKKtegMO1SvZNK nA/19T9gvpZEN8VOMH8ui+YUQygSvARZ7EppJvmzSwT0ZuuP9Ac53o71UM0IifAMZuGO 3z7gu1LqhKesnkA/gJHuDHy2xvvHP89vGsQDwu9r8yIwwjK2bM8Hwf4PrxIWGt18wjbp DViA== X-Forwarded-Encrypted: i=1; AJvYcCW5vbg+hJj1rFISy5ungL3P+Zl7kYUNgjzPer4QkBvMPIxXwXzb3/dAA5Upyi3P3xe5f0Cf5PNAfseQww==@gnu.org X-Gm-Message-State: AOJu0YxuEV2jM3a14LrluwsrQhnv6jm/3U/johNZwdJCdMY6YW8p9OU6 +hnxPkwPtonhbw8yTqRbLh6+ixOpn5ZwuzYeYE1Tsr38TU4GjZdA4teDeEB4 X-Gm-Gg: ASbGnctn3ryk29bGJ1p+GfgfJnZHvh/QtxyMghocqnJKBYnXFDry2W98fsxIOdXWX4v 3cGIEJVS7AwuNZNIhHPAJXeHtlJ402QA7GYd5OdVB2354MtIJq9b9dzN6eL/vF8LrayM7TjOUUi 0FC776aNGY88qn/1HiERToS+fkFptKFfJ/U520dk/CkGTvuLjrglf6qMU309swSrhsIi4pqCUmR /9wxFROErvRyOwC9DTwmbSSdYPlGspZ0nxhcgPT7pSbvvBXHYdOkL0= X-Google-Smtp-Source: AGHT+IEuOgmrxzO8qOydacq2ElZlBLUMC8d5+5nF9vHLanMqRqu/gvkS57dfW1eLQUnZr7sOi3U8wA== X-Received: by 2002:a05:6402:401f:b0:5d6:3716:950e with SMTP id 4fb4d7f45d1cf-5d81e8c1344mr31530753a12.11.1735554479627; Mon, 30 Dec 2024 02:27:59 -0800 (PST) Original-Received: from caladan ([31.177.115.143]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5d806fed2a1sm15059624a12.67.2024.12.30.02.27.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Dec 2024 02:27:59 -0800 (PST) In-Reply-To: ("Gerd =?utf-8?Q?M=C3=B6llmann=22'?= =?utf-8?Q?s?= message of "Mon, 30 Dec 2024 11:05:44 +0100") Received-SPF: pass client-ip=2a00:1450:4864:20::529; envelope-from=eller.helmut@gmail.com; helo=mail-ed1-x529.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 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:327400 Archived-At: On Mon, Dec 30 2024, Gerd M=C3=B6llmann wrote: >> My interpretation of this design document[*], is that MPS's arena lock >> protects most of MPS entry points. There are a few (e.g. mps_reserve >> and mp_ld_add) that don't claim the arena lock and for those it's the >> burden of the client to call them in a thread safe way. For us this >> probably means: don't call them in a signal handler. >> >> The main entry point that we want to call in the signal handler is the >> SEGFAULT handler (not sure how this works on MacOS). The fault handler >> claims the non-recursive arena lock. So, in the signal handler we >> should not hold the lock while hitting a barrier. > > Okay, that I think I understand then. The "only" difference between > macOS and Linux is that on macOS no SEGV handler is involved. Hitting > the barrier on macOS means that the EXC_BAD_ACCESS port thread, which > was waiting for Mach message, receives a message from the OS and starts > working. I guess that both, macOS and Linux version, will end up in ArenaAccess. Perhaps on macOS in the other thread. >>> I think I understand that, except when the Emacs thread is interrupted >>> while in MPS code, which happens for allocation points running out of >>> memory and mps_arena_step (idle time). >> >> Hmm, is that sentence incomplete? I don't quite understand it. > > What I meant is that I imagine a signal interrupts the Emacs thread at a > point where we are "in MPS". AreaEnter/Leave I think I understand, it's > some pthread_mutex_t, I think, from other mails. A problematic "in MPS" > could then be "while the Emacs thread owns the mutex". The places where > I imagine that mutex could be owned are mps_arena_step (I call it Emacs > is idle) and mps_commit (in alloc_impl, when the allocation point used > runs out of memory). Maybe other places, but mainly these two. Yes. > And the question on macOS for me would be if the port thread tries to > qcquire the same mutex, or how the heck that works. Or IOW, if there is > a problem, why I've never seen it happening in all that time I'm using > igc. Maybe you could set a breakpoint in AreaAccess to find out which thread removes the barriers. > I find that difficult to understand. But it may be just a > statistical phenomenon. Maybe filling up an APs memory is so fast so > that the probability of a signal hitting while owning the mutex is close > to zero, or something.=20 Very few of Emacs' signal handlers actually touch a barrier. I've also not seen any reproducable receipes for the "signal issues" that the igc branch supposedly has. Helmut