GNOME Bugzilla – Bug 117202
SEGFAULT with freeTDS 0.61 Provider
Last modified: 2004-12-22 21:47:04 UTC
Software: libgda CVS tree freetds 0.61 RedHat 9.0 M$SQL 7.0 Server Problem: Using a simple test program, libgda SEGFAULTs while trying to connect to a freeTDS data source. Backtrace:
+ Trace 38616
Solution: The following patch fixes the following problems: * The socket struct is properly allocated before being passed to tds_connect() * The config struct is filled in with valid data before being passed to tds_connect() * The port number specified in the data source is now being used * Added a missing semi-colon in the header file ;) Index: providers/freetds/gda-freetds-provider.c =================================================================== RCS file: /cvs/gnome/libgda/providers/freetds/gda-freetds-provider.c,v retrieving revision 1.27 diff -u -r1.27 gda-freetds-provider.c --- providers/freetds/gda-freetds-provider.c 9 Mar 2003 18:55:34 -0000 1.27 +++ providers/freetds/gda-freetds-provider.c 11 Jul 2003 12:37:40 -0000 @@ -243,6 +243,9 @@ tds_set_library(tds_cnc->login, "TDS-Library"); if (t_host) tds_set_server(tds_cnc->login, (char *) t_host); + + if (t_port) + tds_set_port(tds_cnc->login, atoi(t_port)); tds_set_charset(tds_cnc->login, "iso_1"); tds_set_language(tds_cnc->login, "us_english"); @@ -267,7 +270,21 @@ #if defined(HAVE_FREETDS_VER0_60) tds_cnc->tds = tds_connect(tds_cnc->login, tds_cnc->ctx, NULL); #elif defined(HAVE_FREETDS_VER0_6X) - tds_connect (tds_cnc->tds, tds_cnc->config); + tds_cnc->tds = tds_alloc_socket(tds_cnc->ctx, 512); + if (! tds_cnc->tds) { + gda_log_error (_("Allocating tds socket failed.")); + gda_freetds_free_connection_data (tds_cnc); + gda_connection_add_error_string (cnc, _("Allocating tds socket failed.")); + return FALSE; + } + tds_set_parent (tds_cnc->tds, NULL); + tds_cnc->config = tds_read_config_info (NULL, tds_cnc->login, tds_cnc->ctx->locale); + if (tds_connect (tds_cnc->tds, tds_cnc->config) != TDS_SUCCEED) { + gda_log_error (_("Establishing connection failed.")); + //gda_freetds_free_connection_data (tds_cnc); + gda_connection_add_error_string (cnc, _("Establishing connection failed.")); + return FALSE; + } #else tds_cnc->tds = tds_connect(tds_cnc->login, NULL); #endif Index: providers/freetds/gda-freetds-provider.h =================================================================== RCS file: /cvs/gnome/libgda/providers/freetds/gda-freetds-provider.h,v retrieving revision 1.13 diff -u -r1.13 gda-freetds-provider.h --- providers/freetds/gda-freetds-provider.h 9 Mar 2003 18:55:34 -0000 1.13 +++ providers/freetds/gda-freetds-provider.h 11 Jul 2003 12:37:40 -0000 @@ -66,7 +66,7 @@ #ifdef HAVE_FREETDS_VER0_6X TDSCONNECTINFO *config; /* tds connect struct */ #else - TDSCONFIGINFO *config /* tds config struct */ + TDSCONFIGINFO *config; /* tds config struct */ #endif /* Data just got at connection beginning */ Other: I still cannot use the freeTDS data source using mergeant. It connects but then fails with the following errors: (mergeant:4022): mergeant-WARNING **: The provider has returned the wrong number and/or types of data for the TYPES schema description. Please contact the provider's maintainer and report the problem. (mergeant:4022): mergeant-WARNING **: The provider has returned the wrong number and/or types of data for the PROCEDURES schema description. Please contact the provider's maintainer and report the problem. (mergeant:4022): mergeant-WARNING **: The provider has returned the wrong number and/or types of data for the TABLES schema description. Please contact the provider's maintainer and report the problem. (mergeant:4022): mergeant-WARNING **: The provider has returned the wrong number and/or types of data for the VIEWS schema description. Please contact the provider's maintainer and report the problem. I haven't had time to look at the above mergeant problem yet ;) -Seth
Created attachment 18214 [details] [review] freeTDS patch file
Created attachment 19968 [details] [review] freeTDS patch file, uncompressed
Patch applied to CVS Wed, 17 Sep 2003.