[freetds] Segmentation fault on dbinit()
Paul Andrews
andrewsp at andronics.com
Thu Oct 25 10:55:31 EDT 2007
Thanks Entropy.
I left out a rather crucial piece of information: the code AS IS
compiles, debugs, and runs fine on another Suse 10.2 machine.
I know it must be something to do with the FreeTDS configuration or
environment variables or something...!?!?
I just don't know how to fix it.
The line that is failing is
in = fopen(FREETDS_LOCALESCONFFILE, "+r");
in the tds_get_locale() function.
The environment variable FREETDS_LOCALESCONFFILE must be NULL (I imagine).
locales.conf is in /etc as is freetds.conf (which is evidently found
because tsql works).
Any ideas?
Paul.
entropy at freetds.org wrote:
> Paul Andrews wrote:
>
>> 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[])
>> {
>> [...]
>>
>> //dberrhandle((EHANDLEFUNC)dberr_handler);
>> //dbmsghandle((MHANDLEFUNC)dbmsg_handler);
>>
>> if ( dbinit() == FAIL ) ==> Segmentation Fault here
>>
>
> Is your db_connect() function called more than once per run?
>
> dbinit() must be called exactly once per application, and must be called
> before any other DB-Lib function.
>
> Move it to the beginning of main() or some other suitable initialization
> point for your application, and move the dberrhandle() and dbmsghandle()
> calls after it (if you plan to uncomment them at some point).
>
> If you must call it from this function, then use a static variable to
> ensure it is done only once, and make sure no other DB-Lib calls can
> happen beforehand elsewhere in the app.
>
>
More information about the FreeTDS
mailing list