mkleehammer / pyodbc

Python ODBC bridge
https://github.com/mkleehammer/pyodbc/wiki
MIT No Attribution
2.89k stars 562 forks source link

MySQL ODBC driver - Segmentation fault on RHEL8 #1066

Closed dimon222 closed 1 year ago

dimon222 commented 2 years ago

Environment

Issue

Connecting to MySQL using pyodbc raises segmentation fault on RHEL8. I wasn't seeing same problem with RHEL7. I did ensure to use latest repository configuration for OL8 (yum-based installation) I also tried to downgrade to 4.0.30 like suggested in #1036, tried tarball compiled with glibc, tried RPM-way installation, and tried to even get the source and compile the driver myself - in all scenarios I get Segmentation fault. I attempted to enable trace, but it didn't show anything useful, complete silence after connection step in there. Says "completion = 0".

Extra note - I'm running it in K8s container under Gevent/Uwsgi bundle, so there might be involved some threading.

gordthompson commented 2 years ago

Do you get a segfault if you try to connect using unixODBC's isql utility?

dimon222 commented 2 years ago

No.

gordthompson commented 2 years ago

Can you try connecting via pyodbc from a plain Python session, i.e., outside of the environment that might be introducing the threading uncertainty?

v-chojas commented 2 years ago

You can also attach a gdebugger and run, that will show exactly where it crashed. x/i $rip will show faulting instruction directly, and bt will give a stack trace.

dimon222 commented 2 years ago

Can you try connecting via pyodbc from a plain Python session, i.e., outside of the environment that might be introducing the threading uncertainty?

Indeed. Its not happening in regular interpreter, so its something to do with Gevent/uwsgi umbrella impacting on how pyodbc behaves. I saw there were few similar issues related to async-incompatibility of pyodbc, but I wonder why OS upgrade would make a difference for exactly same versions of all components (except of unixODBC which is now new with... async fixes)

dimon222 commented 2 years ago

I think it's a complex issue related to gevent/driver/pyodbc behaving together in some way. I was able to work with other ODBC drivers (oracle, etc) via same pyodbc under gevent without any issues. Moreover, on RHEL8 mariadb-connector-odbc as dropin replacement was worked me instead of mysql without issues. I don't know what is true root cause (driver? But then why it works without gevent?!).