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 1kgioK-00038a-JE for pgsql-hackers@arkaria.postgresql.org; Sun, 22 Nov 2020 06:25:20 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kgioG-00080B-H6 for pgsql-hackers@arkaria.postgresql.org; Sun, 22 Nov 2020 06:25:16 +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 1kgioG-000804-9z for pgsql-hackers@lists.postgresql.org; Sun, 22 Nov 2020 06:25:16 +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 1kgioA-0000V5-5a for pgsql-hackers@lists.postgresql.org; Sun, 22 Nov 2020 06:25:14 +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 0AM6P8pj1778089; Sun, 22 Nov 2020 01:25:08 -0500 From: Tom Lane To: vignesh C cc: PostgreSQL Hackers Subject: Re: Printing backtrace of postgres processes In-reply-to: References: Comments: In-reply-to vignesh C message dated "Sun, 22 Nov 2020 08:36:25 +0530" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1778087.1606026307.1@sss.pgh.pa.us> Date: Sun, 22 Nov 2020 01:25:08 -0500 Message-ID: <1778088.1606026308@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk vignesh C writes: > The idea here is to implement & expose pg_print_callstack function, > internally what this function does is, the connected backend will send > SIGUSR1 signal by setting PMSIGNAL_BACKTRACE_EMIT to the postmaster > process. Postmaster process will send a SIGUSR1 signal to the process > by setting PROCSIG_BACKTRACE_PRINT if the process has access to > ProcSignal. As syslogger process & Stats process don't have access to > ProcSignal, multiplexing with SIGUSR1 is not possible for these > processes, hence SIGUSR2 signal will be sent for these processes. Once > the process receives this signal it will log the backtrace of the > process. Surely this is *utterly* unsafe. You can't do that sort of stuff in a signal handler. It might be all right to set a flag that would cause the next CHECK_FOR_INTERRUPTS to print a backtrace, but I'm not sure how useful that really is. The proposed postmaster.c addition seems quite useless, as there is exactly one stack trace it could ever log. I would like to see some discussion of the security implications of such a feature, as well. ("There aren't any" is the wrong answer.) regards, tom lane