pg.ddx.io  pgsql-odbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Segmentation Fault in Postgres server when using psqlODBC
18+ messages / 6 participants
[nested] [flat]

* Segmentation Fault in Postgres server when using psqlODBC
@ 2013-05-24 16:55 Joshua Berry <yoberi@gmail.com>
  2013-05-24 21:25 ` Re: Segmentation Fault in Postgres server when using psqlODBC Hiroshi Inoue <inoue@tpf.co.jp>
  0 siblings, 1 reply; 18+ messages in thread

From: Joshua Berry @ 2013-05-24 16:55 UTC (permalink / raw)
  To: pgsql-bugs@postgresql.org; pgsql-odbc

Hi Groups,

I'm dealing with periodic backend process segmentation faults. I'm posting
to both the bugs and odbc lists as it seems that my application's use of
pgsqlODBC triggers a bug in the postgres backend.

The environment is:
Clients: win32 clients using various version of the psqlODBC driver (mostly
using 8.04.0200). The connection string contains "UseDeclareFetch=1" which
causes long idle transactions, heavy cursor and savepoint use.
Server: Dell dual Xeon x86 48GB RAM (12GB PG shared mem) RHEL system with
Postgresql 9.2.4. Note that these same issues occurred on PG9.1 and PG8.4.

I've experienced these issues for over a year now. However, during that
time several things have changed which may or may not be related:
* The schema has been modified with heavier use of triggers to update
manually created materialized views (ie not using the 9.3 CREATE
MATERIALIZED VIEW).
* The number of concurrent users has increased (from perhaps 15 concurrent
users two years ago, to 30 concurrent users now).
* The PG version used has changed from 8.4, to 9.1, and finally to 9.2
* I've done recent tuning to the planner cost constants in order to favor
index scans over table scans in more situations.

I've looked through past error logs and I found that I had a segfault in
the server process while using PG 8.4 about a dozen times over a 12 month
period. Each time one client's postgres process crashes, the backend
forcefully closes all active connections due to possiby corrupted memory
and then restarts. This leaves all active clients stranded as the
connection is closed, and all cursors and savepoint info is lost. My app
doesn't recover gracefully, and users are forced to click through some
cryptic error messages from the application framework used for the app
(Clarion) and then restart the app.

A few months ago, I upgraded to another server with PG 9.1, assuming that
the issue with the previous server with 8.4 was due to bad RAM, as I did
observe a high ECC error count on the previous system as logged by the IPMI
controller. However, I very quickly had another segfault on the new system
with PG9.1. The default settings of the OS and PG init script disabled core
dumps, so I only started collecting core files for the past few months.

I posted details in pgsql-general April 10, 2013; here is a link to the
thread:
http://www.postgresql.org/message-id/CAPmZXM03MEDEn6nqqf_Phs3M1DK-EaXP5_K-LmirneOJMAQ-Hg@mail.gmail....

The crash always is some variation of the following stack, as observed in
both PG91 and PG92 crashes:
(gdb) bt
#0  ResourceOwnerEnlargeCatCacheRefs (owner=0x0) at resowner.c:603
#1  0x000000000070f372 in SearchCatCache (cache=0x27fab90, v1=<value
optimized out>, v2=<value optimized out>, v3=<value optimized out>,
v4=<value optimized out>) at catcache.c:1136
#2  0x000000000071b1ae in getTypeOutputInfo (type=20, typOutput=0x2b3db80,
typIsVarlena=0x2b3db88 "") at lsyscache.c:2482
#3  0x000000000045d127 in printtup_prepare_info (myState=0x2810290,
typeinfo=0x29ad7b0, numAttrs=42) at printtup.c:263
#4  0x000000000045d4c4 in printtup (slot=0x3469650, self=0x2810290) at
printtup.c:297
#5  0x000000000065a76a in RunFromStore (portal=0x285fed0, direction=<value
optimized out>, count=10, dest=0x2810290) at pquery.c:1122
#6  0x000000000065a852 in PortalRunSelect (portal=0x285fed0, forward=<value
optimized out>, count=10, dest=0x2810290) at pquery.c:940
#7  0x000000000065bcf8 in PortalRun (portal=0x285fed0, count=10,
isTopLevel=1 '\001', dest=0x2810290, altdest=0x2810290,
completionTag=0x7fffee67f7c0 "") at pquery.c:788
#8  0x0000000000659552 in exec_execute_message (argc=<value optimized out>,
argv=<value optimized out>, dbname=0x2768370 "DBNAME", username=<value
optimized out>) at postgres.c:1929
#9  PostgresMain (argc=<value optimized out>, argv=<value optimized out>,
dbname=0x2768370 "DBNAME", username=<value optimized out>) at
postgres.c:4016
#10 0x0000000000615161 in BackendRun () at postmaster.c:3614
#11 BackendStartup () at postmaster.c:3304
#12 ServerLoop () at postmaster.c:1367
#13 0x0000000000617dcc in PostmasterMain (argc=<value optimized out>,
argv=<value optimized out>) at postmaster.c:1127
#14 0x00000000005b6830 in main (argc=5, argv=0x2766480) at main.c:199
(gdb)

Andres Freund and Tom Lane spent some time tracking down possible root
causes with some of the following summaries:

Tom Lane writes:
|Andres Freund <andres@2ndquadrant.com> writes:
|> Tom: It looks to me like printtup_prepare_info won't normally be called
|> in an held cursor. But if some concurrent DDL changed the number of
|> columns in typeinfo vs thaose in the the receiver that could explain the
|> issue and why its not seen all the time, right?
|
|It looks to me like there are probably two triggering conditions:
|
|1. Client is doing a direct protocol Execute on a held-cursor portal.
|
|2. Cache flush occurs to drop the syscache entries needed by
|getTypeOutputInfo.  (Otherwise, they'd still be around from when the
|held cursor was created.)
|
|The first of these explains why we don't see it in the
|CLOBBER_CACHE_ALWAYS buildfarm runs, and the second one explains why
|Joshua is only seeing it intermittently and not every darn time his
|application does that.

Andres Freund writes:
|On 2013-04-10 19:06:12 -0400, Tom Lane wrote:
|> I wrote:
|> > (Wanders away wondering just how much the regression tests exercise
|> > holdable cursors.)
|>
|> And the answer is they're not testing this code path at all, because if
|> you do
|>       DECLARE c CURSOR WITH HOLD FOR ...
|>       FETCH ALL FROM c;
|> then the second query executes with a portal (and resource owner)
|> created to execute the FETCH command, not directly on the held portal.
|>
|> After a little bit of thought I'm not sure it's even possible to
|> reproduce this problem with libpq, because it doesn't expose any way to
|> issue a bare protocol Execute command against a pre-existing portal.
|> (I had thought psqlOBC went through libpq, but maybe it's playing some
|> games here.)
|
|Hm. PQexecPrepared() looks like it can do that.

I didn't find that any bugs were officially reported/documented, so I
wanted to followup with more detail and follow the guidelines here:
http://www.postgresql.org/docs/current/static/bug-reporting.html
Specifically, I decided to update to the latest stable release, currently
PG9.2.4.

After updating to PG92 three days ago, I've had two of the same segfaults.
Either I'm very (un)lucky or the intermittant issue is occurring more
frequently with PG92.

On a test machine running a snapshort of the production database, and with
the backend configured to log all queries, I have an example of the type of
traffic that client apps will perform:
https://dl.dropboxusercontent.com/u/4715250/pg92_psqlODBC_08.04.0200.txt
In the above logfile, the logfile was cleared, the client app was started,
A window was opened, it was closed, and the app was closed. I installed
pgODBC version 09.01.0200, and aside from cursor names and timestamps
differing, all other lines were identical.

I do not currently have a testing environment which can emulate the
production environment enough to trigger this bug. I've never had this
crash outside of the production environment.

Any thoughts/suggestions?

Regards,
-Joshua

^ permalink  raw  reply  [nested|flat] 18+ messages in thread

* Re: Segmentation Fault in Postgres server when using psqlODBC
  2013-05-24 16:55 Segmentation Fault in Postgres server when using psqlODBC Joshua Berry <yoberi@gmail.com>
@ 2013-05-24 21:25 ` Hiroshi Inoue <inoue@tpf.co.jp>
  2013-05-28 14:20   ` Re: Segmentation Fault in Postgres server when using psqlODBC Joshua Berry <yoberi@gmail.com>
  0 siblings, 1 reply; 18+ messages in thread

From: Hiroshi Inoue @ 2013-05-24 21:25 UTC (permalink / raw)
  To: Joshua Berry <yoberi@gmail.com>; +Cc: pgsql-bugs@postgresql.org; pgsql-odbc

Hi,

Psqlodbc drivers send Execite requests for cursors instead of
issueing FETCH commands.

regards,
Hiroshi Inoue

(2013/05/25 1:55), Joshua Berry wrote:
> Hi Groups,
>
> I'm dealing with periodic backend process segmentation faults. I'm
> posting to both the bugs and odbc lists as it seems that my
> application's use of pgsqlODBC triggers a bug in the postgres backend.
>
> The environment is:
> Clients: win32 clients using various version of the psqlODBC driver
> (mostly using 8.04.0200). The connection string contains
> "UseDeclareFetch=1" which causes long idle transactions, heavy cursor
> and savepoint use.
> Server: Dell dual Xeon x86 48GB RAM (12GB PG shared mem) RHEL system
> with Postgresql 9.2.4. Note that these same issues occurred on PG9.1 and
> PG8.4.
>
> I've experienced these issues for over a year now. However, during that
> time several things have changed which may or may not be related:
> * The schema has been modified with heavier use of triggers to update
> manually created materialized views (ie not using the 9.3 CREATE
> MATERIALIZED VIEW).
> * The number of concurrent users has increased (from perhaps 15
> concurrent users two years ago, to 30 concurrent users now).
> * The PG version used has changed from 8.4, to 9.1, and finally to 9.2
> * I've done recent tuning to the planner cost constants in order to
> favor index scans over table scans in more situations.
>
> I've looked through past error logs and I found that I had a segfault in
> the server process while using PG 8.4 about a dozen times over a 12
> month period. Each time one client's postgres process crashes, the
> backend forcefully closes all active connections due to possiby
> corrupted memory and then restarts. This leaves all active clients
> stranded as the connection is closed, and all cursors and savepoint info
> is lost. My app doesn't recover gracefully, and users are forced to
> click through some cryptic error messages from the application framework
> used for the app (Clarion) and then restart the app.
>
> A few months ago, I upgraded to another server with PG 9.1, assuming
> that the issue with the previous server with 8.4 was due to bad RAM, as
> I did observe a high ECC error count on the previous system as logged by
> the IPMI controller. However, I very quickly had another segfault on the
> new system with PG9.1. The default settings of the OS and PG init script
> disabled core dumps, so I only started collecting core files for the
> past few months.
>
> I posted details in pgsql-general April 10, 2013; here is a link to the
> thread:
> http://www.postgresql.org/message-id/CAPmZXM03MEDEn6nqqf_Phs3M1DK-EaXP5_K-LmirneOJMAQ-Hg@mail.gmail....
>
> The crash always is some variation of the following stack, as observed
> in both PG91 and PG92 crashes:
> (gdb) bt
> #0  ResourceOwnerEnlargeCatCacheRefs (owner=0x0) at resowner.c:603
> #1  0x000000000070f372 in SearchCatCache (cache=0x27fab90, v1=<value
> optimized out>, v2=<value optimized out>, v3=<value optimized out>,
> v4=<value optimized out>) at catcache.c:1136
> #2  0x000000000071b1ae in getTypeOutputInfo (type=20,
> typOutput=0x2b3db80, typIsVarlena=0x2b3db88 "") at lsyscache.c:2482
> #3  0x000000000045d127 in printtup_prepare_info (myState=0x2810290,
> typeinfo=0x29ad7b0, numAttrs=42) at printtup.c:263
> #4  0x000000000045d4c4 in printtup (slot=0x3469650, self=0x2810290) at
> printtup.c:297
> #5  0x000000000065a76a in RunFromStore (portal=0x285fed0,
> direction=<value optimized out>, count=10, dest=0x2810290) at pquery.c:1122
> #6  0x000000000065a852 in PortalRunSelect (portal=0x285fed0,
> forward=<value optimized out>, count=10, dest=0x2810290) at pquery.c:940
> #7  0x000000000065bcf8 in PortalRun (portal=0x285fed0, count=10,
> isTopLevel=1 '\001', dest=0x2810290, altdest=0x2810290,
> completionTag=0x7fffee67f7c0 "") at pquery.c:788
> #8  0x0000000000659552 in exec_execute_message (argc=<value optimized
> out>, argv=<value optimized out>, dbname=0x2768370 "DBNAME",
> username=<value optimized out>) at postgres.c:1929
> #9  PostgresMain (argc=<value optimized out>, argv=<value optimized
> out>, dbname=0x2768370 "DBNAME", username=<value optimized out>) at
> postgres.c:4016
> #10 0x0000000000615161 in BackendRun () at postmaster.c:3614
> #11 BackendStartup () at postmaster.c:3304
> #12 ServerLoop () at postmaster.c:1367
> #13 0x0000000000617dcc in PostmasterMain (argc=<value optimized out>,
> argv=<value optimized out>) at postmaster.c:1127
> #14 0x00000000005b6830 in main (argc=5, argv=0x2766480) at main.c:199
> (gdb)
>
> Andres Freund and Tom Lane spent some time tracking down possible root
> causes with some of the following summaries:
>
> Tom Lane writes:
> |Andres Freund <andres@2ndquadrant.com <mailto:andres@2ndquadrant.com>>
> writes:
> |> Tom: It looks to me like printtup_prepare_info won't normally be called
> |> in an held cursor. But if some concurrent DDL changed the number of
> |> columns in typeinfo vs thaose in the the receiver that could explain the
> |> issue and why its not seen all the time, right?
> |
> |It looks to me like there are probably two triggering conditions:
> |
> |1. Client is doing a direct protocol Execute on a held-cursor portal.
> |
> |2. Cache flush occurs to drop the syscache entries needed by
> |getTypeOutputInfo.  (Otherwise, they'd still be around from when the
> |held cursor was created.)
> |
> |The first of these explains why we don't see it in the
> |CLOBBER_CACHE_ALWAYS buildfarm runs, and the second one explains why
> |Joshua is only seeing it intermittently and not every darn time his
> |application does that.
>
> Andres Freund writes:
> |On 2013-04-10 19:06:12 -0400, Tom Lane wrote:
> |> I wrote:
> |> > (Wanders away wondering just how much the regression tests exercise
> |> > holdable cursors.)
> |>
> |> And the answer is they're not testing this code path at all, because if
> |> you do
> |>       DECLARE c CURSOR WITH HOLD FOR ...
> |>       FETCH ALL FROM c;
> |> then the second query executes with a portal (and resource owner)
> |> created to execute the FETCH command, not directly on the held portal.
> |>
> |> After a little bit of thought I'm not sure it's even possible to
> |> reproduce this problem with libpq, because it doesn't expose any way to
> |> issue a bare protocol Execute command against a pre-existing portal.
> |> (I had thought psqlOBC went through libpq, but maybe it's playing some
> |> games here.)
> |
> |Hm. PQexecPrepared() looks like it can do that.
>
> I didn't find that any bugs were officially reported/documented, so I
> wanted to followup with more detail and follow the guidelines here:
> http://www.postgresql.org/docs/current/static/bug-reporting.html
> Specifically, I decided to update to the latest stable release,
> currently PG9.2.4.
>
> After updating to PG92 three days ago, I've had two of the same
> segfaults. Either I'm very (un)lucky or the intermittant issue is
> occurring more frequently with PG92.
>
> On a test machine running a snapshort of the production database, and
> with the backend configured to log all queries, I have an example of the
> type of traffic that client apps will perform:
> https://dl.dropboxusercontent.com/u/4715250/pg92_psqlODBC_08.04.0200.txt
> In the above logfile, the logfile was cleared, the client app was
> started, A window was opened, it was closed, and the app was closed. I
> installed pgODBC version 09.01.0200, and aside from cursor names and
> timestamps differing, all other lines were identical.
>
> I do not currently have a testing environment which can emulate the
> production environment enough to trigger this bug. I've never had this
> crash outside of the production environment.
>
> Any thoughts/suggestions?
>
> Regards,
> -Joshua



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



^ permalink  raw  reply  [nested|flat] 18+ messages in thread

* Re: Segmentation Fault in Postgres server when using psqlODBC
  2013-05-24 16:55 Segmentation Fault in Postgres server when using psqlODBC Joshua Berry <yoberi@gmail.com>
  2013-05-24 21:25 ` Re: Segmentation Fault in Postgres server when using psqlODBC Hiroshi Inoue <inoue@tpf.co.jp>
