Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rdXeT-0067kg-SC for pgsql-hackers@arkaria.postgresql.org; Fri, 23 Feb 2024 15:39:54 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1rdXeS-001zPC-3x for pgsql-hackers@arkaria.postgresql.org; Fri, 23 Feb 2024 15:39:52 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rdXeR-001zP3-Qu for pgsql-hackers@lists.postgresql.org; Fri, 23 Feb 2024 15:39:52 +0000 Received: from feynman.df7cb.de ([195.49.152.168]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rdXeO-000XWt-Ur for pgsql-hackers@lists.postgresql.org; Fri, 23 Feb 2024 15:39:51 +0000 Received: from msg.df7cb.de (unknown [IPv6:2a02:908:1482:3660:b7d0:f584:a987:bc23]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature ECDSA (P-384) server-digest SHA384) (Client did not present a certificate) by feynman.df7cb.de (Postfix) with ESMTPSA id 4ThDhz3yMpz3G4m; Fri, 23 Feb 2024 16:39:47 +0100 (CET) Date: Fri, 23 Feb 2024 16:39:47 +0100 From: Christoph Berg To: Michael Paquier Cc: Ashutosh Bapat , Alvaro Herrera , Bharath Rupireddy , vignesh C , torikoshia , PostgreSQL Hackers Subject: Re: Printing backtrace of postgres processes Message-ID: References: <202402090848.j6evnpunbehe@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Re: Michael Paquier > >> • backtrace() and backtrace_symbols_fd() don't call malloc() explic‐ > >> itly, but they are part of libgcc, which gets loaded dynamically > >> when first used. Dynamic loading usually triggers a call to mal‐ > >> loc(3). If you need certain calls to these two functions to not > >> allocate memory (in signal handlers, for example), you need to make > >> sure libgcc is loaded beforehand. > >> > >> and the patch ensures that libgcc is loaded by calling a dummy > >> backtrace() at the start of the process. > > FWIW, anything I am reading about the matter freaks me out, including > the dlopen() part in all the backends: > https://www.gnu.org/software/libc/manual/html_node/Backtraces.html I'd be concerned about the cost of doing that as part of the startup of every single backend process. Shouldn't this rather be done within the postmaster so it's automatically inherited by forked backends? (EXEC_BACKEND systems probably don't have libgcc I guess.) Christoph