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 1jLq3d-0005Bc-PD for pgsql-bugs@arkaria.postgresql.org; Tue, 07 Apr 2020 15:22:33 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jLq3c-0000Wc-Ht for pgsql-bugs@arkaria.postgresql.org; Tue, 07 Apr 2020 15:22:32 +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 1jLq3c-0000WV-Bz for pgsql-bugs@lists.postgresql.org; Tue, 07 Apr 2020 15:22:32 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jLq3a-0005Bn-7g for pgsql-bugs@lists.postgresql.org; Tue, 07 Apr 2020 15:22:31 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id 037FMSZN029585; Tue, 7 Apr 2020 11:22:28 -0400 From: Tom Lane To: hghwng@gmail.com cc: pgsql-bugs@lists.postgresql.org Subject: Re: BUG #16348: Memory leak when parsing config In-reply-to: <16348-018c10b6fd16ebcc@postgresql.org> References: <16348-018c10b6fd16ebcc@postgresql.org> Comments: In-reply-to PG Bug reporting form message dated "Tue, 07 Apr 2020 13:36:20 -0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <29581.1586272948.1@sss.pgh.pa.us> Date: Tue, 07 Apr 2020 11:22:28 -0400 Message-ID: <29582.1586272948@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk PG Bug reporting form writes: > ANALYSIS: > When parsing config file, gui-file.l:ProcessConfig sets up memory context. > It invokes guc-file.l:ProcessConfigFileInternal, which is expected to leak > memory. It's okay because the leaked memory will be freed when cleaning up > the context. Next, guc-file.l:ProcessConfigFileInternal associates each > config item with filename by calling guc.c:set_config_option, which calls > guc.c:guc_strdup. However, guc.c:guc_strdup is not aware of the memory > context, and invokes libc.so:strdup directly. And? The places that use guc_strdup are expecting that the values will be tracked and then freed when discarded. Perhaps there is a code path where that's not happening, but you haven't either shown it or given any reason to believe one exists. As a quick cross-check, I set up a shell loop to send a constant stream of SIGHUPs to an idle backend. I don't see any change in the backend's memory consumption in "top". Maybe this test case is missing some necessary factor ... but, again, you haven't given a reason to believe there is one. regards, tom lane