@ 2013-05-28 14:20   ` Joshua Berry <yoberi@gmail.com>
  2013-05-28 20:19     ` Re: Segmentation Fault in Postgres server when using psqlODBC Hiroshi Inoue <inoue@tpf.co.jp>
  0 siblings, 1 reply; 18+ messages in thread

From: Joshua Berry @ 2013-05-28 14:20 UTC (permalink / raw)
  To: Hiroshi Inoue <inoue@tpf.co.jp>; +Cc: pgsql-odbc

Hi Hiroshi,

On Fri, May 24, 2013 at 4:25 PM, Hiroshi Inoue <inoue@tpf.co.jp> wrote:

> Psqlodbc drivers send Execite requests for cursors instead of
> issueing FETCH commands.
>

Thanks for the reply. Have you seen or heard of psqlODBC's use of
cursors intermittently causing segfaults as I'd described? If so, can these
issues be avoided by enabling or disabling options in the driver or
avoiding certain queries/conditions? The entire system is a  blackbox to
me, so when I encounter issues like this, I'm not sure how to diagnose and
correct. Any advice or tips would be much appreciated.

Kind Regards,
-Joshua

^ permalink  raw  reply  [nested|flat] 18+ messages in thread

* Re: Segmentation Fault in Postgres server when using psqlODBC
  2013-05-24 16:55 Segmentation Fault in Postgres server when using psqlODBC Joshua Berry <yoberi@gmail.com>
  2013-05-24 21:25 ` Re: Segmentation Fault in Postgres server when using psqlODBC Hiroshi Inoue <inoue@tpf.co.jp>
  2013-05-28 14:20   ` Re: Segmentation Fault in Postgres server when using psqlODBC Joshua Berry <yoberi@gmail.com>
