Re: BUG #16466: Valgrind detects an invalid read in dblink_open() with a cursor inside a transaction

From: Joe Conway <mail(at)joeconway(dot)com>
To: exclusion(at)gmail(dot)com, pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #16466: Valgrind detects an invalid read in dblink_open() with a cursor inside a transaction
Date: 2020-05-27 19:58:24
Message-ID: 9bd0744f-5f04-c778-c5b3-809efe9c30c7@joeconway.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

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(at)gmail(dot)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

Attachment Content-Type Size
dblink_uninit-vars_20200527.00.diff text/x-patch 623 bytes

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Alexander Lakhin 2020-05-27 21:00:00 Re: BUG #16466: Valgrind detects an invalid read in dblink_open() with a cursor inside a transaction
Previous Message PG Bug reporting form 2020-05-27 18:00:32 BUG #16466: Valgrind detects an invalid read in dblink_open() with a cursor inside a transaction