Skip to Content.
Sympa Menu

freetds - Re: [freetds] Segmentation fault on dbinit()

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: entropy AT freetds.org
  • To: FreeTDS Development Group <freetds AT lists.ibiblio.org>
  • Subject: Re: [freetds] Segmentation fault on dbinit()
  • Date: Thu, 25 Oct 2007 10:49:47 -0400

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




Archive powered by MHonArc 2.6.24.

Top of Page