Embedded SQL library bug

Lists: pgsql-bugs
From: David Flater <dflater(at)nist(dot)gov>
To: pgsql-bugs(at)postgresql(dot)org
Subject: Embedded SQL library bug
Date: 2004-05-21 21:03:40
Message-ID: 20040521210340.GA24507@cme.nist.gov
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs

============================================================================
POSTGRESQL BUG REPORT TEMPLATE
============================================================================

Your name : David Flater
Your email address : dflater(at)nist(dot)gov

System Configuration
---------------------
Architecture (example: Intel Pentium) : Sun Ultrasparc 60

Operating System (example: Linux 2.4.18) : SunOS 5.8

PostgreSQL version (example: PostgreSQL-7.4.2): PostgreSQL-7.4.2

Compiler used (example: gcc 2.95.2) : gcc 3.2

Please enter a FULL description of your problem:
------------------------------------------------

In Embedded SQL, sometimes get segmentation faults on selecting part
or all of a float8[] array into a char array.

(gdb) where
#0 0xff233da0 in strncpy () from /usr/lib/libc.so.1
#1 0xff376780 in ECPGget_data () from /private/pgsql/lib/libecpg.so.4
#2 0xff37345c in ECPGstore_result () from /private/pgsql/lib/libecpg.so.4
#3 0xff374cc8 in ECPGexecute () from /private/pgsql/lib/libecpg.so.4
#4 0xff3751dc in ECPGdo () from /private/pgsql/lib/libecpg.so.4
#5 0x00010a58 in main (argc=1, argv=0xffbef384) at crashme.pgc:45

The attached example reproduces the failure on PostgreSQL 7.4.2 under
Solaris. The problem was also experienced by a colleague who was
using Linux but I haven't tested the example under Linux.

Please describe a way to repeat the problem. Please try to provide a
concise reproducible example, if at all possible:
----------------------------------------------------------------------

I have attached a tar file containing a program, makefile, and log of
my results.

Do this:

createdb crashme
make
./crashme

If you know how this problem might be fixed, list the solution below:
---------------------------------------------------------------------

N/A

--
David Flater, National Institute of Standards and Technology, U.S.A.

Attachment Content-Type Size
bug.tar.gz application/x-tar-gz 1.7 KB

From: Michael Meskes <meskes(at)postgresql(dot)org>
To: David Flater <dflater(at)nist(dot)gov>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: Embedded SQL library bug
Date: 2004-05-22 11:26:43
Message-ID: 20040522112643.GA5714@1
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs

On Fri, May 21, 2004 at 05:03:40PM -0400, David Flater wrote:
> In Embedded SQL, sometimes get segmentation faults on selecting part
> or all of a float8[] array into a char array.

Thanks for the report. The problem is that ecpg does not know that it
gets an array of floats but expects a character string since the
variable is char[]. Seeing that it gets more than one value it tries to
bulk load the data into an array of strings which obviously doesn't
exist.

I will have to see what solution is best for this.

Michael

--
Michael Meskes
Email: Michael at Fam-Meskes dot De
ICQ: 179140304, AIM/Yahoo: michaelmeskes, Jabber: meskes(at)jabber(dot)org
Go SF 49ers! Go Rhein Fire! Use Debian GNU/Linux! Use PostgreSQL!


From: Michael Meskes <meskes(at)postgresql(dot)org>
To: David Flater <dflater(at)nist(dot)gov>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: Embedded SQL library bug
Date: 2004-06-28 12:08:32
Message-ID: 20040628120832.GA8025@1
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs

On Fri, May 21, 2004 at 05:03:40PM -0400, David Flater wrote:
> In Embedded SQL, sometimes get segmentation faults on selecting part
> or all of a float8[] array into a char array.

I just committed a patch to cvs HEAD that should fix your problem.
Please try it and tell me if it works correctly.

Michael
--
Michael Meskes
Email: Michael at Fam-Meskes dot De
ICQ: 179140304, AIM/Yahoo: michaelmeskes, Jabber: meskes(at)jabber(dot)org
Go SF 49ers! Go Rhein Fire! Use Debian GNU/Linux! Use PostgreSQL!