After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 117202 - SEGFAULT with freeTDS 0.61 Provider
SEGFAULT with freeTDS 0.61 Provider
Status: RESOLVED FIXED
Product: libgda
Classification: Other
Component: FreeTDS provider
0.90.x
Other Linux
: Normal major
: ---
Assigned To: holger.thon
gnome-db Maintainers
Depends on:
Blocks:
 
 
Reported: 2003-07-11 13:27 UTC by Seth Remington
Modified: 2004-12-22 21:47 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
freeTDS patch file (767 bytes, patch)
2003-07-11 13:29 UTC, Seth Remington
none Details | Review
freeTDS patch file, uncompressed (2.26 KB, patch)
2003-09-16 00:43 UTC, Andrej Czapszys
none Details | Review

Description Seth Remington 2003-07-11 13:27:37 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:
  • #0 tds_connect
    at login.c line 221
  • #1 gda_freetds_provider_open_connection
    at gda-freetds-provider.c line 270
  • #2 gda_server_provider_open_connection
    at gda-server-provider.c line 174
  • #3 gda_connection_new
    at gda-connection.c line 265
  • #4 gda_client_open_connection
    at gda-client.c line 391
  • #5 test_query
    at main.c line 51
  • #6 main
    at main.c line 87
  • #7 __libc_start_main
    from /lib/tls/libc.so.6


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
Comment 1 Seth Remington 2003-07-11 13:29:12 UTC
Created attachment 18214 [details] [review]
freeTDS patch file
Comment 2 Andrej Czapszys 2003-09-16 00:43:39 UTC
Created attachment 19968 [details] [review]
freeTDS patch file, uncompressed
Comment 3 Seth Remington 2003-09-17 12:59:12 UTC
Patch applied to CVS Wed, 17 Sep 2003.