From: | "Tristan Partin" <tristan(at)neon(dot)tech> |
---|---|
To: | <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Potential us of initialized memory in xlogrecovery.c |
Date: | 2023-06-06 14:24:56 |
Message-ID: | CT5MN8E11U0M.1NYNCHXYUHY41@gonk |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hello,
Today, I compiled the master branch of Postgres with the following GCC
version:
gcc (GCC) 13.1.1 20230511 (Red Hat 13.1.1-2)
I got the following warning:
[701/2058] Compiling C object src/backend/postgres_lib.a.p/access_transam_xlogrecovery.c.o
In function ‘recoveryStopsAfter’,
inlined from ‘PerformWalRecovery’ at ../src/backend/access/transam/xlogrecovery.c:1749:8:
../src/backend/access/transam/xlogrecovery.c:2756:42: warning: ‘recordXtime’ may be used uninitialized [-Wmaybe-uninitialized]
2756 | recoveryStopTime = recordXtime;
| ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~
../src/backend/access/transam/xlogrecovery.c: In function ‘PerformWalRecovery’:
../src/backend/access/transam/xlogrecovery.c:2647:21: note: ‘recordXtime’ was declared here
2647 | TimestampTz recordXtime;
| ^~~~~~~~~~~
Investigating this issue I see a potential assignment in
xlogrecovery.c:2715. Best I can tell the warning looks real. Similar
functions in this file seem to initialize recordXtime to 0. Attached is
a patch which does just that.
--
Tristan Partin
Neon (https://neon.tech)
Attachment | Content-Type | Size |
---|---|---|
v1-0001-Initialize-potentially-uninitialized-memory-in-xl.patch | text/x-patch | 946 bytes |
From | Date | Subject | |
---|---|---|---|
Next Message | Rômulo Coutinho | 2023-06-06 14:42:36 | ERROR: could not determine which collation to use for string comparison |
Previous Message | Evan Jones | 2023-06-06 14:24:45 | Re: [PATCH] pg_regress.c: Fix "make check" on Mac OS X: Pass DYLD_LIBRARY_PATH |