Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ntVKL-0003Ki-NR for pgsql-bugs@arkaria.postgresql.org; Tue, 24 May 2022 14:16:01 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1ntVKK-0002FG-Kh for pgsql-bugs@arkaria.postgresql.org; Tue, 24 May 2022 14:16:00 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ntVKK-0002Ew-CO for pgsql-bugs@lists.postgresql.org; Tue, 24 May 2022 14:16:00 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ntVKG-0005L0-Q2 for pgsql-bugs@lists.postgresql.org; Tue, 24 May 2022 14:15:58 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 24OEFtF21531974; Tue, 24 May 2022 10:15:55 -0400 From: Tom Lane To: Julien Rouhaud cc: Mats Kindahl , pgsql-bugs@lists.postgresql.org Subject: Re: Use of signal-unsafe functions from signal handlers In-reply-to: <20220524123739.6glyxyx4owqpqjnr@jrouhaud> References: <20220524101418.7pp65powa362vzln@jrouhaud> <20220524123739.6glyxyx4owqpqjnr@jrouhaud> Comments: In-reply-to Julien Rouhaud message dated "Tue, 24 May 2022 20:37:39 +0800" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1531972.1653401755.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Tue, 24 May 2022 10:15:55 -0400 Message-ID: <1531973.1653401755@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Julien Rouhaud writes: > Yes, but it's using ereport with FATAL level, so if it's the top level m= essage > the ErrorContext should be in initial state or have been reset previousl= y, and > if it's not then the escape hatch will reset the context. So in any cas= e there > will be a guarantee to have at least 8kB available in that context, that= any > palloc will be able to use to format the message. ereport() itself is just the tip of the iceberg; even if it's safe (which I concur it isn't), there's also the atexit/on_proc_exit functions that are likely to be called during shutdown. So yeah, this coding is not too safe. I'm not sure that getting rid of it would be a net win though, as we'd replace it-might-crash hazards with it-might-never-exit hazards, from bgworkers that neglect to respond to ShutdownRequestPending. regards, tom lane