Skip to Content.
Sympa Menu

freetds - ctlib segfault with multiple login/logout

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: martin dempsey <mjd AT digitaleveryware.com>
  • To: freetds AT franklin.oit.unc.edu
  • Cc: katkinson AT acresgaming.com
  • Subject: ctlib segfault with multiple login/logout
  • Date: Thu, 07 Mar 2002 23:52:33 -0800



I'm having a problem with a program using ctlib that crashes when it
trys to connect to a second database. By adding just three lines to
the "src/ctlib/unittests/t0001.c" test program, I can cause it to
crash in the same fashion.

The "t0001.c" program does a login and logout, nothing more. If you
wrap that in a while loop so it does a couple login/logouts it
segfaults. Shouldn't you be able to login/logout to a database and
some time later be able to login again? Is this a bug or am I
confused?

The problem happens with version 0.53 and 0.51. I am using an x86
linux machine connecting to W2K/SqlServer version 7.0. The same thing
happens with NT/SqlSever 7.0

-------------- stack trace of crash ---------------------------------

(gdb) run
Starting program:
/home/mjd/src/acres/ticker/freetds-0.53/src/ctlib/unittests/.libs/t0001
t0001.c: Testing login, logout
Trying login
Trying logout
Trying login

Program received signal SIGSEGV, Segmentation fault.
0x69746e75 in ?? ()
(gdb) bt
#0 0x69746e75 in ?? ()
#1 0x4001ab21 in ctlib_handle_info_message (aStruct=0x804b280) at ctutil.c:38
#2 0x4001d97e in tds_process_msg (tds=0x804b280, marker=171) at token.c:1214
#3 0x4001bdaf in tds_process_default_tokens (tds=0x804b280, marker=171) at
token.c:101
#4 0x4001bf8d in tds_process_login_tokens (tds=0x804b280) at token.c:209
#5 0x4001effc in tds_connect (login=0x804c9a8, parent=0x804b258) at
login.c:240
#6 0x40018a61 in ct_connect (con=0x804b258, servername=0x804ace0 "acct",
snamelen=2) at ct.c:303
#7 0x8048dd4 in try_ctlogin (ctx=0xbffffb90, conn=0xbffffb94,
cmd=0xbffffb98, verbose=1) at common.c:82
#8 0x8048a5a in main () at t0001.c:24
(gdb)


------------ modified "src/ctlib/unittests/t0001.c" program ------

#include <stdio.h>
#include <ctpublic.h>
/* only include this if you need access to PWD information */
/* #include "common.h" */

static char software_version[] = "$Id: t0001.c,v 1.1.1.1 2001/10/12
23:29:06 brianb Exp $";
static void *no_unused_var_warn[] = {software_version,
no_unused_var_warn};

int main()
{
CS_CONTEXT *ctx;
CS_CONNECTION *conn;
CS_COMMAND *cmd;
CS_RETCODE ret;
int verbose = 0;
int i = 0; /////////////// ADDED LINE ///////////////////////

fprintf(stdout, "%s: Testing login, logout\n", __FILE__);

while (i++ < 100) { /////////// ADDED LINE //////////////////////

if (verbose) { fprintf(stdout, "Trying login\n"); }
ret = try_ctlogin(&ctx, &conn, &cmd, verbose);
if (ret != CS_SUCCEED) {
fprintf(stderr, "Login failed\n");
return 1;
}

if (verbose) { fprintf(stdout, "Trying logout\n"); }
ret = try_ctlogout(ctx, conn, cmd, verbose);
if (ret != CS_SUCCEED) {
fprintf(stderr, "Logout failed\n");
return 2;
}


} ///////////////////////////// ADDED LINE ///////////////////////

if (verbose) { fprintf(stdout, "Test suceeded\n"); }
return 0;
}

------------------------------------------------------------------




Archive powered by MHonArc 2.6.24.

Top of Page