Обсуждение: 7.1 beta 4 ODBC Connection Problem

Поиск
Список
Период
Сортировка

7.1 beta 4 ODBC Connection Problem

От
Steve Wranovsky
Дата:
Hello,

I have been successfully using 7.0.3 with our application under Redhat 6.0.  
We are using the ODBC interface under Linux to access a database.

I decided to test the 7.1 beta 4 with our application, and installed the 
RPMs from the PostgreSQL.org ftp site.  I was able to install everything, create
our database and check it with psql, however, when I try and access the database
via ODBC, I run into problems.  

I get a seg fault when I try and connect to the database via SQLConnect.  Below 
is a stack trace from the core file.  The crash occurs in sprintf.  

FYI, I also decided to try the 7.1 beta 3 release.  I was able to Connect 
properly with this release, so the problem appears to be specific to 7.1 beta 4.

Anyone have any ideas?


Thanks,
Steve

[mergeark@steveark mergeark]$ gdb adopt_std core
GNU gdb 4.17.0.11 with Linux support
Copyright 1998 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i386-redhat-linux"...
Core was generated by `adopt_std /dev/scd0 1'.
Program terminated with signal 11, Segmentation fault.
Reading symbols from /home/mergeark/exe/lib/libmergebox.so...done.
Reading symbols from /usr/lib/libpsqlodbc.so.0...done.
Reading symbols from /home/mergeark/exe/lib/mc3adv.so...done.
Reading symbols from /lib/libm.so.6...done.
Reading symbols from /lib/libdl.so.2...done.
Reading symbols from /lib/libc.so.6...done.
Reading symbols from /lib/ld-linux.so.2...done.
Reading symbols from /lib/libnss_files.so.2...done.
#0  0x40171e23 in _IO_vfprintf (s=0xbfffd7e0, format=0x40064409 "%c.%c", ap=0xbfffd8ac) at vfprintf.c:1248
vfprintf.c:1248: No such file or directory.
(gdb) bt
#0  0x40171e23 in _IO_vfprintf (s=0xbfffd7e0, format=0x40064409 "%c.%c", ap=0xbfffd8ac) at vfprintf.c:1248
#1  0x4017e0b3 in _IO_vsprintf (string=0x400643df "0.0", format=0x40064409 "%c.%c", args=0xbfffd8a8) at
iovsprintf.c:47
#2  0x4017876f in sprintf (s=0x400643df "0.0", format=0x40064409 "%c.%c") at sprintf.c:38
#3  0x4004f268 in CC_lookup_pg_version ()
#4  0x4004def9 in CC_connect ()
#5  0x4004d0b4 in SQLConnect ()
#6  0x8057efa in DatabaseConnect ()
#7  0x8057c1e in ADB_DatabaseInit ()
#8  0x804a802 in Initialize_Process () at adopt_std.c:238
#9  0x804bf7b in main (ac=3, av=0xbffff754) at adopt_std.c:934
#10 0x40143cb3 in __libc_start_main (main=0x804be8c <main>, argc=3, argv=0xbffff754, init=0x8049b6c <_init>,
fini=0x8068614<_fini>, rtld_fini=0x4000a350 <_dl_fini>, stack_end=0xbffff74c) at ../sysdeps/generic/libc-start.c:78
 
(gdb) 



Re: 7.1 beta 4 ODBC Connection Problem

От
Tom Lane
Дата:
Steve Wranovsky <stevew@merge.com> writes:
> I get a seg fault when I try and connect to the database via
> SQLConnect.  Below is a stack trace from the core file.  The crash
> occurs in sprintf.

This is probably the same problem that Nick Gorham pointed out this
morning...
        regards, tom lane

------- Forwarded Message

Date:    Wed, 07 Feb 2001 13:04:34 +0000
From:    Nick Gorham <nick@easysoft.com>
To:      pgsql-hackers@postgresql.org
Subject: [HACKERS] unixODBC (again)

Hi,

Having seen that the driver I distribute doesn't work against 7.1 Beta
4, and not wanting to continue the split between the two versions,
I have tried to get the driver in the beta working with unixODBC, but
I have come against a couple of problems, one a show stopper.

First let me say that I want to stop the split between the version, If
I can just point people to your distribution, thats fine by me, but it
needs to work :-). I am not trying to get you to standardise on
unixODBC, just to provide the option.

Initially I had to link my system odbc.ini to a user odbc, because the
driver looks in the home account. This would be SO much better if there
was a build option to link with libodbcini.so, not saying it should be
the default, just that the option would be great.

After this, it still didn't find the entries, I fould the problem was
the code couldn't handle spaces in the ini file, so

[dsn]
Servername=fred

works, but

[dsn]
Servername         = fred

doesn't. Not a major point, but again the ini lib would fix this.

Then having sorted this out, I get a core dump, that I have traced to
CC_lookup_pg_version, the code did
   CC_lookup_pg_version(ConnectionClass *self)   {   HSTMT hstmt;   StatementClass *stmt;   RETCODE result;   char
*szVersion= "0.0";   static char *func = "CC_lookup_pg_version";
 

Then later did a
   sprintf( szVersion... );

This seems to be trying to write into, what the compiler is marking as
read only storage. A quick change to
   CC_lookup_pg_version(ConnectionClass *self)   {   HSTMT hstmt;   StatementClass *stmt;   RETCODE result;   char
szVersion[3 ];                    ---- should be 4 --- tgl   static char *func = "CC_lookup_pg_version";
 
       strcpy( szVersion, "0.0" );

Fixes the problem, and it connects. I will continue testing, with some
apps and see how it gets on

--
Nick Gorham
Easysoft Ltd

------- End of Forwarded Message