pg.ddx.io pgsql-bugs@postgresql.org mailing list archive
help / color / mirror / Atom feedBUG #17880: Uninitialised value used when analyzing a table with an inheritance tree containing no children
2+ messages / 2 participants
[nested] [flat]
Commits from this thread:
2023-03-31 c2d7d679c1 d0d92fe3d4 e46a309bd8 65266d90f8 6f7ca625b9 2dcd92e97d Ensure acquire_inherited_sample_rows sets its output parameters.
* BUG #17880: Uninitialised value used when analyzing a table with an inheritance tree containing no children
@ 2023-03-31 10:00 PG Bug reporting form <noreply@postgresql.org>
0 siblings, 1 reply; 2+ messages in thread
From: PG Bug reporting form @ 2023-03-31 10:00 UTC (permalink / raw)
To: pgsql-bugs@lists.postgresql.org; +Cc: exclusion@gmail.com
The following bug has been logged on the website:
Bug reference: 17880
Logged by: Alexander Lakhin
Email address: exclusion@gmail.com
PostgreSQL version: 15.2
Operating system: Ubuntu 22.04
Description:
The following query:
CREATE TABLE t (a int) PARTITION BY RANGE (a);
CREATE TABLE tp1 (a int);
ALTER TABLE t ATTACH PARTITION tp1 FOR VALUES FROM (100) to (200);
ALTER TABLE t DETACH PARTITION tp1;
ANALYZE (VERBOSE) t;
produces the error detected by valgrind:
2023-03-31 12:11:20.784 MSK|law|regression|6426a3b8.3543d1|LOG: statement:
ANALYZE (VERBOSE) t;
2023-03-31 12:11:20.792 MSK|law|regression|6426a3b8.3543d1|INFO: analyzing
"public.t" inheritance tree
2023-03-31 12:11:20.804 MSK|law|regression|6426a3b8.3543d1|INFO: skipping
analyze of "public.t" inheritance tree --- this inheritance tree contains no
child tables
==00:00:00:03.670 3490769== Conditional jump or move depends on
uninitialised value(s)
==00:00:00:03.670 3490769== at 0x3D52EE: vac_update_relstats
(vacuum.c:1354)
==00:00:00:03.670 3490769== by 0x34B874: do_analyze_rel (analyze.c:675)
==00:00:00:03.670 3490769== by 0x34BEB4: analyze_rel (analyze.c:269)
==00:00:00:03.670 3490769== by 0x3D5EEC: vacuum (vacuum.c:493)
==00:00:00:03.670 3490769== by 0x3D667A: ExecVacuum (vacuum.c:276)
==00:00:00:03.670 3490769== by 0x596188: standard_ProcessUtility
(utility.c:866)
==00:00:00:03.670 3490769== by 0x596672: ProcessUtility (utility.c:530)
==00:00:00:03.670 3490769== by 0x593B42: PortalRunUtility
(pquery.c:1158)
==00:00:00:03.670 3490769== by 0x593E19: PortalRunMulti (pquery.c:1315)
==00:00:00:03.670 3490769== by 0x59419B: PortalRun (pquery.c:791)
==00:00:00:03.670 3490769== by 0x59047D: exec_simple_query
(postgres.c:1250)
==00:00:00:03.670 3490769== by 0x5922D3: PostgresMain (postgres.c:4593)
==00:00:00:03.670 3490769==
...
The similar query:
CREATE TABLE t (a int) PARTITION BY RANGE (a);
CREATE TABLE tp1 (a int) PARTITION BY RANGE (a);
ALTER TABLE t ATTACH PARTITION tp1 FOR VALUES FROM (100) to (200);
ANALYZE (VERBOSE) t;
produces the same error but with a slightly different INFO message:
2023-03-31 12:13:24.070 MSK|law|regression|6426a433.3549e7|LOG: statement:
ANALYZE (VERBOSE) t;
2023-03-31 12:13:24.093 MSK|law|regression|6426a433.3549e7|INFO: analyzing
"public.t" inheritance tree
2023-03-31 12:13:24.107 MSK|law|regression|6426a433.3549e7|INFO: skipping
analyze of "public.t" inheritance tree --- this inheritance tree contains no
analyzable child tables
==00:00:00:03.621 3492327== Conditional jump or move depends on
uninitialised value(s)
==00:00:00:03.621 3492327== at 0x3D52EE: vac_update_relstats
(vacuum.c:1354)
==00:00:00:03.621 3492327== by 0x34B874: do_analyze_rel (analyze.c:675)
==00:00:00:03.621 3492327== by 0x34BEB4: analyze_rel (analyze.c:26
...
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.
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()).
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: BUG #17880: Uninitialised value used when analyzing a table with an inheritance tree containing no children
@ 2023-03-31 13:40 Tom Lane <tgl@sss.pgh.pa.us>
parent: PG Bug reporting form <noreply@postgresql.org>
0 siblings, 0 replies; 2+ messages in thread
From: Tom Lane @ 2023-03-31 13:40 UTC (permalink / raw)
To: exclusion@gmail.com; +Cc: pgsql-bugs@lists.postgresql.org
PG Bug reporting form <noreply@postgresql.org> 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
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2023-03-31 13:40 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2023-03-31 10:00 BUG #17880: Uninitialised value used when analyzing a table with an inheritance tree containing no children PG Bug reporting form <noreply@postgresql.org>
2023-03-31 13:40 ` Tom Lane <tgl@sss.pgh.pa.us>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox