[freetds] Segmentation fault on dbinit()
entropy at freetds.org
entropy at freetds.org
Thu Oct 25 10:49:47 EDT 2007
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.
--
Cheers,
entropy
More information about the FreeTDS
mailing list