pyodbc: pyodbc - fetchone() crash - Only 4.0.38 issue (other versions work fine)

Environment

  • Python: 3.10
  • pyodbc: 4.0.38
  • OS: Win64 (same issue in Linux when running as Azure Python Function)
  • DB: Azure SQL
  • driver: ?

Issue

Get a none-defined error (python crashes)

Code works in 4.0.35 and before. Stopped working after updating to 4.0.38. Works again after downgrading to 4.0.35.

—Some test code that reproduces it for me:

    connection_string = os.environ["SQL_CONNECTION_STRING"]
    with pyodbc.connect(connection_string) as conn:
        cursor = conn.cursor()
        cursor. Execute("SELECT TOP 1 * FROM table")
        logging.info("Executed query")
        row = cursor.fetchone() 
        #loggin the row data
        logging.info("Fetched row")
        logging.info(f"Row: {row}")

Error: Language Worker Process exited. Pid=1516. / python exited with code -1073741819 (0xC0000005).

If running above without fetchone() no issues.


My first ever “bug report”. Apologies if it is not according to the standard. Done my best to make it useful.

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 16 (5 by maintainers)

Commits related to this issue

Most upvoted comments

My tests running in a docker container started failing when updating pyodbc to 4.0.38. I haven’t been able to fully track down what the issue is as it reports it as a Python segmentation fault error. Reverting to 4.0.35 fixed the issue.

Here’s what I see when I check the database result a few times:

>>> con = pyodbc.connect(dsn=DSN, database=DB, autocommit=True, trusted_connection='yes', app='pyCAOM_unittest')
>>> print(con.getinfo(pyodbc.SQL_DRIVER_NAME))
libmsodbcsql-17.10.so.2.1
>>> print(con.getinfo(pyodbc.SQL_DRIVER_VER)) 
17.10.0002
>>> 
>>> query = 'select @@servername'
>>> db_result = con.execute(query).fetchall()
>>> print(db_result)
[('TWMASTDB9',)]
>>> print(db_result)
[('[_b',)]
>>> print(db_result)
[''\'\\\'\\S',)]
>>> print(db_result)
Segmentation fault (core dumped)

With pyodbc 4.0.35 my value of db_result doesn’t change with each print statement.

FYI: I have yanked 4.0.38 from PyPI. 4.0.39 will be uploaded soon. The AppVeyor tests take a while. Once the current set completes I’ll bump the version, push, wait for those tests to complete (as they’ll have the version tag), then release.

Thanks to everyone for reporting this.