tanrj / pyodbc

Automatically exported from code.google.com/p/pyodbc
MIT No Attribution
0 stars 0 forks source link

This query makes pyodbc segfault #98

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Run a long-running query
2. Run the query "select * from v_monitor.sessions" in another process

What is the expected output? What do you see instead?
I expected it to fetch rows from the sessions table.  Instead, it segfaults.  
If I add a small limit to the query, it doesn't segfault, but all the 
rows it outputs are unintelligible garbage that looks like this:

(u'21-42 85:3449', u'vpadmnd00', u'vri', u'1.63.0:15', u'21-41 32:6711', 
u'vr0-et92:x', u'21-42 85:1878', u'0', u'UkonTn ', u'21-42 
85:1810', 0L, 29L, u'', u'Nn', u'Pswr')

What version of the product are you using? On what operating system?
'2.1.7-beta0' on CentOS with Python  2.6.4
vertica_3.5.9_odbc_3.5_unixodbc_x86_64_linux.so

Please provide any additional information below.
I don't think this is a problem with the vertica drivers.  This query works 
fine in isql, which uses the same drivers.  Below is the exact script 
I used to cause the segfault.  Be sure to kick off some long running query with 
another python script first: there has to be an existing 
session or you wont see the segfault.

import pyodbc
connection = pyodbc.connect('DSN=vert')
cursor = connection.cursor()
cursor.execute("""select * from v_monitor.sessions""")
rows = cursor.fetchall() # SEGMENTATION FAULT
print repr(rows) # GARBAGE

Original issue reported on code.google.com by nickreta...@gmail.com on 20 Apr 2010 at 11:58

GoogleCodeExporter commented 8 years ago
Friend showed me how to get a stack trace with gdb.  Here it is:

#0  0x00002aaaafbf3661 in GetDataString (cur=0x8408d0, iCol=<value optimized 
out>) at /tmp/pyodbc-2.1.7/src/getdata.cpp:188
#1  0x00002aaaafbf389a in GetData (cur=0x918940, iCol=1) at 
/tmp/pyodbc-2.1.7/src/getdata.cpp:585
#2  0x00002aaaafbee12a in Cursor_fetch (cur=0x8408d0) at 
/tmp/pyodbc-2.1.7/src/cursor.cpp:977
#3  0x00002aaaafbee1f8 in Cursor_fetchlist (cur=0x8408d0, max=-1) at 
/tmp/pyodbc-2.1.7/src/cursor.cpp:1009
#4  0x00002aaaaab9c6a3 in call_function (f=0x693570, throwflag=<value optimized 
out>) at Python/ceval.c:3690
#5  PyEval_EvalFrameEx (f=0x693570, throwflag=<value optimized out>) at 
Python/ceval.c:2389
#6  0x00002aaaaab9dc4f in PyEval_EvalCodeEx (co=0x2aaaaaf44648, globals=<value 
optimized out>, locals=<value optimized out>, args=0x0, argcount=0, kws=0x0, 
kwcount=0, 
    defs=0x0, defcount=0, closure=0x0) at Python/ceval.c:2968
#7  0x00002aaaaab9dc92 in PyEval_EvalCode (co=0x918940, globals=0x8c8, 
locals=0x4cc) at Python/ceval.c:522
#8  0x00002aaaaabc1401 in run_mod (fp=0x692dc0, filename=0x7fffffffebc7 
"segfault.py", start=<value optimized out>, globals=0x63bf50, locals=0x63bf50, 
closeit=1, 
    flags=0x7fffffffe8a0) at Python/pythonrun.c:1335
#9  PyRun_FileExFlags (fp=0x692dc0, filename=0x7fffffffebc7 "segfault.py", 
start=<value optimized out>, globals=0x63bf50, locals=0x63bf50, closeit=1, 
flags=0x7fffffffe8a0)
    at Python/pythonrun.c:1321
#10 0x00002aaaaabc16c4 in PyRun_SimpleFileExFlags (fp=<value optimized out>, 
filename=0x7fffffffebc7 "segfault.py", closeit=1, flags=0x7fffffffe8a0) at 
Python/pythonrun.c:931
#11 0x00002aaaaabccdcc in Py_Main (argc=<value optimized out>, 
argv=0x7fffffffe9c8) at Modules/main.c:599
#12 0x0000003bfc21d994 in __libc_start_main () from /lib64/libc.so.6
#13 0x0000000000400629 in _start ()

Original comment by nickreta...@gmail.com on 21 Apr 2010 at 12:05

GoogleCodeExporter commented 8 years ago
OK, that's fantastic.  I'll look at that.

I'm pretty sure I need to port the 3.1 Unicode support back to the 2.1.x 
branch.  I'm going to make a v2unicode 
branch to test with.  Did you build your own?  If so, I'll let you know when 
the branch is ready and you can try to 
reproduce it.

Original comment by mkleehammer on 21 Apr 2010 at 6:34

GoogleCodeExporter commented 8 years ago
I just installed it with `pip install pyodbc`, which compiles it automatically.

Original comment by nickreta...@gmail.com on 21 Apr 2010 at 9:01

GoogleCodeExporter commented 8 years ago
Is there another branch I should be using?

Original comment by nickreta...@gmail.com on 23 Apr 2010 at 9:32

GoogleCodeExporter commented 8 years ago
Some information from Vertica Help:

Regarding the odd error message you reported.  This is a result of
mismatching the character sizes between the connection and the
application, e.g. by the setting of WideCharSizeOut and WideCharSizeIn
in the connection parameters.

What is displayed in your case is every other character of the string.
Your reported odd string said:

Err nai eso Dfra

E.r.r. .n.a.i. .e.s.o. .D.f.r.a.
Error: Invalid Session ID format

Original comment by nickreta...@gmail.com on 28 Apr 2010 at 8:34

GoogleCodeExporter commented 8 years ago
Can you test this with 2.1.8?  I believe I've fixed the Unicode issues.

Original comment by mkleehammer on 6 Sep 2010 at 5:37

GoogleCodeExporter commented 8 years ago
Sorry, I don't work on this project anymore.

Original comment by nickreta...@gmail.com on 7 Sep 2010 at 7:35

GoogleCodeExporter commented 8 years ago

Original comment by mkleehammer on 7 Sep 2010 at 2:06

GoogleCodeExporter commented 8 years ago

Original comment by mkleehammer on 21 Nov 2010 at 4:44