Skip to Content.
Sympa Menu

freetds - [freetds] problem with dbopen Segmentation fault: 11 (core dumped)

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: Anton Kiryushkin <swood AT fotofor.biz>
  • To: FreeTDS AT lists.ibiblio.org
  • Subject: [freetds] problem with dbopen Segmentation fault: 11 (core dumped)
  • Date: Wed, 4 Apr 2012 07:40:51 +0400

Hello, all.

I try to use freeTDS for check my MS SQL server. I use the sample code:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <errno.h>
#include <unistd.h>
#include <libgen.h>


#include <sybfront.h>
#include <sybdb.h>

int err_handler(DBPROCESS*, int, int, int, char*, char*);
int msg_handler(DBPROCESS*, DBINT, int, int, char*, char*, char*, int);

int main() {
DBPROCESS *dbproc;
LOGINREC *login;
DBCHAR name[100];

dbinit ();

login = dblogin();
DBSETLUSER(login, "login");
DBSETLPWD(login, "passwd");
DBSETLAPP(login, "Freetds");
dbproc = dbopen(login, "SERVERNAME");
dbcmd(dbproc, "SELECT @@SERVERNAME");
dbsqlexec(dbproc);
if (dbresults(dbproc) == SUCCEED)
{
dbbind(dbproc, 1, NTBSTRINGBIND, 0, name);
while (dbnextrow(dbproc) != NO_MORE_ROWS) {
printf("%s\n", name);
}
}
dbexit();
return 0;
}

And after compile:
cc -I /usr/local/include -Wl,-L/usr/local/lib -Wl,-R/usr/local/lib sample.c
-lsybdb -o sample
then I try to run this file I get:
Segmentation fault: 11 (core dumped)
In gdb I see next backtrace:

# gdb ./sample
GNU gdb 6.1.1 [FreeBSD]
Copyright 2004 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-marcel-freebsd"...(no debugging symbols
found)...
(gdb) run
Starting program: /home/user/sample
[New LWP 100170]
[New Thread 0x28201040 (LWP 100170)]

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x28201040 (LWP 100170)]
tds_dstr_copyn (s=0x6374652f, src=0x280c69db "SYBASE", length=6) at
tdsstring.c:88
88 if (s->dstr_s != tds_str_empty)
(gdb) bt
#0 tds_dstr_copyn (s=0x6374652f, src=0x280c69db "SYBASE", length=6) at
tdsstring.c:88
#1 0x280b67b5 in tds_dstr_copy (s=0x6374652f, src=0x280c69db "SYBASE") at
tdsstring.c:139
#2 0x2808e4e2 in tdsdbopen (login=0x281baed3, server=0x280c69db "SYBASE",
msdblib=0) at dblib.c:1176
#3 0x280970fc in dbopen (login=0x281baed3, server=0x0) at dbopen.c:48
#4 0x281589c7 in getpwent_r () from /lib/libc.so.7
#5 0x2815a2cb in getpwent_r () from /lib/libc.so.7
#6 0x2818ccd4 in nsdispatch () from /lib/libc.so.7
#7 0x28157f04 in getpwuid_r () from /lib/libc.so.7
#8 0x280b5dc9 in tds_get_homedir () at threadsafe.c:534
#9 0x280aa791 in tds_get_home_file (file=0xbfbfe930 "") at config.c:321
#10 0x280aab2a in tds_read_conf_file (connection=0x2822d0c0,
server=0x2820a0b0 "SERVERNAME") at config.c:372
#11 0x280ab768 in tds_read_config_info (tds=0x282200c0, login=0x2820d080,
locale=0x2820a030) at config.c:190
#12 0x2808e555 in tdsdbopen (login=0x2820b088, server=0x80489bb
"SERVERNAME", msdblib=0) at dblib.c:1192
#13 0x080487cd in main ()
(gdb) quit

OS of server FreeBSD 7.2 i386. freeTDS version 0.91.
# tsql -C
Compile-time settings (established with the "configure" script)
Version: freetds v0.91
freetds.conf directory: /usr/local/etc
MS db-lib source compatibility: no
Sybase binary compatibility: yes
Thread safety: yes
iconv library: no
TDS version: 7.1
iODBC: no
unixodbc: no
SSPI "trusted" logins: no
Kerberos: no

Can you help me with this problem?

--
Best regards,
Anton Kiryushkin,




--
Best regards,
Anton Kiryushkin,



  • [freetds] problem with dbopen Segmentation fault: 11 (core dumped), Anton Kiryushkin, 04/03/2012

Archive powered by MHonArc 2.6.24.

Top of Page