From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Maxime Devos Newsgroups: gmane.lisp.guile.devel Subject: RE: [PATCH] At-exit hook Date: Thu, 7 Nov 2024 17:10:45 +0100 Message-ID: <20241107171045.ZsAk2D00S42S6aw01sAkk9@laurent.telenet-ops.be> References: <20241107122308.ZnP72D00T42S6aw01nP8co@laurent.telenet-ops.be> <20241107120925.87d4b80c9f289d18eec437ad@gmail.com> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="_6232DA71-EFFE-45DF-B3EE-606FB5F0F374_" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="23681"; mail-complaints-to="usenet@ciao.gmane.io" To: Mailer , guile-devel Original-X-From: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org Thu Nov 07 17:11:07 2024 Return-path: Envelope-to: guile-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 1t956A-0005xZ-1A for guile-devel@m.gmane-mx.org; Thu, 07 Nov 2024 17:11:06 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t955y-0002Ul-VT; Thu, 07 Nov 2024 11:10:54 -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 1t955x-0002Ri-44 for guile-devel@gnu.org; Thu, 07 Nov 2024 11:10:53 -0500 Original-Received: from laurent.telenet-ops.be ([2a02:1800:110:4::f00:19]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1t955t-0000GX-CA for guile-devel@gnu.org; Thu, 07 Nov 2024 11:10:52 -0500 Original-Received: from [IPv6:2a02:1811:8c0e:ef00:45f4:a590:36c8:c699] ([IPv6:2a02:1811:8c0e:ef00:45f4:a590:36c8:c699]) by laurent.telenet-ops.be with cmsmtp id ZsAk2D00S42S6aw01sAkk9; Thu, 07 Nov 2024 17:10:45 +0100 Importance: normal X-Priority: 3 In-Reply-To: <20241107120925.87d4b80c9f289d18eec437ad@gmail.com> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telenet.be; s=r24; t=1730995845; bh=uZeG/tmf764cAlsluN5flsWye3Y1JUGmw57g/rsrexk=; h=Message-ID:MIME-Version:To:From:Subject:Date:In-Reply-To: References:Content-Type:From; b=fiD4faUeOPO0VHjk7EvcUJupltvb9j1opKUw1qDvzwGixZLWPcwREoUq2nOv6G9rc s0xQPR1n7+wL7Ea7AaEpUNrR+sxavEFwfnpV0x7XS9PeX158ospQqUZaUN3lTwj4sd XlEdjYSK2cEWTb/EFq6SwUcl78OScJSEi8Iyv7hDq4Ji0IxFCKcpldsSGDUKe51UuP s0lwhXv3Rzf86ZgACosXRT8LfIFi5m7lBpi4ZJQvGROC33VU3LnaLLmdIDzwya9bKX 1yyE/moUac//lM3mpuQc+slVTntIl85De8qL3mPcA2Td9fY1lFCKZb/L9vUSH//4jt oTojmrM1zsfeQ== Received-SPF: pass client-ip=2a02:1800:110:4::f00:19; envelope-from=maximedevos@telenet.be; helo=laurent.telenet-ops.be X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org Original-Sender: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.lisp.guile.devel:22765 Archived-At: --_6232DA71-EFFE-45DF-B3EE-606FB5F0F374_ Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" On Thu, 7 Nov 2024 12:23:08 +0100 >Maxime Devos wrote: >> =E2=80=98atexit=E2=80=99 functions are run at =E2=80=98exit=E2=80=99. = =E2=80=98exit=E2=80=99 can be run from signal >> handlers (*). Since the hook runs Scheme code, it could do a lot of >> AC-unsafe things, resulting in problems. >>=20 >> (*) glibc documentation says =E2=80=98exit=E2=80=99 is AC-unsafe, but th= is is >> unsupported by POSIX AFAICT. OTOH the same applies to even =E2=80=98mall= oc=E2=80=99, >> so likely I=E2=80=99m looking in the wrong places. >I think you meant async-signal-safe (AS-safe). 'exit' is not a-s-s and >cannot be called in a signal handler (for example it can flush buffers) >whereas '_exit' is a-s-s. Furthermore a registered handler cannot >itself safely call 'exit'. [=E2=80=A6] No, I did mean exactly what I wrote. Read the glibc documentation of =E2=80= =98exit=E2=80=99 and you=E2=80=99ll see. (Likewise for the POSIX page for = =E2=80=98exit=E2=80=99 =E2=80=93 POSIX does not seem to restrict things to = _outside_ signal handlers.) Also, when two authorative sources (POSIX and glibc in this case) have cont= rary claims, then simply repeating one of those claim does not help at all,= you would need to explain the cause of the discrepancy instead. That =E2=80=98exit=E2=80=99 flushes buffers does not imply that =E2=80=98ex= it=E2=80=99 is async-unsafe, alternatives include buffer flushing being saf= e, =E2=80=98exit=E2=80=99 having its own implementation of flushing that is= AC-safe, or =E2=80=98you may call =E2=80=98exit=E2=80=99 but only if no fi= les (as in FILE*) are open=E2=80=99. Best regards, Maxime Devos --_6232DA71-EFFE-45DF-B3EE-606FB5F0F374_ Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset="utf-8"

On Thu, 7 Nov 2024 12:23:08 +0100

>Maxime Devos <maximedevos@telenet.= be> wrote:

= >> =E2=80=98atexit=E2=80=99 functions are run at =E2=80=98exit=E2=80= =99. =E2=80=98exit=E2=80=99 can be run from signal

>> handlers (*). Since the hook = runs Scheme code, it could do a lot of

>> AC-unsafe things, resulting in problems.<= o:p>

>> =

>> (*) glibc= documentation says =E2=80=98exit=E2=80=99 is AC-unsafe, but this is

>> unsupported= by POSIX AFAICT. OTOH the same applies to even =E2=80=98malloc=E2=80=99,

>> so lik= ely I=E2=80=99m looking in the wrong places.

 

>I think you meant async-signal-safe (AS-safe).= =C2=A0 'exit' is not a-s-s and

>cannot be called in a signal handler (for example it c= an flush buffers)

>whereas '_exit' is a-s-s.=C2=A0 Furthermore a registered handler ca= nnot

>itsel= f safely call 'exit'. [=E2=80=A6]

 

No, I did mean exactly what I wrote. Read the glibc documentat= ion of =E2=80=98exit=E2=80=99 and you=E2=80=99ll see. (Likewise for the POS= IX page for =E2=80=98exit=E2=80=99 =E2=80=93 POSIX does not seem to restric= t things to _outside_ signal handlers.)

 

Also, when two authorative sources (POSIX and gli= bc in this case) have contrary claims, then simply repeating one of those c= laim does not help at all, you would need to explain the cause of the discr= epancy instead.

 

That = =E2=80=98exit=E2=80=99 flushes buffers does not imply that =E2=80=98exit=E2= =80=99 is async-unsafe, alternatives include buffer flushing being safe, = =E2=80=98exit=E2=80=99 having its own implementation of flushing that is AC= -safe, or =E2=80=98you may call =E2=80=98exit=E2=80=99 but only if no files= (as in FILE*) are open=E2=80=99.

 

Best regards,

Maxime Devos

= --_6232DA71-EFFE-45DF-B3EE-606FB5F0F374_--