[CONC-667] mysql_stmt_fetch() crashes when mysql_stmt_reset() or mysql_stmt_free_result() for other statement are called. Created: 2023-09-14  Updated: 2023-09-14

Status: Open
Project: MariaDB Connector/C
Component/s: Prepared Statements
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: Filip Strömbäck Assignee: Georg Richter
Resolution: Unresolved Votes: 0
Labels: crash
Environment:

Ubuntu Linux 22.04 using GCC


Attachments: File main-1.c    

 Description   

After executing a prepared statement (mysql_stmt_execute), if either mysql_stmt_free_result() or mysql_stmt_reset() are called with another prepared statement as parameter, then the client library (connector/c) crashes when mysql_stmt_fetch() is later called.

I have attached a minimum example in C that illustrates this. This happens on version 10.6.12 (according to the MARIADB_CLIENT_VERSION_STR in the headers) on the library from the system's package manager. When either of the two calls below the comment "Problematic lines" are present, the program crashes at the call after "About to fetch". When none of the problematic lines are present, the program runs to completion.

I don't necessarily expect the calls to mysql_stmt_free_result() or mysql_stmt_reset() to be allowed in this situation. I would, however, have expected that I received some error code either at either of the calls. This would make it easier to debug the situation.

For context, this happened when I was implementing cleanup in a destructor in a C++ wrapper for the C library. In certain cases, cleanup happened after executing the query, but before fetching the results. I have a workaround for the problem, so this is mainly to make it easier to debug future problems.


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