[CONPY-273] Crash in PyMem_RawDebugFree Created: 2023-11-22  Updated: 2023-11-22  Resolved: 2023-11-22

Status: Closed
Project: MariaDB Connector/Python
Component/s: DBAPI 2.0
Affects Version/s: 1.1.8
Fix Version/s: 1.1.9

Type: Bug Priority: Major
Reporter: Georg Richter Assignee: Georg Richter
Resolution: Fixed Votes: 0
Labels: None
Environment:

Windows


Attachments: File conpy273.py    
Python Version: 3.10

 Description   

This bug was initially reported on Stackoverflow by "JensS": https://stackoverflow.com/questions/77523793/python-crashes-pymem-debugrawfree-when-querying-mariadb-with-sqlalchemy-2-0

When running the attached script in Python Development Mode it crashes when substituting parameters inside the where clause:

Debug memory block at address p=0000028AE6179E20: API 'r'
    21 bytes originally requested
    The 7 pad bytes at p-7 are FORBIDDENBYTE, as expected.
    The 8 pad bytes at tail=0000028AE6179E35 are FORBIDDENBYTE, as expected.
    Data at p: 4d 79 20 41 63 63 6f 75 ... 00 00 00 00 00 00 00 00
 
Enable tracemalloc to get the memory block allocation traceback
 
Fatal Python error: _PyMem_DebugRawFree: bad ID: Allocated using API 'r', verified using API 'm'
Python runtime state: initialized
 
Current thread 0x00001678 (most recent call first):
  File "C:\python\python312\Lib\site-packages\mariadb-1.1.9-py3.12-win-amd64.egg\mariadb\cursors.py", line 135 in _substitute_parameters
  File "C:\python\python312\Lib\site-packages\mariadb-1.1.9-py3.12-win-amd64.egg\mariadb\cursors.py", line 306 in execute
  File "C:\python\python312\Lib\site-packages\sqlalchemy\engine\default.py", line 922 in do_execute
  File "C:\python\python312\Lib\site-packages\sqlalchemy\engine\base.py", line 1969 in _exec_single_context
  File "C:\python\python312\Lib\site-packages\sqlalchemy\engine\base.py", line 1848 in _execute_context
  File "C:\python\python312\Lib\site-packages\sqlalchemy\engine\base.py", line 1639 in _execute_clauseelement
  File "C:\python\python312\Lib\site-packages\sqlalchemy\sql\elements.py", line 516 in _execute_on_connection
  File "C:\python\python312\Lib\site-packages\sqlalchemy\engine\base.py", line 1416 in execute
  File "C:\python\python312\Lib\site-packages\sqlalchemy\orm\context.py", line 293 in orm_execute_statement
  File "C:\python\python312\Lib\site-packages\sqlalchemy\orm\session.py", line 2190 in _execute_internal
  File "C:\python\python312\Lib\site-packages\sqlalchemy\orm\session.py", line 2308 in execute
  File "C:\work\test\bug.py", line 21 in <module>


Generated at Thu Feb 08 03:31:32 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.