@ 2013-05-28 20:19     ` Hiroshi Inoue <inoue@tpf.co.jp>
  2013-05-29 03:02       ` Re: Segmentation Fault in Postgres server when using psqlODBC Joshua Berry <yoberi@gmail.com>
  0 siblings, 1 reply; 18+ messages in thread

From: Hiroshi Inoue @ 2013-05-28 20:19 UTC (permalink / raw)
  To: Joshua Berry <yoberi@gmail.com>; +Cc: pgsql-odbc

Hi Joshua,

(2013/05/28 23:20), Joshua Berry wrote:
> Hi Hiroshi,
>
> On Fri, May 24, 2013 at 4:25 PM, Hiroshi Inoue <inoue@tpf.co.jp
> <mailto:inoue@tpf.co.jp>> wrote:
>
>     Psqlodbc drivers send Execite requests for cursors instead of
>     issueing FETCH commands.
>
>
> Thanks for the reply. Have you seen or heard of psqlODBC's use of
> cursors intermittently causing segfaults as I'd described?

No.

I have a question about your application.
Is your application mutilthreaded?
If so, do multiple threads share the same connection?

regards,
Hiroshi Inoue


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



^ permalink  raw  reply  [nested|flat] 18+ messages in thread

* Re: Segmentation Fault in Postgres server when using psqlODBC
  2013-05-24 16:55 Segmentation Fault in Postgres server when using psqlODBC Joshua Berry <yoberi@gmail.com>
  2013-05-24 21:25 ` Re: Segmentation Fault in Postgres server when using psqlODBC Hiroshi Inoue <inoue@tpf.co.jp>
  2013-05-28 14:20   ` Re: Segmentation Fault in Postgres server when using psqlODBC Joshua Berry <yoberi@gmail.com>
  2013-05-28 20:19     ` Re: Segmentation Fault in Postgres server when using psqlODBC Hiroshi Inoue <inoue@tpf.co.jp>
@ 2013-05-29 03:02       ` Joshua Berry <yoberi@gmail.com>
  2013-05-30 13:52         ` Re: Segmentation Fault in Postgres server when using psqlODBC Hiroshi Inoue <inoue@tpf.co.jp>
  0 siblings, 1 reply; 18+ messages in thread

From: Joshua Berry @ 2013-05-29 03:02 UTC (permalink / raw)
  To: Hiroshi Inoue <inoue@tpf.co.jp>; +Cc: pgsql-odbc

Hi Hiroshi,

On Tue, May 28, 2013 at 3:19 PM, Hiroshi Inoue <inoue@tpf.co.jp> wrote:

> Thanks for the reply. Have you seen or heard of psqlODBC's use of
>> cursors intermittently causing segfaults as I'd described?
>>
>
> No.
>
> I have a question about your application.
> Is your application mutilthreaded?
> If so, do multiple threads share the same connection?
>

It is multithreaded; all threads use the same connection.

Regards,
-Joshua

^ permalink  raw  reply  [nested|flat] 18+ messages in thread

* Re: Segmentation Fault in Postgres server when using psqlODBC
  2013-05-24 16:55 Segmentation Fault in Postgres server when using psqlODBC Joshua Berry <yoberi@gmail.com>
  2013-05-24 21:25 ` Re: Segmentation Fault in Postgres server when using psqlODBC Hiroshi Inoue <inoue@tpf.co.jp>
  2013-05-28 14:20   ` Re: Segmentation Fault in Postgres server when using psqlODBC Joshua Berry <yoberi@gmail.com>
  2013-05-28 20:19     ` Re: Segmentation Fault in Postgres server when using psqlODBC Hiroshi Inoue <inoue@tpf.co.jp>
  2013-05-29 03:02       ` Re: Segmentation Fault in Postgres server when using psqlODBC Joshua Berry <yoberi@gmail.com>
@ 2013-05-30 13:52         ` Hiroshi Inoue <inoue@tpf.co.jp>
  2013-06-03 14:55           ` Re: Segmentation Fault in Postgres server when using psqlODBC Joshua Berry <yoberi@gmail.com>
  0 siblings, 1 reply; 18+ messages in thread

From: Hiroshi Inoue @ 2013-05-30 13:52 UTC (permalink / raw)
  To: Joshua Berry <yoberi@gmail.com>; +Cc: pgsql-odbc

Hi Joshua,

(2013/05/29 12:02), Joshua Berry wrote:
> Hi Hiroshi,
>
> On Tue, May 28, 2013 at 3:19 PM, Hiroshi Inoue <inoue@tpf.co.jp
> <mailto:inoue@tpf.co.jp>> wrote:
>
>         Thanks for the reply. Have you seen or heard of psqlODBC's use of
>         cursors intermittently causing segfaults as I'd described?
>
>
>     No.
>
>     I have a question about your application.
>     Is your application mutilthreaded?
>     If so, do multiple threads share the same connection?
>
> It is multithreaded; all threads use the same connection.

There's a possibility that the crash is caused by the multithreaded
application. Jack Wilson's bug report seems also related to multithread 
and I sent him a patch to fix the bug hopefully. We will release the 
next release when the patch fixes the bug.

regards,
Hiroshi Inoue



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



^ permalink  raw  reply  [nested|flat] 18+ messages in thread

* Re: Segmentation Fault in Postgres server when using psqlODBC
  2013-05-24 16:55 Segmentation Fault in Postgres server when using psqlODBC Joshua Berry <yoberi@gmail.com>
  2013-05-24 21:25 ` Re: Segmentation Fault in Postgres server when using psqlODBC Hiroshi Inoue <inoue@tpf.co.jp>
  2013-05-28 14:20   ` Re: Segmentation Fault in Postgres server when using psqlODBC Joshua Berry <yoberi@gmail.com>
  2013-05-28 20:19     ` Re: Segmentation Fault in Postgres server when using psqlODBC Hiroshi Inoue <inoue@tpf.co.jp>
  2013-05-29 03:02       ` Re: Segmentation Fault in Postgres server when using psqlODBC Joshua Berry <yoberi@gmail.com>
  2013-05-30 13:52         ` Re: Segmentation Fault in Postgres server when using psqlODBC Hiroshi Inoue <inoue@tpf.co.jp>
@ 2013-06-03 14:55           ` Joshua Berry <yoberi@gmail.com>
  2013-06-04 03:47             ` Re: Segmentation Fault in Postgres server when using psqlODBC Inoue, Hiroshi <inoue@tpf.co.jp>
  0 siblings, 1 reply; 18+ messages in thread

From: Joshua Berry @ 2013-06-03 14:55 UTC (permalink / raw)
  To: Hiroshi Inoue <inoue@tpf.co.jp>; +Cc: pgsql-odbc

Hi Hiroshi,

On Thu, May 30, 2013 at 8:52 AM, Hiroshi Inoue <inoue@tpf.co.jp> wrote:

> It is multithreaded; all threads use the same connection.
>>
>
> There's a possibility that the crash is caused by the multithreaded
> application. Jack Wilson's bug report seems also related to multithread
> and I sent him a patch to fix the bug hopefully. We will release the next
> release when the patch fixes the bug.
>


Thanks for letting me know. I have not had another crash since my last
posting to the list, so nothing more to report on this.

Kind Regards,
-Joshua

^ permalink  raw  reply  [nested|flat] 18+ messages in thread

* Re: Segmentation Fault in Postgres server when using psqlODBC
  2013-05-24 16:55 Segmentation Fault in Postgres server when using psqlODBC Joshua Berry <yoberi@gmail.com>
  2013-05-24 21:25 ` Re: Segmentation Fault in Postgres server when using psqlODBC Hiroshi Inoue <inoue@tpf.co.jp>
  2013-05-28 14:20   ` Re: Segmentation Fault in Postgres server when using psqlODBC Joshua Berry <yoberi@gmail.com>
  2013-05-28 20:19     ` Re: Segmentation Fault in Postgres server when using psqlODBC Hiroshi Inoue <inoue@tpf.co.jp>
  2013-05-29 03:02       ` Re: Segmentation Fault in Postgres server when using psqlODBC Joshua Berry <yoberi@gmail.com>
  2013-05-30 13:52         ` Re: Segmentation Fault in Postgres server when using psqlODBC Hiroshi Inoue <inoue@tpf.co.jp>
  2013-06-03 14:55           ` Re: Segmentation Fault in Postgres server when using psqlODBC Joshua Berry <yoberi@gmail.com>
@ 2013-06-04 03:47             ` Inoue, Hiroshi <inoue@tpf.co.jp>
  2013-06-04 14:46               ` Re: Segmentation Fault in Postgres server when using psqlODBC Joshua Berry <yoberi@gmail.com>
  0 siblings, 1 reply; 18+ messages in thread

From: Inoue, Hiroshi @ 2013-06-04 03:47 UTC (permalink / raw)
  To: Joshua Berry <yoberi@gmail.com>; +Cc: pgsql-odbc

Hi Joshua,

(2013/06/03 23:55), Joshua Berry wrote:
> Hi Hiroshi,
>
> On Thu, May 30, 2013 at 8:52 AM, Hiroshi Inoue <inoue@tpf.co.jp
> <mailto:inoue@tpf.co.jp>> wrote:
>
>         It is multithreaded; all threads use the same connection.
>
>
>     There's a possibility that the crash is caused by the multithreaded
>     application. Jack Wilson's bug report seems also related to
>     multithread and I sent him a patch to fix the bug hopefully. We will
>     release the next release when the patch fixes the bug.
>
>
>
> Thanks for letting me know. I have not had another crash since my last
> posting to the list, so nothing more to report on this.

It's also preferrable to fix the crash at backend.
The crash is caused by execute commands after commit.

regards,
Hiroshi Inoue




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



^ permalink  raw  reply  [nested|flat] 18+ messages in thread

* Re: Segmentation Fault in Postgres server when using psqlODBC
  2013-05-24 16:55 Segmentation Fault in Postgres server when using psqlODBC Joshua Berry <yoberi@gmail.com>
  2013-05-24 21:25 ` Re: Segmentation Fault in Postgres server when using psqlODBC Hiroshi Inoue <inoue@tpf.co.jp>
  2013-05-28 14:20   ` Re: Segmentation Fault in Postgres server when using psqlODBC Joshua Berry <yoberi@gmail.com>
  2013-05-28 20:19     ` Re: Segmentation Fault in Postgres server when using psqlODBC Hiroshi Inoue <inoue@tpf.co.jp>
  2013-05-29 03:02       ` Re: Segmentation Fault in Postgres server when using psqlODBC Joshua Berry <yoberi@gmail.com>
  2013-05-30 13:52         ` Re: Segmentation Fault in Postgres server when using psqlODBC Hiroshi Inoue <inoue@tpf.co.jp>
  2013-06-03 14:55           ` Re: Segmentation Fault in Postgres server when using psqlODBC Joshua Berry <yoberi@gmail.com>
  2013-06-04 03:47             ` Re: Segmentation Fault in Postgres server when using psqlODBC Inoue, Hiroshi <inoue@tpf.co.jp>
@ 2013-06-04 14:46               ` Joshua Berry <yoberi@gmail.com>
  2013-06-04 15:48                 ` Re: Segmentation Fault in Postgres server when using psqlODBC Joshua Berry <yoberi@gmail.com>
  0 siblings, 1 reply; 18+ messages in thread

From: Joshua Berry @ 2013-06-04 14:46 UTC (permalink / raw)
  To: Inoue, Hiroshi <inoue@tpf.co.jp>; +Cc: pgsql-odbc

Hi Hiroshi,

On Mon, Jun 3, 2013 at 10:47 PM, Inoue, Hiroshi <inoue@tpf.co.jp> wrote:

> It's also preferrable to fix the crash at backend.
> The crash is caused by execute commands after commit.
>

That would be the best solution. Thanks for your help.

Kind Regards,
-Joshua

^ permalink  raw  reply  [nested|flat] 18+ messages in thread

* Re: Segmentation Fault in Postgres server when using psqlODBC
  2013-05-24 16:55 Segmentation Fault in Postgres server when using psqlODBC Joshua Berry <yoberi@gmail.com>
  2013-05-24 21:25 ` Re: Segmentation Fault in Postgres server when using psqlODBC Hiroshi Inoue <inoue@tpf.co.jp>
  2013-05-28 14:20   ` Re: Segmentation Fault in Postgres server when using psqlODBC Joshua Berry <yoberi@gmail.com>
  2013-05-28 20:19     ` Re: Segmentation Fault in Postgres server when using psqlODBC Hiroshi Inoue <inoue@tpf.co.jp>
  2013-05-29 03:02       ` Re: Segmentation Fault in Postgres server when using psqlODBC Joshua Berry <yoberi@gmail.com>
  2013-05-30 13:52         ` Re: Segmentation Fault in Postgres server when using psqlODBC Hiroshi Inoue <inoue@tpf.co.jp>
  2013-06-03 14:55           ` Re: Segmentation Fault in Postgres server when using psqlODBC Joshua Berry <yoberi@gmail.com>
  2013-06-04 03:47             ` Re: Segmentation Fault in Postgres server when using psqlODBC Inoue, Hiroshi <inoue@tpf.co.jp>
  2013-06-04 14:46               ` Re: Segmentation Fault in Postgres server when using psqlODBC Joshua Berry <yoberi@gmail.com>
@ 2013-06-04 15:48                 ` Joshua Berry <yoberi@gmail.com>
  2013-06-06 03:39                   ` Re: Segmentation Fault in Postgres server when using psqlODBC Hiroshi Inoue <inoue@tpf.co.jp>
  0 siblings, 1 reply; 18+ messages in thread

From: Joshua Berry @ 2013-06-04 15:48 UTC (permalink / raw)
  To: Inoue, Hiroshi <inoue@tpf.co.jp>; +Cc: pgsql-odbc

Hi Hiroshi,

On Tue, Jun 4, 2013 at 9:46 AM, Joshua Berry <yoberi@gmail.com> wrote:

>
> On Mon, Jun 3, 2013 at 10:47 PM, Inoue, Hiroshi <inoue@tpf.co.jp> wrote:
>
>> It's also preferrable to fix the crash at backend.
>> The crash is caused by execute commands after commit.
>>
>
> That would be the best solution. Thanks for your help.
>

Is there any test code that I could leverage to put together a test case
which can quickly invoke the backend problem that I'm seeing? Perhaps
something that is used in the pgsqlODBC project or something else you or
others might have sitting around? I would like to have a testapp/function
that could help verify that the issue has been fixed in a future backend
patch/release.

I've never explicitly used EXECUTE. Could I construct a plpgsql script
which could use EXECUTE in a similar manner as psqlODBC, thus creating a
test case that would have greater portability?

Kind Regards,
-Joshua

^ permalink  raw  reply  [nested|flat] 18+ messages in thread

* Re: Segmentation Fault in Postgres server when using psqlODBC
  2013-05-24 16:55 Segmentation Fault in Postgres server when using psqlODBC Joshua Berry <yoberi@gmail.com>
  2013-05-24 21:25 ` Re: Segmentation Fault in Postgres server when using psqlODBC Hiroshi Inoue <inoue@tpf.co.jp>
  2013-05-28 14:20   ` Re: Segmentation Fault in Postgres server when using psqlODBC Joshua Berry <yoberi@gmail.com>
  2013-05-28 20:19     ` Re: Segmentation Fault in Postgres server when using psqlODBC Hiroshi Inoue <inoue@tpf.co.jp>
  2013-05-29 03:02       ` Re: Segmentation Fault in Postgres server when using psqlODBC Joshua Berry <yoberi@gmail.com>
  2013-05-30 13:52         ` Re: Segmentation Fault in Postgres server when using psqlODBC Hiroshi Inoue <inoue@tpf.co.jp>
  2013-06-03 14:55           ` Re: Segmentation Fault in Postgres server when using psqlODBC Joshua Berry <yoberi@gmail.com>
  2013-06-04 03:47             ` Re: Segmentation Fault in Postgres server when using psqlODBC Inoue, Hiroshi <inoue@tpf.co.jp>
  2013-06-04 14:46               ` Re: Segmentation Fault in Postgres server when using psqlODBC Joshua Berry <yoberi@gmail.com>
  2013-06-04 15:48                 ` Re: Segmentation Fault in Postgres server when using psqlODBC Joshua Berry <yoberi@gmail.com>
@ 2013-06-06 03:39                   ` Hiroshi Inoue <inoue@tpf.co.jp>
  2013-06-11 16:04                     ` Re: [ODBC] Segmentation Fault in Postgres server when using psqlODBC Joshua Berry <yoberi@gmail.com>
  0 siblings, 1 reply; 18+ messages in thread

From: Hiroshi Inoue @ 2013-06-06 03:39 UTC (permalink / raw)
  To: Joshua Berry <yoberi@gmail.com>; +Cc: pgsql-odbc

(2013/06/05 0:48), Joshua Berry wrote:
> Hi Hiroshi,
>
> On Tue, Jun 4, 2013 at 9:46 AM, Joshua Berry <yoberi@gmail.com
> <mailto:yoberi@gmail.com>> wrote:
>
>
>     On Mon, Jun 3, 2013 at 10:47 PM, Inoue, Hiroshi <inoue@tpf.co.jp
>     <mailto:inoue@tpf.co.jp>> wrote:
>
>         It's also preferrable to fix the crash at backend.
>         The crash is caused by execute commands after commit.
>
>     That would be the best solution. Thanks for your help.
>
>
> Is there any test code that I could leverage to put together a test case
> which can quickly invoke the backend problem that I'm seeing? Perhaps
> something that is used in the pgsqlODBC project or something else you or
> others might have sitting around? I would like to have a
> testapp/function that could help verify that the issue has been fixed in
> a future backend patch/release.

It seems difficult to provide a test code. However I can reproduce
the crash by changing 1 line of psqlodbc driver source code with a
test case. For example, the crash is fixed by the attached patch.

> I've never explicitly used EXECUTE. Could I construct a plpgsql script
> which could use EXECUTE in a similar manner as psqlODBC, thus creating a
> test case that would have greater portability?

Oops it's an Execute message used in extended query protocol not a
*EXECUTE* command.

regards,
Hiroshi Inoue

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

Attachments:

