[unixODBC-support] unixODBC and tclodbc problem

Laura Lefebvre Laura.Lefebvre at MessagingDirect.com
Wed Nov 10 17:30:23 GMT 2004


I am using unixODBC 2.2.10, tclodbc 2.2, tclsh 8.4.4 connecting to a
Sybase 9.0.1 (1753) database.
        
I am running on Linux ES3, however I have reproduced the problem I'm
about to describe on Linux RH 7,3. Solaris 7 and Solaris 9.

The DSN I am connecting to looks like this:

[ODBC Data Sources]
subscriber=Adaptive Server Anywhere 9.0

[subscriber]
Userid=subscriberrw
Password=passrw
DatabaseName=subscriberdb
ServerName=md-subscriber-laura
CommLinks=tcpip{DoBroadcast=Direct;Host=localhost;Port=2639}
Driver=/home/laura/test.lauravm1/sybase/lib/libdbodbc9_r.so
Debug=YES
LogFile=/home/laura/test.lauravm1/var/log/subscriber_odbc.log

In tclsh, I execute 'package require tclodbc' to load the tclodbc library.

Using the tclodbc 'database' command I can connect to the database driver 
just fine and execute SQL statements. 

While the connection is open I can do a TCL exec command.

However, after I close the database connection (db disconnect) the TCL
exec command SegFaults in fork()

laura at lauravm1 (/home/laura/projects/test): /pkg/tcl/8.4.4-debug/bin/tclsh8.4 
% exec ls
problem.txt
test.tcl
% package require tclodbc
2.2
% database db subscriber
db
% exec ls
problem.txt
test.tcl
% db "select * from auth_user"
{1 Laura Lefebvre {} 1}
% exec ls
problem.txt
test.tcl
% db disconnect 
OK
% exec ls
Segmentation fault
laura at lauravm1 (/home/laura/projects/test):

The resulting stack trace:

run
Starting program: /pkg/tcl/8.4.4-debug/bin/tclsh8.4 
[Thread debugging using libthread_db enabled]
[New Thread -1220873568 (LWP 13574)]
2.2
% database db subscriber
[Switching to Thread -1220873568 (LWP 13574)]

Breakpoint 1, SQLConnect (connection_handle=0x80979b8, 
    server_name=0x805f988 "subscriberdb", name_length1=12, 
    user_name=0xb75e3428 "", name_length2=0, authentication=0xb75e3428 "", 
    name_length3=0) at ../../DriverManager/SQLConnect.c:3489
[New Thread -1225417808 (LWP 13587)]
[New Thread -1235907664 (LWP 13588)]
[New Thread -1246544976 (LWP 13589)]
0xb719e704 in TclDatabase::TclDatabase(TclObj, TclObj, TclObj) ()
   from /pkg/tclodbc/2.2.0-laura/lib/libtclodbc2.2.so
(gdb) c
Continuing.
db
% db disconnect
% exec ls

Program received signal SIGSEGV, Segmentation fault.
0xb6f8b900 in ?? ()
(gdb) bt
#0  0xb6f8b900 in ?? ()
#1  0xb7458276 in fork () from /lib/tls/libc.so.6
#2  0xb75c9093 in TclpCreateProcess (interp=0x804bee8, argc=1, argv=0x80bd6f0, 
    inputFile=0x1, outputFile=0x6, errorFile=0x7, pidPtr=0xbfffaee0)
    at ../unix/tclUnixPipe.c:432
#3  0xb75ac6e0 in TclCreatePipeline (interp=0x804bee8, argc=1, argv=0x80bd6f0, 
    pidArrayPtr=0xbfffb084, inPipePtr=0x0, outPipePtr=0xbfffb090, 
    errFilePtr=0xbfffb08c) at ../generic/tclPipe.c:871
#4  0xb75aca0b in Tcl_OpenCommandChannel (interp=0x804bee8, argc=1, 
    argv=0x80bd6f0, flags=12) at ../generic/tclPipe.c:1020
#5  0xb7593045 in Tcl_ExecObjCmd (dummy=0x0, interp=0x804bee8, objc=2, 
    objv=0x804da6c) at ../generic/tclIOCmd.c:798
#6  0xb753e9f9 in TclEvalObjvInternal (interp=0x804bee8, objc=2, 
    objv=0x804da6c, command=0x0, length=0, flags=0)
    at ../generic/tclBasic.c:3084
#7  0xb756fe7f in TclExecuteByteCode (interp=0x804bee8, codePtr=0x80974f0)
    at ../generic/tclExecute.c:1404
#8  0xb756ebca in TclCompEvalObj (interp=0x804bee8, objPtr=0x805f690)
    at ../generic/tclExecute.c:982
#9  0xb753fc81 in Tcl_EvalObjEx (interp=0x804bee8, objPtr=0x805f690, 
    flags=131072) at ../generic/tclBasic.c:4004
#10 0xb7585cb8 in Tcl_RecordAndEvalObj (interp=0x804bee8, cmdPtr=0x805f690, 
    flags=131072) at ../generic/tclHistory.c:142
#11 0xb759f7c2 in Tcl_Main (argc=1, argv=0xbfffb894, 
    appInitProc=0x8048773 <Tcl_AppInit>) at ../generic/tclMain.c:390
#12 0x08048766 in main (argc=1, argv=0xbfffb894) at ../unix/tclAppInit.c:90
(gdb) 

If I never disconnect from the database, the TCL exec command continues
to work. It's only after I've called the disconnect command that the
SegFault occurs.


If I link tclodbc directly against the Sybase 9.0.1 ODBC library
(libdbodbc_9.so), eliminating unixODBC from the equation, this problem
does not occur. I can connect to and disconnect from the database and exec
continues to work, even after I've disconnected.  This seems to point to
unixODBC as the culprit.

I have also been able to reproduce this problem by asking to connect to the DSN when 
the Sybase database server is not running:

laura at lauravm1 (/home/laura/projects/test): /pkg/tcl/8.4.4-debug/bin/tclsh8.4 
% exec ls
problem.txt
test.tcl
% package require tclodbc
2.2
% database db subscriber
08001 -100 {[unixODBC][Sybase][ODBC Driver][Adaptive Server Anywhere]Database server not found}
% exec ls
Segmentation fault
laura at lauravm1 (/home/laura/projects/test): 

My theory is that the problem lies in the disconnect code. I have walked
through SQLDisconnect and SQLConnect and see that a partial connection
is attempted in the 'Database server not found' case, which results in
some disconnect code being executed.

This problem also occurs with unixODBC 2.2.7.


Any thoughts would be appreciated.

Thank you


_____________________________________________
Laura Lefebvre
ACI Worldwide - MessagingDirect
mailto:Laura.Lefebvre at MessagingDirect.com
phone: (780) 429 3513 Ext. 320




More information about the unixODBC-support mailing list