pyodbc icon indicating copy to clipboard operation
pyodbc copied to clipboard

MySQL ODBC driver - Segmentation fault on RHEL8

Open dimon222 opened this issue 2 years ago • 6 comments

Environment

  • Python: 3.9
  • pyodbc: 4.0.32
  • OS: RHEL8 (UBI8 - https://catalog.redhat.com/software/containers/ubi8/ubi/5c359854d70cc534b3a3784e)
  • DB: MySQL
  • driver: MySQL ODBC driver 8.0.22

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.

dimon222 avatar May 30 '22 16:05 dimon222

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

gordthompson avatar May 30 '22 19:05 gordthompson

No.

dimon222 avatar May 30 '22 20:05 dimon222

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

gordthompson avatar May 30 '22 22:05 gordthompson

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.

v-chojas avatar May 30 '22 22:05 v-chojas

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 avatar May 31 '22 01:05 dimon222

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?!).

dimon222 avatar Jun 02 '22 20:06 dimon222