printtup_holdable_cursor.patch (text/x-patch, 1.4K) download diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index e87e675..258a4c2 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -238,6 +238,7 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) { int16 *formats = myState->portal->formats; int i; + bool resownerIsNull = false; /* get rid of any old data */ if (myState->myinfo) @@ -252,6 +253,15 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) myState->myinfo = (PrinttupAttrInfo *) palloc0(numAttrs * sizeof(PrinttupAttrInfo)); + if (NULL == CurrentResourceOwner) + { + /* + * This occurs when processing execute messages + * for holdable cursors after commit. + */ + resownerIsNull = true; + CurrentResourceOwner = CurTransactionResourceOwner; + } for (i = 0; i < numAttrs; i++) { PrinttupAttrInfo *thisState = myState->myinfo + i; @@ -273,10 +283,16 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) fmgr_info(thisState->typsend, &thisState->finfo); } else + { + if (resownerIsNull) + CurrentResourceOwner = NULL; ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + } } + if (resownerIsNull) + CurrentResourceOwner = NULL; } /* ----------------
^ permalink raw reply [nested|flat] 18+ messages in thread

* Re: [ODBC] Segmentation Fault in Postgres server when using psqlODBC
  2013-05-24 16:55 Segmentation Fault in Postgres server when using psqlODBC Joshua Berry <yoberi@gmail.com>
  2013-05-24 21:25 ` Re: Segmentation Fault in Postgres server when using psqlODBC Hiroshi Inoue <inoue@tpf.co.jp>
  2013-05-28 14:20   ` Re: Segmentation Fault in Postgres server when using psqlODBC Joshua Berry <yoberi@gmail.com>
  2013-05-28 20:19     ` Re: Segmentation Fault in Postgres server when using psqlODBC Hiroshi Inoue <inoue@tpf.co.jp>
  2013-05-29 03:02       ` Re: Segmentation Fault in Postgres server when using psqlODBC Joshua Berry <yoberi@gmail.com>
  2013-05-30 13:52         ` Re: Segmentation Fault in Postgres server when using psqlODBC Hiroshi Inoue <inoue@tpf.co.jp>
  2013-06-03 14:55           ` Re: Segmentation Fault in Postgres server when using psqlODBC Joshua Berry <yoberi@gmail.com>
  2013-06-04 03:47             ` Re: Segmentation Fault in Postgres server when using psqlODBC Inoue, Hiroshi <inoue@tpf.co.jp>
  2013-06-04 14:46               ` Re: Segmentation Fault in Postgres server when using psqlODBC Joshua Berry <yoberi@gmail.com>
  2013-06-04 15:48                 ` Re: Segmentation Fault in Postgres server when using psqlODBC Joshua Berry <yoberi@gmail.com>
  2013-06-06 03:39                   ` Re: Segmentation Fault in Postgres server when using psqlODBC Hiroshi Inoue <inoue@tpf.co.jp>
@ 2013-06-11 16:04                     ` Joshua Berry <yoberi@gmail.com>
  2013-06-11 16:20                       ` Re: [ODBC] Segmentation Fault in Postgres server when using psqlODBC Heikki Linnakangas <hlinnakangas@vmware.com>
  0 siblings, 1 reply; 18+ messages in thread

From: Joshua Berry @ 2013-06-11 16:04 UTC (permalink / raw)
  To: Hiroshi Inoue <inoue@tpf.co.jp>; +Cc: pgsql-bugs@postgresql.org

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.

The root issue:

     Inoue, Hiroshi <inoue@tpf.co.jp  <mailto:inoue@tpf.co.jp>> wrote:
>>
>>         It's also preferrable to fix the crash at backend.
>>         The crash is caused by execute commands after commit.
>>
>
Regarding testing:


> Is there any test code that I could leverage to put together a test case
>> which can quickly invoke the backend problem that I'm seeing? Perhaps
>> something that is used in the pgsqlODBC project or something else you
>> or others might have sitting around? I would like to have a
>> testapp/function that could help verify that the issue has been fixed in
>> a future backend patch/release.
>>
>
> It seems difficult to provide a test code. However I can reproduce
> the crash by changing 1 line of psqlodbc driver source code with a
> test case. For example, the crash is fixed by the attached patch.
>
>
>  I've never explicitly used EXECUTE. Could I construct a plpgsql script
>> which could use EXECUTE in a similar manner as psqlODBC, thus creating a
>> test case that would have greater portability?
>>
>
> Oops it's an Execute message used in extended query protocol not a
> *EXECUTE* command.
>

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

Attachments:

printtup_holdable_cursor.patch (application/octet-stream, 1.4K) download diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index e87e675..258a4c2 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -238,6 +238,7 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) { int16 *formats = myState->portal->formats; int i; + bool resownerIsNull = false; /* get rid of any old data */ if (myState->myinfo) @@ -252,6 +253,15 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) myState->myinfo = (PrinttupAttrInfo *) palloc0(numAttrs * sizeof(PrinttupAttrInfo)); + if (NULL == CurrentResourceOwner) + { + /* + * This occurs when processing execute messages + * for holdable cursors after commit. + */ + resownerIsNull = true; + CurrentResourceOwner = CurTransactionResourceOwner; + } for (i = 0; i < numAttrs; i++) { PrinttupAttrInfo *thisState = myState->myinfo + i; @@ -273,10 +283,16 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) fmgr_info(thisState->typsend, &thisState->finfo); } else + { + if (resownerIsNull) + CurrentResourceOwner = NULL; ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + } } + if (resownerIsNull) + CurrentResourceOwner = NULL; } /* ----------------
^ permalink raw reply [nested|flat] 18+ messages in thread

* Re: [ODBC] Segmentation Fault in Postgres server when using psqlODBC
  2013-05-24 16:55 Segmentation Fault in Postgres server when using psqlODBC Joshua Berry <yoberi@gmail.com>
  2013-05-24 21:25 ` Re: Segmentation Fault in Postgres server when using psqlODBC Hiroshi Inoue <inoue@tpf.co.jp>
  2013-05-28 14:20   ` Re: Segmentation Fault in Postgres server when using psqlODBC Joshua Berry <yoberi@gmail.com>
  2013-05-28 20:19     ` Re: Segmentation Fault in Postgres server when using psqlODBC Hiroshi Inoue <inoue@tpf.co.jp>
  2013-05-29 03:02       ` Re: Segmentation Fault in Postgres server when using psqlODBC Joshua Berry <yoberi@gmail.com>
  2013-05-30 13:52         ` Re: Segmentation Fault in Postgres server when using psqlODBC Hiroshi Inoue <inoue@tpf.co.jp>
  2013-06-03 14:55           ` Re: Segmentation Fault in Postgres server when using psqlODBC Joshua Berry <yoberi@gmail.com>
  2013-06-04 03:47             ` Re: Segmentation Fault in Postgres server when using psqlODBC Inoue, Hiroshi <inoue@tpf.co.jp>
  2013-06-04 14:46               ` Re: Segmentation Fault in Postgres server when using psqlODBC Joshua Berry <yoberi@gmail.com>
  2013-06-04 15:48                 ` Re: Segmentation Fault in Postgres server when using psqlODBC Joshua Berry <yoberi@gmail.com>
  2013-06-06 03:39                   ` Re: Segmentation Fault in Postgres server when using psqlODBC Hiroshi Inoue <inoue@tpf.co.jp>
  2013-06-11 16:04                     ` Re: [ODBC] Segmentation Fault in Postgres server when using psqlODBC Joshua Berry <yoberi@gmail.com>
@ 2013-06-11 16:20                       ` Heikki Linnakangas <hlinnakangas@vmware.com>
  2013-06-11 16:26                         ` Re: [ODBC] Segmentation Fault in Postgres server when using psqlODBC Andres Freund <andres@2ndquadrant.com>
  0 siblings, 1 reply; 18+ messages in thread

From: Heikki Linnakangas @ 2013-06-11 16:20 UTC (permalink / raw)
  To: Joshua Berry <yoberi@gmail.com>; +Cc: Hiroshi Inoue <inoue@tpf.co.jp>; pgsql-bugs@postgresql.org

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?

- Heikki


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



^ permalink  raw  reply  [nested|flat] 18+ messages in thread

* Re: [ODBC] Segmentation Fault in Postgres server when using psqlODBC
  2013-05-24 16:55 Segmentation Fault in Postgres server when using psqlODBC Joshua Berry <yoberi@gmail.com>
  2013-05-24 21:25 ` Re: Segmentation Fault in Postgres server when using psqlODBC Hiroshi Inoue <inoue@tpf.co.jp>
  2013-05-28 14:20   ` Re: Segmentation Fault in Postgres server when using psqlODBC Joshua Berry <yoberi@gmail.com>
  2013-05-28 20:19     ` Re: Segmentation Fault in Postgres server when using psqlODBC Hiroshi Inoue <inoue@tpf.co.jp>
  2013-05-29 03:02       ` Re: Segmentation Fault in Postgres server when using psqlODBC Joshua Berry <yoberi@gmail.com>
  2013-05-30 13:52         ` Re: Segmentation Fault in Postgres server when using psqlODBC Hiroshi Inoue <inoue@tpf.co.jp>
  2013-06-03 14:55           ` Re: Segmentation Fault in Postgres server when using psqlODBC Joshua Berry <yoberi@gmail.com>
  2013-06-04 03:47             ` Re: Segmentation Fault in Postgres server when using psqlODBC Inoue, Hiroshi <inoue@tpf.co.jp>
  2013-06-04 14:46               ` Re: Segmentation Fault in Postgres server when using psqlODBC Joshua Berry <yoberi@gmail.com>
  2013-06-04 15:48                 ` Re: Segmentation Fault in Postgres server when using psqlODBC Joshua Berry <yoberi@gmail.com>
  2013-06-06 03:39                   ` Re: Segmentation Fault in Postgres server when using psqlODBC Hiroshi Inoue <inoue@tpf.co.jp>
  2013-06-11 16:04                     ` Re: [ODBC] Segmentation Fault in Postgres server when using psqlODBC Joshua Berry <yoberi@gmail.com>
  2013-06-11 16:20                       ` Re: [ODBC] Segmentation Fault in Postgres server when using psqlODBC Heikki Linnakangas <hlinnakangas@vmware.com>
@ 2013-06-11 16:26                         ` Andres Freund <andres@2ndquadrant.com>
  2013-06-13 13:31                           ` Re: [ODBC] Segmentation Fault in Postgres server when using psqlODBC Hiroshi Inoue <inoue@tpf.co.jp>
  0 siblings, 1 reply; 18+ messages in thread

From: Andres Freund @ 2013-06-11 16:26 UTC (permalink / raw)
  To: Heikki Linnakangas <hlinnakangas@vmware.com>; +Cc: Joshua Berry <yoberi@gmail.com>; Hiroshi Inoue <inoue@tpf.co.jp>; pgsql-bugs@postgresql.org

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.

Greetings,

Andres Freund

-- 
 Andres Freund	                   http://www.2ndQuadrant.com/
 PostgreSQL Development, 24x7 Support, Training & Services


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



^ permalink  raw  reply  [nested|flat] 18+ messages in thread

* Re: [ODBC] Segmentation Fault in Postgres server when using psqlODBC
  2013-05-24 16:55 Segmentation Fault in Postgres server when using psqlODBC Joshua Berry <yoberi@gmail.com>
  2013-05-24 21:25 ` Re: Segmentation Fault in Postgres server when using psqlODBC Hiroshi Inoue <inoue@tpf.co.jp>
  2013-05-28 14:20   ` Re: Segmentation Fault in Postgres server when using psqlODBC Joshua Berry <yoberi@gmail.com>
  2013-05-28 20:19     ` Re: Segmentation Fault in Postgres server when using psqlODBC Hiroshi Inoue <inoue@tpf.co.jp>
  2013-05-29 03:02       ` Re: Segmentation Fault in Postgres server when using psqlODBC Joshua Berry <yoberi@gmail.com>
  2013-05-30 13:52         ` Re: Segmentation Fault in Postgres server when using psqlODBC Hiroshi Inoue <inoue@tpf.co.jp>
  2013-06-03 14:55           ` Re: Segmentation Fault in Postgres server when using psqlODBC Joshua Berry <yoberi@gmail.com>
  2013-06-04 03:47             ` Re: Segmentation Fault in Postgres server when using psqlODBC Inoue, Hiroshi <inoue@tpf.co.jp>
  2013-06-04 14:46               ` Re: Segmentation Fault in Postgres server when using psqlODBC Joshua Berry <yoberi@gmail.com>
  2013-06-04 15:48                 ` Re: Segmentation Fault in Postgres server when using psqlODBC Joshua Berry <yoberi@gmail.com>
  2013-06-06 03:39                   ` Re: Segmentation Fault in Postgres server when using psqlODBC Hiroshi Inoue <inoue@tpf.co.jp>
  2013-06-11 16:04                     ` Re: [ODBC] Segmentation Fault in Postgres server when using psqlODBC Joshua Berry <yoberi@gmail.com>
  2013-06-11 16:20                       ` Re: [ODBC] Segmentation Fault in Postgres server when using psqlODBC Heikki Linnakangas <hlinnakangas@vmware.com>
  2013-06-11 16:26                         ` Re: [ODBC] Segmentation Fault in Postgres server when using psqlODBC Andres Freund <andres@2ndquadrant.com>
@ 2013-06-13 13:31                           ` Hiroshi Inoue <inoue@tpf.co.jp>
  2013-06-13 13:33                             ` Re: [ODBC] Segmentation Fault in Postgres server when using psqlODBC Tom Lane <tgl@sss.pgh.pa.us>
  2013-06-13 17:16                             ` Re: [ODBC] Segmentation Fault in Postgres server when using psqlODBC Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 2 replies; 18+ messages in thread

From: Hiroshi Inoue @ 2013-06-13 13:31 UTC (permalink / raw)
  To: Andres Freund <andres@2ndquadrant.com>; Heikki Linnakangas <hlinnakangas@vmware.com>; +Cc: Joshua Berry <yoberi@gmail.com>; pgsql-bugs@postgresql.org, Tom Lane <tgl@sss.pgh.pa.us>

(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; }
^ permalink raw reply [nested|flat] 18+ messages in thread

* Re: [ODBC] Segmentation Fault in Postgres server when using psqlODBC
  2013-05-24 16:55 Segmentation Fault in Postgres server when using psqlODBC Joshua Berry <yoberi@gmail.com>
  2013-05-24 21:25 ` Re: Segmentation Fault in Postgres server when using psqlODBC Hiroshi Inoue <inoue@tpf.co.jp>
  2013-05-28 14:20   ` Re: Segmentation Fault in Postgres server when using psqlODBC Joshua Berry <yoberi@gmail.com>
  2013-05-28 20:19     ` Re: Segmentation Fault in Postgres server when using psqlODBC Hiroshi Inoue <inoue@tpf.co.jp>
  2013-05-29 03:02       ` Re: Segmentation Fault in Postgres server when using psqlODBC Joshua Berry <yoberi@gmail.com>
  2013-05-30 13:52         ` Re: Segmentation Fault in Postgres server when using psqlODBC Hiroshi Inoue <inoue@tpf.co.jp>
  2013-06-03 14:55           ` Re: Segmentation Fault in Postgres server when using psqlODBC Joshua Berry <yoberi@gmail.com>
  2013-06-04 03:47             ` Re: Segmentation Fault in Postgres server when using psqlODBC Inoue, Hiroshi <inoue@tpf.co.jp>
  2013-06-04 14:46               ` Re: Segmentation Fault in Postgres server when using psqlODBC Joshua Berry <yoberi@gmail.com>
  2013-06-04 15:48                 ` Re: Segmentation Fault in Postgres server when using psqlODBC Joshua Berry <yoberi@gmail.com>
  2013-06-06 03:39                   ` Re: Segmentation Fault in Postgres server when using psqlODBC Hiroshi Inoue <inoue@tpf.co.jp>
  2013-06-11 16:04                     ` Re: [ODBC] Segmentation Fault in Postgres server when using psqlODBC Joshua Berry <yoberi@gmail.com>
  2013-06-11 16:20                       ` Re: [ODBC] Segmentation Fault in Postgres server when using psqlODBC Heikki Linnakangas <hlinnakangas@vmware.com>
  2013-06-11 16:26                         ` Re: [ODBC] Segmentation Fault in Postgres server when using psqlODBC Andres Freund <andres@2ndquadrant.com>
  2013-06-13 13:31                           ` Re: [ODBC] Segmentation Fault in Postgres server when using psqlODBC Hiroshi Inoue <inoue@tpf.co.jp>
@ 2013-06-13 13:33                             ` Tom Lane <tgl@sss.pgh.pa.us>
  1 sibling, 0 replies; 18+ messages in thread

From: Tom Lane @ 2013-06-13 13:33 UTC (permalink / raw)
  To: Hiroshi Inoue <inoue@tpf.co.jp>; +Cc: Andres Freund <andres@2ndquadrant.com>; Heikki Linnakangas <hlinnakangas@vmware.com>; Joshua Berry <yoberi@gmail.com>; pgsql-bugs@postgresql.org

Hiroshi Inoue <inoue@tpf.co.jp> writes:
> OK I made a test C program which reproduces the crash.
> The program uses libpq and a hack.

Oh, thank you, I was just about to go spend an hour doing that ...

			regards, tom lane


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



^ permalink  raw  reply  [nested|flat] 18+ messages in thread

* Re: [ODBC] Segmentation Fault in Postgres server when using psqlODBC
  2013-05-24 16:55 Segmentation Fault in Postgres server when using psqlODBC Joshua Berry <yoberi@gmail.com>
  2013-05-24 21:25 ` Re: Segmentation Fault in Postgres server when using psqlODBC Hiroshi Inoue <inoue@tpf.co.jp>
  2013-05-28 14:20   ` Re: Segmentation Fault in Postgres server when using psqlODBC Joshua Berry <yoberi@gmail.com>
  2013-05-28 20:19     ` Re: Segmentation Fault in Postgres server when using psqlODBC Hiroshi Inoue <inoue@tpf.co.jp>
  2013-05-29 03:02       ` Re: Segmentation Fault in Postgres server when using psqlODBC Joshua Berry <yoberi@gmail.com>
  2013-05-30 13:52         ` Re: Segmentation Fault in Postgres server when using psqlODBC Hiroshi Inoue <inoue@tpf.co.jp>
  2013-06-03 14:55           ` Re: Segmentation Fault in Postgres server when using psqlODBC Joshua Berry <yoberi@gmail.com>
  2013-06-04 03:47             ` Re: Segmentation Fault in Postgres server when using psqlODBC Inoue, Hiroshi <inoue@tpf.co.jp>
  2013-06-04 14:46               ` Re: Segmentation Fault in Postgres server when using psqlODBC Joshua Berry <yoberi@gmail.com>
  2013-06-04 15:48                 ` Re: Segmentation Fault in Postgres server when using psqlODBC Joshua Berry <yoberi@gmail.com>
  2013-06-06 03:39                   ` Re: Segmentation Fault in Postgres server when using psqlODBC Hiroshi Inoue <inoue@tpf.co.jp>
  2013-06-11 16:04                     ` Re: [ODBC] Segmentation Fault in Postgres server when using psqlODBC Joshua Berry <yoberi@gmail.com>
  2013-06-11 16:20                       ` Re: [ODBC] Segmentation Fault in Postgres server when using psqlODBC Heikki Linnakangas <hlinnakangas@vmware.com>
  2013-06-11 16:26                         ` Re: [ODBC] Segmentation Fault in Postgres server when using psqlODBC Andres Freund <andres@2ndquadrant.com>
  2013-06-13 13:31                           ` Re: [ODBC] Segmentation Fault in Postgres server when using psqlODBC Hiroshi Inoue <inoue@tpf.co.jp>
@ 2013-06-13 17:16                             ` Tom Lane <tgl@sss.pgh.pa.us>
  2013-06-13 19:30                               ` Re: [ODBC] Segmentation Fault in Postgres server when using psqlODBC Joshua Berry <yoberi@gmail.com>
  1 sibling, 1 reply; 18+ messages in thread

From: Tom Lane @ 2013-06-13 17:16 UTC (permalink / raw)
  To: Hiroshi Inoue <inoue@tpf.co.jp>; +Cc: Andres Freund <andres@2ndquadrant.com>; Heikki Linnakangas <hlinnakangas@vmware.com>; Joshua Berry <yoberi@gmail.com>; pgsql-bugs@postgresql.org

Hiroshi Inoue <inoue@tpf.co.jp> writes:
> (2013/06/12 1:26), Andres Freund wrote:
>> 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've committed a fix for this.  Thanks again for the test case.

			regards, tom lane


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



^ permalink  raw  reply  [nested|flat] 18+ messages in thread

* Re: [ODBC] Segmentation Fault in Postgres server when using psqlODBC
  2013-05-24 16:55 Segmentation Fault in Postgres server when using psqlODBC Joshua Berry <yoberi@gmail.com>
  2013-05-24 21:25 ` Re: Segmentation Fault in Postgres server when using psqlODBC Hiroshi Inoue <inoue@tpf.co.jp>
  2013-05-28 14:20   ` Re: Segmentation Fault in Postgres server when using psqlODBC Joshua Berry <yoberi@gmail.com>
  2013-05-28 20:19     ` Re: Segmentation Fault in Postgres server when using psqlODBC Hiroshi Inoue <inoue@tpf.co.jp>
  2013-05-29 03:02       ` Re: Segmentation Fault in Postgres server when using psqlODBC Joshua Berry <yoberi@gmail.com>
  2013-05-30 13:52         ` Re: Segmentation Fault in Postgres server when using psqlODBC Hiroshi Inoue <inoue@tpf.co.jp>
  2013-06-03 14:55           ` Re: Segmentation Fault in Postgres server when using psqlODBC Joshua Berry <yoberi@gmail.com>
  2013-06-04 03:47             ` Re: Segmentation Fault in Postgres server when using psqlODBC Inoue, Hiroshi <inoue@tpf.co.jp>
  2013-06-04 14:46               ` Re: Segmentation Fault in Postgres server when using psqlODBC Joshua Berry <yoberi@gmail.com>
  2013-06-04 15:48                 ` Re: Segmentation Fault in Postgres server when using psqlODBC Joshua Berry <yoberi@gmail.com>
  2013-06-06 03:39                   ` Re: Segmentation Fault in Postgres server when using psqlODBC Hiroshi Inoue <inoue@tpf.co.jp>
  2013-06-11 16:04                     ` Re: [ODBC] Segmentation Fault in Postgres server when using psqlODBC Joshua Berry <yoberi@gmail.com>
  2013-06-11 16:20                       ` Re: [ODBC] Segmentation Fault in Postgres server when using psqlODBC Heikki Linnakangas <hlinnakangas@vmware.com>
  2013-06-11 16:26                         ` Re: [ODBC] Segmentation Fault in Postgres server when using psqlODBC Andres Freund <andres@2ndquadrant.com>
  2013-06-13 13:31                           ` Re: [ODBC] Segmentation Fault in Postgres server when using psqlODBC Hiroshi Inoue <inoue@tpf.co.jp>
  2013-06-13 17:16                             ` Re: [ODBC] Segmentation Fault in Postgres server when using psqlODBC Tom Lane <tgl@sss.pgh.pa.us>
@ 2013-06-13 19:30                               ` Joshua Berry <yoberi@gmail.com>
  0 siblings, 0 replies; 18+ messages in thread

From: Joshua Berry @ 2013-06-13 19:30 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Hiroshi Inoue <inoue@tpf.co.jp>; Andres Freund <andres@2ndquadrant.com>; Heikki Linnakangas <hlinnakangas@vmware.com>; pgsql-bugs@postgresql.org

Hiroshi, Tom, and Andres,

On Thu, Jun 13, 2013 at 12:16 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:

> Hiroshi Inoue <inoue@tpf.co.jp> writes:
> > OK I made a test C program which reproduces the crash.
> > The program uses libpq and a hack.
>
> I've committed a fix for this.  Thanks again for the test case.
>

Many thanks for your time and effort in debugging, testing, and patching
this.

Kind Regards,
-Joshua

^ permalink  raw  reply  [nested|flat] 18+ messages in thread


end of thread, other threads:[~2013-06-13 19:30 UTC | newest]

Thread overview: 18+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2013-05-24 16:55 Segmentation Fault in Postgres server when using psqlODBC Joshua Berry <yoberi@gmail.com>
2013-05-24 21:25 ` Hiroshi Inoue <inoue@tpf.co.jp>
2013-05-28 14:20   ` Joshua Berry <yoberi@gmail.com>
2013-05-28 20:19     ` Hiroshi Inoue <inoue@tpf.co.jp>
2013-05-29 03:02       ` Joshua Berry <yoberi@gmail.com>
2013-05-30 13:52         ` Hiroshi Inoue <inoue@tpf.co.jp>
2013-06-03 14:55           ` Joshua Berry <yoberi@gmail.com>
2013-06-04 03:47             ` Inoue, Hiroshi <inoue@tpf.co.jp>
2013-06-04 14:46               ` Joshua Berry <yoberi@gmail.com>
2013-06-04 15:48                 ` Joshua Berry <yoberi@gmail.com>
2013-06-06 03:39                   ` Hiroshi Inoue <inoue@tpf.co.jp>
2013-06-11 16:04                     ` Joshua Berry <yoberi@gmail.com>
2013-06-11 16:20                       ` Heikki Linnakangas <hlinnakangas@vmware.com>
2013-06-11 16:26                         ` Andres Freund <andres@2ndquadrant.com>
2013-06-13 13:31                           ` Hiroshi Inoue <inoue@tpf.co.jp>
2013-06-13 13:33                             ` Tom Lane <tgl@sss.pgh.pa.us>
2013-06-13 17:16                             ` Tom Lane <tgl@sss.pgh.pa.us>
2013-06-13 19:30                               ` Joshua Berry <yoberi@gmail.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