[freetds] Segmentation fault on dbinit()

Paul Andrews andrewsp at andronics.com
Thu Oct 25 08:42:01 EDT 2007


Hi All.

Getting a segmentation fault on dbinit().

Platform: Suse 10.2 / 10.3 using rpm's from OpenSuse.org

Tsql works fine.

Using GDB, it looks like fopen on the locales.conf file in
tds_get_locale is failing.

int db_connect(int nDbType, char acServer[], char acUsername[], char
acPassword[], char acAppName[], char acDatabase[], char acFreeTdsDbName[])
{
    printf("\nServer: %s\n",acServer);
    printf("\nUsername: %s\n",acUsername);
    printf("\nPassword: %s\n", acPassword);
    printf("\nAppName: %s\n", acAppName);
    printf("\nDatabase: %s\n", acDatabase);
    printf("\nDbName: %s\n", acFreeTdsDbName);

   

    //dberrhandle((EHANDLEFUNC)dberr_handler);
        //dbmsghandle((MHANDLEFUNC)dbmsg_handler);
   
    if ( dbinit() == FAIL ) ==> Segmentation Fault here
        printf("\nFail\n");
    else
        printf("\nSuccess\n");

    printf("\nbefore\n");

    if ( dblogin() == FAIL)
    {
        printf("\ndblogin() FAIL\n");
    }
    else
    {
        login = dblogin();
        printf("\nLogin ok\n");
    }

    DBSETLUSER(login, acUsername);
    DBSETLPWD(login, acPassword);
    DBSETLHOST(login, acServer);
    DBSETLAPP(login, acAppName);

    printf("\nafter\n");
   
    /*if ( dbopen(login, acFreeTdsDbName) == NULL )
    {
        return -1;
    }*/

    if ( dbopen(login, acFreeTdsDbName) == NULL )
    {
        printf("\nDBOpen() Error\n");
    }
    else
    {
        dbconn = dbopen(login, acFreeTdsDbName);
        //return 0;
    }

    printf("\nafter 1\n");
   
   
    if(dbuse(dbconn, acDatabase) == FAIL)
        return -1;

    printf("\nafter 2\n");
   
    return 0;
   
}


Any and all help appreciated.

Paul.


More information about the FreeTDS mailing list