methew / pyodbc

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

Segmentation fault when querying a large data set #346

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
import pyodbc
cxn = pyodbc.connect("Driver={ODBC Driver 11 for SQL 
Server};Address={address101};Database=Database;UID=webuser;PWD=pass123;Trusted_C
onnection=No")
cur = cxn.cursor()
q = """select a.uuid, f.name, cast(f.value as text)
from application a
inner join fields f on a.application_id = f.application_id"""
cur.execute(q)
rows = cur.fetchall()

What is the expected output? What do you see instead?
Instead of getting the rows, it crashes approximately on the 3-rd gigabyte of 
data (the data set is totally around 6 gigs, which is being loaded into the 
memory.) See the backtrace below.

What version of the product are you using? On what operating system?
pyodbc 3.0.7 with patch from issue 296 applied (was crashing without the patch 
as well, the patch fixed another problem I was facing.) with Microsoft ODBC 
Driver 11 for SQL Server on Linux. OS - Ubuntu 12.04 

Please provide any additional information below.

backtrace: 
(gdb) c
Continuing.

Program received signal SIGSEGV, Segmentation fault.
0x00007f65e0043c0d in gconv () from /usr/lib/x86_64-linux-gnu/gconv/UTF-16.so
(gdb) bt
#0  0x00007f65e0043c0d in gconv () from 
/usr/lib/x86_64-linux-gnu/gconv/UTF-16.so
#1  0x00007f65e1d7c9a4 in ?? () from /lib/x86_64-linux-gnu/libc.so.6
#2  0x00007f65e1d7bf7a in iconv () from /lib/x86_64-linux-gnu/libc.so.6
#3  0x00007f65dfd70155 in ?? () from 
/opt/microsoft/msodbcsql/lib64/libmsodbcsql-11.0.so.2270.0
#4  0x00007f65dfd46d94 in ?? () from 
/opt/microsoft/msodbcsql/lib64/libmsodbcsql-11.0.so.2270.0
#5  0x00007f65dfd470b6 in ?? () from 
/opt/microsoft/msodbcsql/lib64/libmsodbcsql-11.0.so.2270.0
#6  0x00007f65dfcbf6d8 in ?? () from 
/opt/microsoft/msodbcsql/lib64/libmsodbcsql-11.0.so.2270.0
#7  0x00007f65dfcc2aed in ?? () from 
/opt/microsoft/msodbcsql/lib64/libmsodbcsql-11.0.so.2270.0
#8  0x00007f65dfd23175 in ?? () from 
/opt/microsoft/msodbcsql/lib64/libmsodbcsql-11.0.so.2270.0
#9  0x00007f65dfd237af in SQLGetData () from 
/opt/microsoft/msodbcsql/lib64/libmsodbcsql-11.0.so.2270.0
#10 0x00007f65e097e991 in SQLGetData (statement_handle=0x13e23e0, 
column_number=3, target_type=1, target_value=0x7fffe8686ea0, 
buffer_length=4094, strlen_or_ind=0x7fffe8687f30) at SQLGetData.c:443
#11 0x00007f65e0bdae33 in GetDataString (cur=0x1284a50, iCol=<optimized out>) 
at /home/user/tmp/pyodbc/src/getdata.cpp:345
#12 0x00007f65e0bdb90b in GetData (cur=0x1284a50, iCol=2) at 
/home/user/tmp/pyodbc/src/getdata.cpp:714
#13 0x00007f65e0bdc568 in Cursor_fetch (cur=0x1284a50) at 
/home/user/tmp/pyodbc/src/cursor.cpp:1067
#14 Cursor_fetch (cur=0x1284a50) at /home/user/tmp/pyodbc/src/cursor.cpp:1030
#15 0x00007f65e0bdc631 in Cursor_fetchlist (cur=0x1284a50, max=-1) at 
/home/user/tmp/pyodbc/src/cursor.cpp:1098
#16 0x00000000004870ca in PyEval_EvalFrameEx ()
#17 0x000000000048d930 in PyEval_EvalCodeEx ()
#18 0x000000000042537b in PyRun_InteractiveOneFlags ()
#19 0x0000000000425725 in PyRun_InteractiveLoopFlags ()
#20 0x0000000000426580 in Py_Main ()
#21 0x00007f65e1d7b76d in __libc_start_main () from 
/lib/x86_64-linux-gnu/libc.so.6
#22 0x000000000041bb31 in _start ()

Original issue reported on code.google.com by dkuznet...@gmail.com on 4 Nov 2013 at 7:11

GoogleCodeExporter commented 9 years ago
Perhaps it's related to this issue with SQL Server driver:

http://msdn.microsoft.com/en-us/library/hh568448.aspx

and has nothing to do with pyodbc:

Original comment by dkuznet...@gmail.com on 4 Nov 2013 at 7:40

GoogleCodeExporter commented 9 years ago
Confirmed, it was related to the SQL server driver issue. 
Casting to ntext instead of text solved this particular problem.

Original comment by dkuznet...@gmail.com on 4 Nov 2013 at 9:37