From: Heikki Linnakangas <hlinnaka@iki.fi>
To: Paal Christof <Christof.Paal@ncia.nato.int>
To: pgsql-odbc@postgresql.org <pgsql-odbc@postgresql.org>
Subject: Re: Crash in 64 bit ODBC driver when using bookmarks
Date: Sun, 21 Oct 2018 23:42:37 +0300
Message-ID: <63d13cfb-3b15-c3ca-14ae-adabaec1b4df@iki.fi> (raw)
In-Reply-To: <168ee54f5e0044088c596bc88bcc335e@NRDW2EX3.NR.NC3A>
References: <168ee54f5e0044088c596bc88bcc335e@NRDW2EX3.NR.NC3A>
On 19/10/2018 15:16, Paal Christof wrote:
> I think I have found a bug in the PostgreSQL ODBC driver (of which I am using the latest version 10_03).
> I am using SQLBindCol to bind a bookmark column of type SQL_C_VARBOOKMARK.
>
> Everything works perfectly when I compile my application in 32 bit mode and use the 32 bit ODBC driver.
> With the 64 bit driver I get an instant crash (memory exception).
> With logging turned on, the last entry in the mylog is the following:
> [SC_Create_bookmark]3133: entering type=-2 buflen=64 buf=000000000C6AF268
>
> I can also attach a debugger and the crash happens at the following line:
> memcpy(CALC_BOOKMARK_ADDR(bookmark, offset, bind_size, bind_row), &pg_bm, cvtlen);
>
> At that time the value of the bookmark variable is: bookmark = 0x0000000000000001 {buflen=??? buffer=??? used=??? ...}, screenshot attached.
> Although it received good values when the function was called (as seen in the log), the memory got corrupted in between and it is no longer a valid pointer.
> I assume this is because something is writing a 64 bit value into a buffer which is only made for a 32 bit integer.
Can you provide a self-contained test case? There is a test case that
uses SQLBindCol with SQL_C_VARBOOKMARK, in the regression test suite,
and it's been working fine:
https://git.postgresql.org/gitweb/?p=psqlodbc.git;a=blob;f=test/src/bookmark-test.c;h=ccdfa5e8428900...
If you could reproduce the crash with some changes to that test program,
that would help a lot.
- Heikki
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: hlinnaka@iki.fi, Christof.Paal@ncia.nato.int
Subject: Re: Crash in 64 bit ODBC driver when using bookmarks
In-Reply-To: <63d13cfb-3b15-c3ca-14ae-adabaec1b4df@iki.fi>
References: <168ee54f5e0044088c596bc88bcc335e@NRDW2EX3.NR.NC3A> <63d13cfb-3b15-c3ca-14ae-adabaec1b4df@iki.fi>
* 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