From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Pip Cet Newsgroups: gmane.emacs.devel Subject: Re: MPS: a random backtrace while toying with gdb Date: Mon, 01 Jul 2024 17:27:49 +0000 Message-ID: References: <87bk3jh8bt.fsf@localhost> <86le2mhhsj.fsf@gnu.org> <875xtqramd.fsf@gmail.com> <86cynyhfsn.fsf@gnu.org> <87v81qp91g.fsf@gmail.com> <86r0cefb0i.fsf@gnu.org> <86msn1fk0c.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="19410"; mail-complaints-to="usenet@ciao.gmane.io" Cc: eller.helmut@gmail.com, gerd.moellmann@gmail.com, yantar92@posteo.net, emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon Jul 01 19:37:39 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 1sOKyA-0004mc-7Z for ged-emacs-devel@m.gmane-mx.org; Mon, 01 Jul 2024 19:37:38 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sOKxT-0004zS-69; Mon, 01 Jul 2024 13:36:55 -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 1sOKop-0002MN-EW for emacs-devel@gnu.org; Mon, 01 Jul 2024 13:27:59 -0400 Original-Received: from mail-4316.protonmail.ch ([185.70.43.16]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sOKom-000104-Ua; Mon, 01 Jul 2024 13:27:59 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail3; t=1719854874; x=1720114074; bh=48bhSm+iTZeyD1Q2ty22p2i9wM6DSHPSvfIcwPijmrs=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector; b=mWLk6N7euvQKt1E6BEzCXgUjRpap5sqAsMzbqYkNik3JZIy9wtHwowpSSPFpyDbNt nr9FM1tbKGrmG/4BenSaCm3NAjlIrnKutUaaWuAg0sLPKIMbCrCdjF17Xysa48bl6T ulS+dccHUv7bA2NfYMJEWXzwDIzxyytMMJenMgJeUKIrIU24ABGjC5doTqLqMVG7wj xAS31z3PbcJzeMSuJhXFmPJZzMUoKsZ70Fz5XTCAZmHvz0xO7xlFNDo/hdNqowneok 5GQa3znjobkCs77W/9RruTRPJ6EzgDhF0Ne/552GUKAxMA5GTJEqZXY5UFP3rAI0tc lcX3mLlspNMpA== In-Reply-To: <86msn1fk0c.fsf@gnu.org> Feedback-ID: 112775352:user:proton X-Pm-Message-ID: 8005ea8f9121eecd60626c2e10823e69fb17be52 Received-SPF: pass client-ip=185.70.43.16; envelope-from=pipcet@protonmail.com; helo=mail-4316.protonmail.ch 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, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Mon, 01 Jul 2024 13:36:51 -0400 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:321041 Archived-At: On Monday, July 1st, 2024 at 11:07, Eli Zaretskii wrote: > > Date: Sun, 30 Jun 2024 20:32:54 +0000 >=20 > > From: Pip Cet pipcet@protonmail.com > > Cc: eller.helmut@gmail.com, gerd.moellmann@gmail.com, yantar92@posteo.n= et, emacs-devel@gnu.org > >=20 > > On Sunday, June 30th, 2024 at 20:09, Eli Zaretskii eliz@gnu.org wrote: > >=20 > > > > Date: Sun, 30 Jun 2024 19:25:36 +0000 > > >=20 > > > > From: Pip Cet pipcet@protonmail.com > > > > Cc: Eli Zaretskii eliz@gnu.org, gerd.moellmann@gmail.com, yantar92@= posteo.net, > > > > emacs-devel@gnu.org > > > >=20 > > > > IIUC the consensus is you can set an "int" or "bool" to true, or wr= ite to a self-pipe, but that's about as much as you should ever do in a sig= nal handler... > > >=20 > > > That's not true, AFAIU: you can safely call any of the dozens of > > > functions listed by the signal-safety(7) man page. > >=20 > > I think the implication is reversed there: functions that aren't on tha= t man page definitely aren't safe to call, but that doesn't mean that any o= ld C code modifying complicated structures using only the listed functions = is safe, at all. >=20 > I didn't say "any code"; obviously, one can write unsafe code even > without calling any function! This is a strawman if ever there was > one. I'm sorry, I must have misunderstood you. I thought you said I could safely= call any of dozens of functions when what I talked about was what signal h= andlers can actually, effectively, do. There's no contradiction there. > > My point is that complicated C structures, such as the queue Helmut imp= lemented, cannot usually be safely modified from signal handlers unless the= non-signal code takes care to block signals while it is modifying the stru= cture. >=20 > It goes without saying that updating a static data structure makes the > signal handler non-reentrant, and it should at least block SIGCHLD. Blocking SIGCHLD in a SIGCHLD handler is redundant unless SA_NODEFER is in = use. Are we talking about a different handler here? > > All that said, it's not like our existing code looks safe, either, so t= he patch is definitely an improvement! >=20 > I don't think I agree with the "improvement" part. The challenge is > to prevent crashes without giving up useful features, not by means of > giving them up. One last suggestion: how about blocking those signals for most of Emacs' li= fetime, only unblocking them in maybe_quit or at similar points? That would= allow us to keep the existing signal handlers and make them safe... I still think this is a simple oversight on the part of MPS, FWIW. You shou= ldn't allow other signals when handling SIGSEGV, or at least give the clien= t program an option to specify a signal mask. Pip