Uploaded image for project: 'MariaDB Connector/C'
  1. MariaDB Connector/C
  2. CONC-667

mysql_stmt_fetch() crashes when mysql_stmt_reset() or mysql_stmt_free_result() for other statement are called.

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Minor
    • Resolution: Fixed
    • None
    • 3.4.0
    • Prepared Statements
    • Ubuntu Linux 22.04 using GCC

    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.

      Attachments

        Activity

          People

            georg Georg Richter
            fstromback Filip Strömbäck
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Git Integration

                Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.