pg.ddx.io  pgsql-odbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Hiroshi Inoue <inoue@tpf.co.jp>
To: Andres Freund <andres@2ndquadrant.com>
To: Heikki Linnakangas <hlinnakangas@vmware.com>
Cc: Joshua Berry <yoberi@gmail.com>
Cc: pgsql-bugs@postgresql.org, Tom Lane <tgl@sss.pgh.pa.us>
Subject: Re: [ODBC] Segmentation Fault in Postgres server when using psqlODBC
Date: Thu, 13 Jun 2013 22:31:20 +0900
Message-ID: <51B9C9A8.9000109@tpf.co.jp> (raw)
In-Reply-To: <20130611162652.GA30025@awork2.anarazel.de>
References: <51A51147.2060103@tpf.co.jp>
	<CAPmZXM1ffoi_niJc_Ra7MG1+Anp5Q0-77AAW0YawEJ4hVA3b=g@mail.gmail.com>
	<51A75999.6030701@tpf.co.jp>
	<CAPmZXM1QngGY4svmZMnTOsP4LjcypcLvW+gyz=GbhmTcRDZnpA@mail.gmail.com>
	<51AD6351.4030208@tpf.co.jp>
	<CAPmZXM1jcE3BDi7si9JZUZC1weHUHWx8s3N0JCsmRq-+3o_6Bg@mail.gmail.com>
	<CAPmZXM08s=6=owEWsu542QSz6ME8McpoA8RwGwSJQHDNS-v5TA@mail.gmail.com>
	<51B0046F.8080908@tpf.co.jp>
	<CAPmZXM0ye9i3ib+pXoimf6C6GpGUgdKbvydUFFg2+VQyj+u-6Q@mail.gmail.com>
	<51B74E69.4010206@vmware.com>
	<20130611162652.GA30025@awork2.anarazel.de>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

(2013/06/12 1:26), Andres Freund wrote:
> On 2013-06-11 19:20:57 +0300, Heikki Linnakangas wrote:
>> On 11.06.2013 19:04, Joshua Berry wrote:
>>> Hiroshi Inoue has developed the attached patch to correct the issue that
>>> was  reported. More of the dialogue can be found in the pgsql-odbc list.
>>
>> I tried to follow that thread over at pgsql-odbc, but couldn't quite
>> understand what the problem is. Did you have a test program to reproduce it?
>> Or failing that, what is the sequence of protocol messages that causes the
>> problem?
>
> I'd guess creating a SQL level WITH HOLD cursor and then fetching that
> via the extended protocol, outside the transaction, should do the trick.

OK I made a test C program which reproduces the crash.
The program uses libpq and a hack.

I attached the program.
Please modify the connect operation suitable for your environment.
Note that the connection should be non-ssl.
Also add error checkings if needed.

regards,
Hiroshi Inoue

-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs

Attachments:

heldcursor.c (text/x-csrc, 1.2K) download #include <libpq-fe.h> #ifdef WIN32 #include <WinSock2.h> #else #include <sys/types.h> #include <sys/socket.h> #endif #define MY_CUR "mycur" int main(int argc, const char **argv) { const char *connstr; PGconn *conn; PGresult *result; int sock; int len, count; if (argc > 1) connstr = argv[1]; else connstr = "host=localhost port=5432 dbname=xxxxx user=xxxxx password=xxxxx"; conn = PQconnectdb(connstr); result = PQexec(conn, "declare " MY_CUR " cursor with hold for select * from generate_series(1, 2) as i"); if (PQgetssl(conn) != NULL) { printf("Use non-ssl connection\n"); return 1; } sock = PQsocket(conn); if (sock < 0) { printf("socket error\n"); return 1; } // send execute message send(sock, "E", 1, 0); len = sizeof(len) + strlen(MY_CUR) + 1 + sizeof(count); len = htonl(len); send(sock, (const char *) &len, sizeof(len), 0); send(sock, MY_CUR, strlen(MY_CUR) + 1, 0); count = htonl(1); send(sock, (const char *) &count, sizeof(count), 0); result = PQexec(conn, "close " MY_CUR); if (!result) printf("close error\n"); else printf("result error=%s\n", PQresultErrorMessage(result)); PQfinish(conn); return 0; }

view thread (18+ messages)  latest in thread

Message-ID: <51B9C9A8.9000109@tpf.co.jp>
Permalink:  ../51B9C9A8.9000109@tpf.co.jp/
Also on:    postgresql.org/message-id/51B9C9A8.9000109@tpf.co.jp

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-odbc@postgresql.org
  Cc: inoue@tpf.co.jp, andres@2ndquadrant.com, hlinnakangas@vmware.com, yoberi@gmail.com, tgl@sss.pgh.pa.us
  Subject: Re: [ODBC] Segmentation Fault in Postgres server when using psqlODBC
  In-Reply-To: <51B9C9A8.9000109@tpf.co.jp>
  References: <51A51147.2060103@tpf.co.jp> <CAPmZXM1ffoi_niJc_Ra7MG1+Anp5Q0-77AAW0YawEJ4hVA3b=g@mail.gmail.com> <51A75999.6030701@tpf.co.jp> <CAPmZXM1QngGY4svmZMnTOsP4LjcypcLvW+gyz=GbhmTcRDZnpA@mail.gmail.com> <51AD6351.4030208@tpf.co.jp> <CAPmZXM1jcE3BDi7si9JZUZC1weHUHWx8s3N0JCsmRq-+3o_6Bg@mail.gmail.com> <CAPmZXM08s=6=owEWsu542QSz6ME8McpoA8RwGwSJQHDNS-v5TA@mail.gmail.com> <51B0046F.8080908@tpf.co.jp> <CAPmZXM0ye9i3ib+pXoimf6C6GpGUgdKbvydUFFg2+VQyj+u-6Q@mail.gmail.com> <51B74E69.4010206@vmware.com> <20130611162652.GA30025@awork2.anarazel.de> <51B9C9A8.9000109@tpf.co.jp>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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