FreeTDS cored when connect to SQL Server

"Liu, Wilson" <[email protected]>
Newsgroups gmane.comp.db.tds.freetds
Message-ID <[email protected]>
Hi, all,

I have find cores when I connect to SQL Server through  FreeTDS library, and find no clue when searching the mail list archive.
Maybe someone can help me here.
Thanks.

Blow is version info:
FreeTDS: freetds-0.82-1,freetds-unixODBC-0.82-1
SQL Server: 2008R2.
OS is CentOS 5.1.

The stack info is:
#0  0xb7ef4410 in __kernel_vsyscall ()
#1  0xb7db6040 in raise () from /lib/i686/nosegneg/libc.so.6
#2  0xb7db7a21 in abort () from /lib/i686/nosegneg/libc.so.6
#3  0xb7daf40b in __assert_fail () from /lib/i686/nosegneg/libc.so.6
#4  0xb7d6a4cc in ?? () from /usr/lib/libsybdb.so.5
#5  0xb7d6a8dc in ?? () from /usr/lib/libsybdb.so.5
#6  0xb7d6aa1d in ?? () from /usr/lib/libsybdb.so.5
#7  0xb7d53fd2 in ?? () from /usr/lib/libsybdb.so.5
#8  0xb7d4fee9 in ?? () from /usr/lib/libsybdb.so.5
#9  0xb7d38337 in dbsqlsend () from /usr/lib/libsybdb.so.5
#10 0xb7d39d02 in dbsqlexec () from /usr/lib/libsybdb.so.5
......


Blow is some of my code:
static int msg_handler(DBPROCESS *dbproc, DBINT msgno, int msgstate, int severity,char *msgtext, char *srvname, char *procname, int line)
{
        enum {changed_database = 5701, changed_language = 5703 };

        if (msgno == changed_database || msgno == changed_language)
                return 0;

        if (msgno > 0) {
                SD_DEBUG_STATD( "Msg %ld, Level %d, State %d\n", (long) msgno, severity, msgstate);

                if (strlen(srvname) > 0)
                        SD_DEBUG_STATD("Server '%s', ", srvname);
                if (strlen(procname) > 0)
                        SD_DEBUG_STATD("Procedure '%s', ", procname);
                if (line > 0)
                        SD_DEBUG_STATD("Line %d", line);

                SD_DEBUG_STATD("\n\t");
        }
        SD_DEBUG_STATD("%s\n", msgtext);

        if (severity > 10) {
                SD_DEBUG_STATD("%s: error: severity %d >10, exiting\n",options.appname, severity);
                exit(severity);
        }

        return 0;
}

static int err_handler(DBPROCESS * dbproc, int severity, int dberr, int oserr,char *dberrstr, char *oserrstr)
{
        if (dberr) {
                SD_DEBUG_STATD("%s: Msg %d, Level %d\n",
                                options.appname, dberr, severity);
                SD_DEBUG_STATD("%s\n\n", dberrstr);
        }

        else {
                SD_DEBUG_STATD("%s: DB-LIBRARY error:\n\t", options.appname);
                SD_DEBUG_STATD("%s\n", dberrstr);
        }

        return INT_CANCEL;
}

#define SQLSERVER_SERVER                "MSSQLServer"
#define FREETDS_MAX_SELECT_SIZE 128000
int init_sql_handle(char *user,char *pwd)
{
        char param_server[256];
        DBINT result;
        char sql_cmd[1024]={0};

         if ( !user || !pwd || !user[0] || !pwd[0]){
                return ERR_CD_INVALID_ARGUMENTS;
                }
         if (dbproc){
                 dbclose (dbproc);
                 dbproc = NULL;
         }
         if (cddblogin){
                 dbloginfree(cddblogin);
                 cddblogin = NULL;
         }else{
                 options.appname="StatDaemon";
                 options.dbname=LOGDB;
                 options.username=strdup(user);
                 options.password=strdup(pwd);
                 if (dbinit() == FAIL) {
                         SD_DEBUG_STATD("DBinit() failed\n");
                         return FAILED;
                 }

                 dberrhandle(err_handler);
                 dbmsghandle(msg_handler);
         }
         cddblogin = dblogin();
         if (cddblogin == NULL){
                 SD_DEBUG_STATD("Failed to init dblogin\n");
                 return FAILED;
         }
         DBSETLUSER(cddblogin,user);
         DBSETLPWD(cddblogin, pwd);
         DBSETLAPP(cddblogin, ESGLOGDB);
         dbproc = dbopen(cddblogin, SQLSERVER_SERVER);
         if (dbproc == NULL) {
                 SD_DEBUG_STATD("Failed to dbopen handle with user=%s,pwd=%s\n", user,pwd);
                 return ERR_CD_DB_OFFBOX;
         }
         if ((result = dbuse(dbproc, ESGLOGDB)) == FAIL) {
                 SD_DEBUG_STATD("Unable to use to database %s\n",ESGLOGDB);
                 return ERR_CD_DB_OFFBOX;
         }
         sprintf(sql_cmd,"set textsize %d",FREETDS_MAX_SELECT_SIZE);
         dbcmd(dbproc, sql_cmd);
         if (FAIL == dbsqlexec (dbproc))
         {
                 SD_DEBUG_STATD("Unable to set text size %s\n",sql_cmd);
                 return ERR_CD_DB_OFFBOX;
         }
         return SUCCESS;
}




 Protected by Websense Hosted Email Security -- www.websense.com
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.