pyodbc: segfault on Linux / unixODBC when calling "use" statement, master only; 4.0.30 is fine
Environment
-
Python: Python 3.8.3 (default, May 23 2020, 16:34:37) [GCC 9.3.1 20200408 (Red Hat 9.3.1-2)] on linux
-
pyodbc: 4.0.31b51 from 7c7b1b1a928752158517f5c30165
-
ODBC headers / devel libs (Fedora 33):
unixODBC-2.3.9-1.fc33.x86_64 unixODBC-devel-2.3.9-1.fc33.x86_64
-
OS:
uname -a Linux photon3 5.10.8-200.fc33.x86_64 #1 SMP Sun Jan 17 19:53:01 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux -
DB:
Centos packages:
mssql-server-14.0.3356.20-23.x86_64 mssql-tools-17.6.1.1-1.x86_64 mssql-server-fts-14.0.3356.20-23.x86_64
-
driver: msodbcsql 13.1.9.2
Issue
SQLAlchemy’s test suite needs to use the “use” statement during a setup process in order to create a schema in a certain database. Building with latest master produces a segfault with the program below. I can do a source build against the 4.0.30 tag and that one is fine.
import pyodbc
print("Using pyodbc version: %s" % pyodbc.version)
conn = pyodbc.connect(
"DRIVER={ODBC Driver 13 for SQL Server};Server=mssql2017,1433;Database=test;UID=scott;PWD=tiger^5HHH"
)
cursor = conn.cursor()
cursor.execute("select db_name()")
db_name = cursor.fetchone()[0]
cursor.execute("use %s" % db_name)
cursor.close()
conn.close()
print("OK!")
output:
Using pyodbc version: 4.0.31b51
Segmentation fault (core dumped)
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 18 (2 by maintainers)
FYI @zzzeek , the fix for this issue has been merged to master. Feel free to run your CI against the latest pyodbc.
#859 works for me on Oracle Linux Server 8.3:
☺️
A fix should be on the way, @zzzeek . PR 859 has been raised. The issue was nothing to do with Fedora in the end, it was just my code. Nevertheless, many thanks indeed for checking this build and raising the issue.
Well Fedora 8 is eons ago, but if we want to call this a bug in Fedora itself I can raise this within Red Hat (where I happen to work!) if we want to raise this with the unixODBC package and we can get a good self-contained reproducer I can shop it around internally.