Uploaded image for project: 'MariaDB Connector/ODBC'
  1. MariaDB Connector/ODBC
  2. ODBC-232

Unhandled exception thrown: read access violation.

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 3.1.0
    • Fix Version/s: 2.0.19, 3.0.9, 3.1.1
    • Component/s: General
    • Labels:
      None
    • Environment:
      Windows Server 2008R2 x64
      ODBC Driver 3.1 RC 32-Bit

      Description

      ODBC driver crashes when Bind Col All is followed by Get Data All.

      While I'm not entirely sure, I think something similar is happening with SSIS during a data-flow (see the attached stack trace)

      Steps to reproduce

      1. ODBC Test (Unicode)
      2. Full Connect -> ODBC 3.0
      3. Catalog --> SQL Columns --> Tablename "combined_test"
      4. Results --> Bind Col All
      5. Results --> Get Data All --> Crash

      DDL for tests

      CREATE DATABASE ODBC_TEST;
      USE ODBC_TEST;
      create table combined_test ( 
       id int auto_increment primary key, 
       contents longtext null, 
       blobcontent longblob null, 
       bitfield bit(1) null
      );
      

      Debugging in Visual Studio and the source code showed @ https://github.com/MariaDB/mariadb-connector-c/blob/34f8887af03d022416dd6593de91d0706e57f46b/libmariadb/mariadb_lib.c#L3281

      mariadb_lib.c

      /* snip */
      MYSQL_FIELD * STDCALL mysql_fetch_field_direct(MYSQL_RES *res,uint fieldnr)
      {
        return &(res)->fields[fieldnr];
      }
      

      Exception:

      Unhandled exception thrown: read access violation.
      res was nullptr.
      

      Call Stack

      >	maodbc.dll!mysql_fetch_field_direct(st_mysql_res * res, unsigned int fieldnr) Line 3281	C
       	maodbc.dll!MADB_StmtGetData(void * StatementHandle, unsigned short Col_or_Param_Num, short TargetType, void * TargetValuePtr, long BufferLength, long * StrLen_or_IndPtr, int InternalUse) Line 2529	C
       	maodbc.dll!SQLGetData(void * StatementHandle, unsigned short Col_or_Param_Num, short TargetType, void * TargetValuePtr, long BufferLength, long * StrLen_or_IndPtr) Line 1813	C
      

      The same procedure via MySQL 8.0 Unicode Driver works (output below):

      MySQL 8.0 Unicode Driver

      SQLColumns:
          In:    StatementHandle = 0x00607008, CatalogName = SQL_NULL_HANDLE, NameLength1 = 0, SchemaName = SQL_NULL_HANDLE, NameLength2 = 0, 
                TableName = "combined_test", NameLength3 = 13, ColumnName = SQL_NULL_HANDLE, NameLength4 = 0
          Return: SQL_SUCCESS=0
       
      Bind Col All:
               icol, fCType, cbValueMax, pcbValue, rgbValue
                 1, SQL_C_WCHAR=-8, 66, 0, ""
                 2, SQL_C_WCHAR=-8, 66, 0, ""
                 3, SQL_C_WCHAR=-8, 66, 0, ""
                 4, SQL_C_WCHAR=-8, 66, 0, ""
                 5, SQL_C_SSHORT=-15, 2, 0, 0
                 6, SQL_C_WCHAR=-8, 22, 0, ""
                 7, SQL_C_SLONG=-16, 4, 0, 0
                 8, SQL_C_SLONG=-16, 4, 0, 0
                 9, SQL_C_SSHORT=-15, 2, 0, 0
                 10, SQL_C_SSHORT=-15, 2, 0, 0
                 11, SQL_C_SSHORT=-15, 2, 0, 0
                 12, SQL_C_WCHAR=-8, 66, 0, ""
                 13, SQL_C_WCHAR=-8, 66, 0, ""
                 14, SQL_C_SSHORT=-15, 2, 0, 0
                 15, SQL_C_SSHORT=-15, 2, 0, 0
                 16, SQL_C_SLONG=-16, 4, 0, 0
                 17, SQL_C_SLONG=-16, 4, 0, 0
                 18, SQL_C_WCHAR=-8, 5, 0, ""
       
      Get Data All:
      TST1005: Highest bound column is 18.
      "TABLE_CAT", "TABLE_SCHEM", "TABLE_NAME", "COLUMN_NAME", "DATA_TYPE", "TYPE_NAME", "COLUMN_SIZE", "BUFFER_LENGTH", "DECIMAL_DIGITS", "NUM_PREC_RADIX", "NULLABLE", "REMARKS", "COLUMN_DEF", "SQL_DATA_TYPE", "SQL_DATETIME_SUB", "CHAR_OCTET_LENGTH", "ORDINAL_POSITION", "IS_NULLABLE"
      "", <Null>, "combined_test", "id", 4, "integer", 10, 4, 0, 10, 1, "", "0", 4, <Null>, <Null>, 1, "YES"
      "", <Null>, "combined_test", "contents", -1, "longtext", 4294967295, 2147483647, <Null>, <Null>, 1, "", <Null>, -1, <Null>, 2147483647, 2, "YES"
      "", <Null>, "combined_test", "blobcontent", -4, "longblob", 4294967295, 2147483647, <Null>, <Null>, 1, "", <Null>, -4, <Null>, 2147483647, 3, "YES"
      "", <Null>, "combined_test", "bitfield", -7, "bit", 1, 1, 0, 10, 1, "", <Null>, -7, <Null>, <Null>, 4, "YES"
      4 rows fetched from 18 columns.
      
      

        Attachments

          Activity

            People

            Assignee:
            Lawrin Lawrin Novitsky
            Reporter:
            godwinpe Peter Godwin
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Git Integration