mkleehammer / pyodbc

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

Segmentation fault when using pyodbc.connect #1188

Closed alascorz closed 1 year ago

alascorz commented 1 year ago

Environment

Issue

I am trying to connect to an Azure Synapse database, using the following code snippet:

    conn_str = (
        f'DRIVER={{ODBC Driver 18 for SQL Server}};'
        f'SERVER={self.database_host};'
        f'DATABASE={self.database_name};'
        f'UID={self.database_user};'
        f'PWD={self.database_password};'
        f'Encrypt=yes;'
        f'TrustServerCertificate=no;'
    )

    conn = pyodbc.connect(conn_str)
    return conn.cursor()

The expected output would be a successful connection to the database and for the code to continue executing. However, the output obtained is a Segmentation Fault:

    Fatal Python error: Segmentation fault

For extra information, I've run some commands I've seen referenced in other threads:

   $ odbcinst -j
   unixODBC 2.3.11
   DRIVERS............: /etc/odbcinst.ini
   SYSTEM DATA SOURCES: /etc/odbc.ini
   FILE DATA SOURCES..: /etc/ODBCDataSources
   USER DATA SOURCES..: /root/.odbc.ini
   SQLULEN Size.......: 8
   SQLLEN Size........: 8
   SQLSETPOSIROW Size.: 8

   $ ldd which odbcinst
   linux-vdso.so.1 (0x00007fff5f2d4000)
   libodbcinst.so.2 => /usr/lib/x86_64-linux-gnu/libodbcinst.so.2 (0x00007fa496620000)
   libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fa4965ff000)
   libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fa49643f000)
   libltdl.so.7 => /usr/lib/x86_64-linux-gnu/libltdl.so.7 (0x00007fa496434000)
   /lib64/ld-linux-x86-64.so.2 (0x00007fa49683d000)
   libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fa49642f000)

   $ ldd pyodbc.cpython-37m-x86_64-linux-gnu.so
   linux-vdso.so.1 (0x00007fff2e598000)
   libodbc.so.2 => /usr/lib/x86_64-linux-gnu/libodbc.so.2 (0x00007f5fbd841000)
   libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f5fbd6bd000)
   libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f5fbd53a000)
   libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f5fbd520000)
   libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f5fbd4ff000)
   libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f5fbd33f000)
   libltdl.so.7 => /usr/lib/x86_64-linux-gnu/libltdl.so.7 (0x00007f5fbd332000)
   /lib64/ld-linux-x86-64.so.2 (0x00007f5fbdae4000)
   libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f5fbd32d000)

Any help will be greatly appreciated

v-chojas commented 1 year ago

Determine where the segfault is happening using gdb.

Please don't double-post, I already replied you in the other thread.

gordthompson commented 1 year ago

FWIW, I am unable to reproduce your issue. As mentioned in other threads, output from strace might also help identify the problem.