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 1piEzm-0001gs-GF for pgsql-bugs@arkaria.postgresql.org; Fri, 31 Mar 2023 13:40:46 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1piEzl-0006aZ-G9 for pgsql-bugs@arkaria.postgresql.org; Fri, 31 Mar 2023 13:40:45 +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 1piEzf-0004Yl-Cp for pgsql-bugs@lists.postgresql.org; Fri, 31 Mar 2023 13:40:39 +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 1piEzd-0000W7-31 for pgsql-bugs@lists.postgresql.org; Fri, 31 Mar 2023 13:40:38 +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 32VDeZ3A435881; Fri, 31 Mar 2023 09:40:35 -0400 From: Tom Lane To: exclusion@gmail.com cc: pgsql-bugs@lists.postgresql.org Subject: Re: BUG #17880: Uninitialised value used when analyzing a table with an inheritance tree containing no children In-reply-to: <17880-9282037c923d856e@postgresql.org> References: <17880-9282037c923d856e@postgresql.org> Comments: In-reply-to PG Bug reporting form message dated "Fri, 31 Mar 2023 10:00:02 -0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <435879.1680270035.1@sss.pgh.pa.us> Date: Fri, 31 Mar 2023 09:40:35 -0400 Message-ID: <435880.1680270035@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk PG Bug reporting form writes: > As I can see, this error is explained by the fact that > acquire_inherited_sample_rows() can exit before setting > *totalrows = 0; > *totaldeadrows = 0; > so variables declared in do_analyze_rel() as > double totalrows, > totaldeadrows; > stay uninitialised and totalrows passed to vac_update_relstats() where it > triggers the valgrind complaint. Good catch! > On a quick glance, the peer functions acquire_sample_rows(), > postgresAcquireSampleRowsFunc(), file_acquire_sample_rows() can't exit > without setting totalrows/totaldeadrows, so maybe > acquire_inherited_sample_rows() deserves fixing (or maybe those variables > can be initialized in do_analyze_rel()). Yeah, I'd put the blame on acquire_inherited_sample_rows. Its head comment says it has the same API as acquire_sample_rows, and that one's comment says that totalrows/totaldeadrows are always set. Will fix, thanks. regards, tom lane