[ psqlodbc-Bugs-1000735 ] segfault at disconnect (CC_clear_error:414)
am 20.09.2006 11:47:33 von noreplyBugs item #1000735, was opened at 2006-09-20 09:47
You can respond by visiting:
http://pgfoundry.org/tracker/?func=detail&atid=538&aid=10007 35&group_id=1000125
Category: None
Group: None
Status: Open
Resolution: None
Priority: 3
Submitted By: Nobody (None)
Assigned to: Nobody (None)
Summary: segfault at disconnect (CC_clear_error:414)
Initial Comment:
hello,
psqlodbc (version 08.02.0002) is (in my case) used in the following chain:
python<->mxODBC<->unixODBC<->psqlodbc<->postgres
the python program segfaulted when disconnecting from the database. here's the backtrace:
(gdb) r
Starting program: /usr/bin/python t.py
[Thread debugging using libthread_db enabled]
[New Thread -1210853696 (LWP 16866)]
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread -1210853696 (LWP 16866)]
CC_clear_error (self=0x0) at connection.c:414
414 if (self->__error_message)
(gdb) bt
#0 CC_clear_error (self=0x0) at connection.c:414
#1 0xb7aee7f2 in SC_clear_error (self=0x8333d68) at statement.c:934
#2 0xb7af148e in SC_Destructor (self=0x8333d68) at statement.c:426
#3 0xb7ac88dc in CC_cleanup (self=0x83341a8) at connection.c:519
#4 0xb7ac8fc5 in PGAPI_Disconnect (hdbc=0x83341a8) at connection.c:197
#5 0xb7af8a8c in SQLDisconnect (ConnectionHandle=0x83341a8) at odbcapi.c:299
#6 0xb7bab675 in SQLDisconnect (connection_handle=0x830b690) at SQLDisconnect.c:313
#7 0xb7c044ad in mxODBC_Close (dbc=0xb7cc80c0, report_errors=1) at mx/ODBC/unixODBC/mxODBC.c:6101
#8 0xb7c0458f in mxODBC_close (self=0xb7cc80c0, args=0x0) at mx/ODBC/unixODBC/mxODBC.c:6176
#9 0x080d4fa4 in PyEval_EvalFrame (f=0x829394c) at Python/ceval.c:3542
#10 0x080d53cb in PyEval_EvalFrame (f=0x82514ac) at Python/ceval.c:3640
#11 0x080d6787 in PyEval_EvalCodeEx (co=0xb7d34ee0, globals=0xb7d15824, locals=0xb7d15824, args=0x0,
argcount=0, kws=0x0, kwcount=0, defs=0x0, defcount=0, closure=0x0) at Python/ceval.c:2736
#12 0x080d67e9 in PyEval_EvalCode (co=0xb7d34ee0, globals=0xb7d15824, locals=0xb7d15824)
at Python/ceval.c:484
#13 0x080f8f87 in PyRun_FileExFlags (fp=0x8240008, filename=0xbf8a9b8f "t.py", start=257,
globals=0xb7d15824, locals=0xb7d15824, closeit=1, flags=0xbf8a89f4) at Python/pythonrun.c:1265
#14 0x080f9184 in PyRun_SimpleFileExFlags (fp=0x8240008, filename=0xbf8a9b8f "t.py", closeit=1,
flags=0xbf8a89f4) at Python/pythonrun.c:860
#15 0x08073606 in Py_Main (argc=1, argv=0xbf8a8ac4) at Modules/main.c:484
#16 0x08072b92 in main (argc=0, argv=0x139) at Modules/python.c:23
after some debugging i found out that the code in connection.c:517 (method CC_cleanup()) does the following:
stmt->hdbc = NULL; /* prevent any more dbase interactions */
SC_Destructor(stmt);
SC_Desctructor() in turn calls SC_clear_error() which calls CC_clear_error (line 934):
CC_clear_error(SC_get_conn(self));
the problem here is that self->hdbc is NULL as set in CC_cleanup(). the fix is IMHO changing the statement.c:934 to read:
if (SC_get_conn(self))
CC_clear_error(SC_get_conn(self));
attached is the diff.
thanks,
Michal Vitecek
------------------------------------------------------------ ----------
You can respond by visiting:
http://pgfoundry.org/tracker/?func=detail&atid=538&aid=10007 35&group_id=1000125
---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly