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 1rYMYv-00Fazy-Ah for pgsql-hackers@arkaria.postgresql.org; Fri, 09 Feb 2024 08:48:45 +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 1rYMYu-007Gsg-2Q for pgsql-hackers@arkaria.postgresql.org; Fri, 09 Feb 2024 08:48:44 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rYMYt-007GsW-Dz for pgsql-hackers@lists.postgresql.org; Fri, 09 Feb 2024 08:48:43 +0000 Received: from fout6-smtp.messagingengine.com ([103.168.172.149]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rYMYq-005rGb-Sz for pgsql-hackers@lists.postgresql.org; Fri, 09 Feb 2024 08:48:42 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailfout.nyi.internal (Postfix) with ESMTP id 2410B1380097; Fri, 9 Feb 2024 03:48:39 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Fri, 09 Feb 2024 03:48:39 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :reply-to:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1707468519; x= 1707554919; bh=gJYt6qgUzFDWgfR2XBmLzY2LYqvbhL+yewqMX5FszQ8=; b=t YyNSYa6v7Bai+QdoAY+uSf3cJQ550hCj7xVruGKCIKITNs35o/a+G2lyAgQimKo2 InOFG+9wLGNN9QWMRV223hCukOe4HcYljdwJH1B8jYSIJG5FSJWOENE/a7n2m8C5 B9k5pRipm/FShqUzwb3+26GgLwovNJj8oXAL5NRfMVU749KONbg3pqd6u/p20JH/ IjUyqWG3gQmC2EsElmSGccFgplxik9wEOo9ZDRRF8GVISco65q0xTB5vbm8wu1U0 4Msa1x7ibka6lLZIWsBDoURbbTMo5cbM788J77r4EXa4QjL+kKtLkgvvOrGCsqxN Y6JOfh64Gp0EXVZJRJoaA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrtdehgdduvdduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvfevuffkgggtugfgjgesthekredttddtjeenucfhrhhomheptehlvhgr rhhoucfjvghrrhgvrhgruceorghlvhhhvghrrhgvsegrlhhvhhdrnhhoqdhiphdrohhrgh eqnecuggftrfgrthhtvghrnhepkeefieehkeekffdtffeggedtffelkeeigfduvdekgfdu gfeluedtiefhkeetudfgnecuffhomhgrihhnpehgihhthhhusgdrtghomhdpvghnthgvrh hprhhishgvuggsrdgtohhmnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehm rghilhhfrhhomheprghlvhhhvghrrhgvsegrlhhvhhdrnhhoqdhiphdrohhrgh X-ME-Proxy: Feedback-ID: ia2694551:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 9 Feb 2024 03:48:38 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alvh.no-ip.org; s=schmee; t=1707468516; bh=SgyeGsjdfz6jQjJDRw3VEuXIYWd7BpD1jgViKHptaIk=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=knhbY6UWfOD0m0UDU9SMHcgSHGUvm7XHVGWjhBACgOUKcRW17Y76i4xEfyyL5vUMf gyVNH70Nfwei/AzDb/95gMAXryTfkCJTbnxSpxWZjOLREw1HF6NWkRU9FcT0Djn2FU i5ST+E35JXwCwhAf9rvJgmRD2Kb+Va+f3HM597J5PkxTB8FCuuslh3Bz6P+Xd1jKwt MgZBx3RbIJ8N+Pap9y0C4bO70MK/RujLPF+q5br4J3qGv+QQGWu+5M3koGg+bjEUAA xUWZg1mf9L8EsjxEefnYlyfiXgoI+2ddZwrbdER3w7EMCgQMME7Ge3w/MPcaVoMoEG z6rvDjrl5sGHQ== Received: by schmee.alvh.no-ip.org (Postfix, from userid 1000) id 6DF59BA3; Fri, 9 Feb 2024 09:48:36 +0100 (CET) Date: Fri, 9 Feb 2024 09:48:36 +0100 From: Alvaro Herrera To: Michael Paquier Cc: Bharath Rupireddy , vignesh C , torikoshia , PostgreSQL Hackers Subject: Re: Printing backtrace of postgres processes Message-ID: <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 On 2024-Feb-09, Michael Paquier wrote: > Anyway, I've been digging around the signal-safety of backtrace(3) > (even looking a bit at some GCC code, brrr), and I am under the > impression that backtrace() is just by nature not safe and also > dangerous in signal handlers. One example of issue I've found: > https://github.com/gperftools/gperftools/issues/838 > > This looks like enough ground to me to reject the patch. Hmm, but the backtrace() manpage says • 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. -- Álvaro Herrera 48°01'N 7°57'E — https://www.EnterpriseDB.com/ "All rings of power are equal, But some rings of power are more equal than others." (George Orwell's The Lord of the Rings)