From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Daniel Colascione Newsgroups: gmane.emacs.devel Subject: Re: SIGPROF + SIGCHLD and igc Date: Mon, 30 Dec 2024 12:53:49 -0500 Message-ID: <5A733BD6-6077-4705-B9BB-B465859D3F2C@dancol.org> References: <87o713wwsi.fsf@telefonica.net> <86frm7sx4d.fsf@gnu.org> <87a5cfoivh.fsf@gmail.com> <87r05reh9t.fsf@protonmail.com> <87msgfmvrp.fsf@gmail.com> <87bjwvedzn.fsf@protonmail.com> <86ttanqc0p.fsf@gnu.org> <87bjwu2pb6.fsf@protonmail.com> <86pll9nrgz.fsf@gnu.org> <87seq5xgpt.fsf@protonmail.com> <86ikr1njuv.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="21555"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: K-9 Mail for Android Cc: eller.helmut@gmail.com, gerd.moellmann@gmail.com, ofv@wanadoo.es, acorallo@gnu.org To: emacs-devel@gnu.org, Eli Zaretskii , Pip Cet Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon Dec 30 18:54:57 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 1tSJyi-0005Sh-LC for ged-emacs-devel@m.gmane-mx.org; Mon, 30 Dec 2024 18:54:57 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tSJyJ-00048u-Ib; Mon, 30 Dec 2024 12:54:33 -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 1tSJxy-00047R-TE for emacs-devel@gnu.org; Mon, 30 Dec 2024 12:54:12 -0500 Original-Received: from dancol.org ([2600:3c01:e000:3d8::1]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tSJxq-0008S7-Rr; Mon, 30 Dec 2024 12:54:09 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=dancol.org; s=x; h=Content-Transfer-Encoding:Content-Type:MIME-Version:Message-ID: References:In-Reply-To:Subject:CC:To:From:Date:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=Vwq8yf/NGnlGPC7koMXHUVd2KUpCzRNkKDjL8YPdSt0=; b=bgoyXgZwGVbYnKebhwlJSw2hIZ eTzBMFPk9Vu/F3IzbVs5kQW44HLa5v/BGldXgCDH5IMKFPxgJsMUwGIbbN7o2nzxaJMdQFlRJTLNh Eufa6HTZkfVw7FM63W2tiSexvzGEoC+no064KvFcv5n+aH1T8yAYGrCdgpuw9IFLcpVQLSfCj9ndD T0ZnoKZisNqcNIW28iKHeMXfV81YKNVftkHV6tJLDKAoPIDeiafHZTrne6r9Q9+Ot90i5WRso36Og AqrgQdg0+gzbGCoVTlujB6kUV9hE5GrgzGMS5qlIjVYE1Ay5suRWlQdDKdPqRlHQNX5FHclTyOmje FjW8xrEw==; Original-Received: from 2603-9001-4203-1ab2-3ff8-4d1b-9285-6dd0.inf6.spectrum.com ([2603:9001:4203:1ab2:3ff8:4d1b:9285:6dd0]:52974 helo=[IPv6:::1]) by dancol.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1tSJxm-0006kk-0Z; Mon, 30 Dec 2024 12:53:58 -0500 In-Reply-To: <86ikr1njuv.fsf@gnu.org> Received-SPF: pass client-ip=2600:3c01:e000:3d8::1; envelope-from=dancol@dancol.org; helo=dancol.org 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, SPF_HELO_PASS=-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:327457 Archived-At: On December 30, 2024 12:47:36 PM EST, Eli Zaretskii wrote= : >> Date: Mon, 30 Dec 2024 16:46:20 +0000 >> From: Pip Cet >> Cc: eller=2Ehelmut@gmail=2Ecom, gerd=2Emoellmann@gmail=2Ecom, ofv@wanad= oo=2Ees, emacs-devel@gnu=2Eorg, acorallo@gnu=2Eorg >>=20 >> We can't avoid re-killing because we might be on another thread=2E > >If we are on another thread, we know that, and can delay running the >body=2E Or we could just run the body (all the signal handlers we have >that I know about don't care: MS-Windows already does that)=2E So this >problem doesn't exist in practice, IME=2E > >> We shouldn't avoid it because we want signal handlers to be called >> in signal handler context, not as C functions=2E > >Actually, no, we have no problems running the handlers we have as C >functions=2E Again, the MS-Windows build does that for years=2E > >> > =2E signal handler is called >> > =2E if the arena is unlocked, it runs the handler's body >>=20 >> (BTW, if we're going for POSIX-conforming solutions, we can't call >> pthread_mutex_trylock in a signal handler=2E > >We do it today, because that's how MPS crashes us=2E So yes, we can do >that=2E > >> > =2E otherwise, it sets a flag to indicate the signal happens and ex= its >>=20 >> Which retriggers the signal > >No, it doesn't=2E Again, we already have signals whose handlers behave >like that=2E > >> > - when the arena is unlocked, we are called, and run the handler'= s body >>=20 >> Do you mean "run the handler's body" or "try again"? I'm not sure >> running it unconditionally is safe, so I'd prefer to "try again", >> re-establishing a signal handler context by unblocking the signal and >> re-killing the main thread (even if that's us)=2E > >I see no reason why it would be unsafe to just run it=2E Again, our >handlers are simple and usually do very little (SIGCHLD is a possible >exception, but we already have a solution for it, AFAIU)=2E > >> We can't run another thread's signal handler=2E > >Not in general, but in practice in Emacs we can (and do)=2E > >> Again, I think this is a good idea, but I'd use it as an improvement to >> the current protection code, not to replace it=2E > >I think you are over-complicating things because you are looking for a >110% waterproof solution that would work for arbitrary code in the >handler=2E But we don't need such perfection, as the existing practices >show=2E > The code there TODAY might not need to be "waterproof", but someone might = add logic one day that violates the unstated simplifying assumptions on whi= ch you're relying=2E In this case, we'll end up with subtle and hard to dia= gnose race conditions=2E Better to make the mechanism robust from the start= =2E Trying to take shortcuts with POSIX signals is penny wise and pound foo= lish=2E