pg.ddx.io pgsql-bugs@postgresql.org mailing list archive
help / color / mirror / Atom feedBUG #16466: Valgrind detects an invalid read in dblink_open() with a cursor inside a transaction
4+ messages / 3 participants
[nested] [flat]
Commits from this thread:
2020-05-28 9003b76e16 e8eb485954 49a00e07c5 43d3d73189 43d7934a3a f140d9b6e0 Initialize dblink remoteConn struct in all cases
* BUG #16466: Valgrind detects an invalid read in dblink_open() with a cursor inside a transaction
@ 2020-05-27 18:00 PG Bug reporting form <noreply@postgresql.org>
2020-05-27 19:58 ` Re: BUG #16466: Valgrind detects an invalid read in dblink_open() with a cursor inside a transaction Joe Conway <mail@joeconway.com>
0 siblings, 1 reply; 4+ messages in thread
From: PG Bug reporting form @ 2020-05-27 18: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: 16466
Logged by: Alexander Lakhin
Email address: exclusion@gmail.com
PostgreSQL version: 13beta1
Operating system: Ubuntu 18.04
Description:
When running under valgrind the following query (based on
contrib/dblink/sql/dblink.sql):
CREATE EXTENSION dblink;
CREATE FUNCTION connection_parameters() RETURNS text LANGUAGE SQL AS $f$
SELECT $$dbname='$$||current_database()||$$'
port=$$||current_setting('port');
$f$;
SELECT dblink_connect('myconn',connection_parameters());
SELECT dblink_exec('myconn','BEGIN');
SELECT dblink_open('myconn','xxx','SELECT 1');
The following error is detected:
==00:00:00:07.723 2378719== Conditional jump or move depends on
uninitialised value(s)
==00:00:00:07.723 2378719== at 0x486A5D0: dblink_open (dblink.c:492)
==00:00:00:07.723 2378719== by 0x3BCA2B: ExecInterpExpr
(execExprInterp.c:699)
==00:00:00:07.723 2378719== by 0x3B97F0: ExecInterpExprStillValid
(execExprInterp.c:1802)
==00:00:00:07.723 2378719== by 0x3F3C05: ExecEvalExprSwitchContext
(executor.h:313)
==00:00:00:07.723 2378719== by 0x3F3C05: ExecProject (executor.h:347)
==00:00:00:07.723 2378719== by 0x3F3C05: ExecResult (nodeResult.c:136)
==00:00:00:07.723 2378719== by 0x3C90EC: ExecProcNodeFirst
(execProcnode.c:450)
==00:00:00:07.723 2378719== by 0x3C139B: ExecProcNode (executor.h:245)
==00:00:00:07.723 2378719== by 0x3C139B: ExecutePlan (execMain.c:1646)
==00:00:00:07.723 2378719== by 0x3C1FEC: standard_ExecutorRun
(execMain.c:364)
==00:00:00:07.723 2378719== by 0x3C20BA: ExecutorRun (execMain.c:308)
==00:00:00:07.723 2378719== by 0x55FED3: PortalRunSelect (pquery.c:912)
==00:00:00:07.723 2378719== by 0x5615C7: PortalRun (pquery.c:756)
==00:00:00:07.723 2378719== by 0x55D8F0: exec_simple_query
(postgres.c:1239)
==00:00:00:07.723 2378719== by 0x55F7F5: PostgresMain (postgres.c:4315)
==00:00:00:07.724 2378719==
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: BUG #16466: Valgrind detects an invalid read in dblink_open() with a cursor inside a transaction
2020-05-27 18:00 BUG #16466: Valgrind detects an invalid read in dblink_open() with a cursor inside a transaction PG Bug reporting form <noreply@postgresql.org>
@ 2020-05-27 19:58 ` Joe Conway <mail@joeconway.com>
2020-05-27 21:00 ` Re: BUG #16466: Valgrind detects an invalid read in dblink_open() with a cursor inside a transaction Alexander Lakhin <exclusion@gmail.com>
0 siblings, 1 reply; 4+ messages in thread
From: Joe Conway @ 2020-05-27 19:58 UTC (permalink / raw)
To: exclusion@gmail.com; pgsql-bugs@lists.postgresql.org
On 5/27/20 2:00 PM, PG Bug reporting form wrote:
> The following bug has been logged on the website:
>
> Bug reference: 16466
> Logged by: Alexander Lakhin
> Email address: exclusion@gmail.com
> PostgreSQL version: 13beta1
> Operating system: Ubuntu 18.04
> Description:
>
> When running under valgrind the following query (based on
> contrib/dblink/sql/dblink.sql):
> CREATE EXTENSION dblink;
> CREATE FUNCTION connection_parameters() RETURNS text LANGUAGE SQL AS $f$
> SELECT $$dbname='$$||current_database()||$$'
> port=$$||current_setting('port');
> $f$;
> SELECT dblink_connect('myconn',connection_parameters());
> SELECT dblink_exec('myconn','BEGIN');
> SELECT dblink_open('myconn','xxx','SELECT 1');
>
> The following error is detected:
> ==00:00:00:07.723 2378719== Conditional jump or move depends on
> uninitialised value(s)
> ==00:00:00:07.723 2378719== at 0x486A5D0: dblink_open (dblink.c:492)
Hmmm, looks like a couple of the members of rconn are left uninitialized.
When dblink_open() is called *without* an outer transaction it handles the
initialization for us, but *with* an outer transaction it does not :-(
I think the attached fixes it.
Joe
--
Crunchy Data - http://crunchydata.com
PostgreSQL Support for Secure Enterprises
Consulting, Training, & Open Source Development
Attachments:
dblink_uninit-vars_20200527.00.diff (text/x-patch, 622B) download
diff --git a/contrib/dblink/dblink.c b/contrib/dblink/dblink.c
index 2fe5da2..7364332 100644
*** a/contrib/dblink/dblink.c
--- b/contrib/dblink/dblink.c
*************** dblink_connect(PG_FUNCTION_ARGS)
*** 298,305 ****
--- 298,310 ----
conname_or_str = text_to_cstring(PG_GETARG_TEXT_PP(0));
if (connname)
+ {
rconn = (remoteConn *) MemoryContextAlloc(TopMemoryContext,
sizeof(remoteConn));
+ rconn->conn = NULL;
+ rconn->openCursorCount = 0;
+ rconn->newXactForCursor = false;
+ }
/* first check for valid foreign data server */
connstr = get_connect_string(conname_or_str);
signature.asc (application/pgp-signature, 832B) download
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: BUG #16466: Valgrind detects an invalid read in dblink_open() with a cursor inside a transaction
2020-05-27 18:00 BUG #16466: Valgrind detects an invalid read in dblink_open() with a cursor inside a transaction PG Bug reporting form <noreply@postgresql.org>
2020-05-27 19:58 ` Re: BUG #16466: Valgrind detects an invalid read in dblink_open() with a cursor inside a transaction Joe Conway <mail@joeconway.com>
@ 2020-05-27 21:00 ` Alexander Lakhin <exclusion@gmail.com>
2020-05-28 17:50 ` Re: BUG #16466: Valgrind detects an invalid read in dblink_open() with a cursor inside a transaction Joe Conway <mail@joeconway.com>
0 siblings, 1 reply; 4+ messages in thread
From: Alexander Lakhin @ 2020-05-27 21:00 UTC (permalink / raw)
To: Joe Conway <mail@joeconway.com>; pgsql-bugs@lists.postgresql.org
Hello Joe,
27.05.2020 22:58, Joe Conway wrote:
> Hmmm, looks like a couple of the members of rconn are left uninitialized.
>
> When dblink_open() is called *without* an outer transaction it handles the
> initialization for us, but *with* an outer transaction it does not :-(
>
> I think the attached fixes it.
Yes, your patch makes valgrind silent.
Thanks!
Best regards,
Alexander
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: BUG #16466: Valgrind detects an invalid read in dblink_open() with a cursor inside a transaction
2020-05-27 18:00 BUG #16466: Valgrind detects an invalid read in dblink_open() with a cursor inside a transaction PG Bug reporting form <noreply@postgresql.org>
2020-05-27 19:58 ` Re: BUG #16466: Valgrind detects an invalid read in dblink_open() with a cursor inside a transaction Joe Conway <mail@joeconway.com>
2020-05-27 21:00 ` Re: BUG #16466: Valgrind detects an invalid read in dblink_open() with a cursor inside a transaction Alexander Lakhin <exclusion@gmail.com>
@ 2020-05-28 17:50 ` Joe Conway <mail@joeconway.com>
0 siblings, 0 replies; 4+ messages in thread
From: Joe Conway @ 2020-05-28 17:50 UTC (permalink / raw)
To: Alexander Lakhin <exclusion@gmail.com>; pgsql-bugs@lists.postgresql.org
On 5/27/20 5:00 PM, Alexander Lakhin wrote:
> Hello Joe,
>
> 27.05.2020 22:58, Joe Conway wrote:
>> Hmmm, looks like a couple of the members of rconn are left uninitialized.
>>
>> When dblink_open() is called *without* an outer transaction it handles the
>> initialization for us, but *with* an outer transaction it does not :-(
>>
>> I think the attached fixes it.
> Yes, your patch makes valgrind silent.
> Thanks!
Thanks for checking! Pushed to all supported branches.
Joe
--
Crunchy Data - http://crunchydata.com
PostgreSQL Support for Secure Enterprises
Consulting, Training, & Open Source Development
Attachments:
signature.asc (application/pgp-signature, 832B) download
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2020-05-28 17:50 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2020-05-27 18:00 BUG #16466: Valgrind detects an invalid read in dblink_open() with a cursor inside a transaction PG Bug reporting form <noreply@postgresql.org>
2020-05-27 19:58 ` Joe Conway <mail@joeconway.com>
2020-05-27 21:00 ` Alexander Lakhin <exclusion@gmail.com>
2020-05-28 17:50 ` Joe Conway <mail@joeconway.com>
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