Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Won't Fix
    • None
    • N/A
    • None
    • ArchLinux, mariadb-libs 10.3.12-4
      GHC (Haskell), mysql-simple 0.4.5 (Haskell), mysql 0.1.6 (Haskell)

    Description

      I was having problems after upgrading my system. It was using libmysqlclient.so.18 and
      now uses mariadb.so.3 as library to access the database. I started getting segfaults after
      multiple queries to the database. I traced the execution down to mariadb_lib.c unpack_fields
      function.

      This function sets multiple char* and length fields. At the end (https://github.com/MariaDB/mariadb-connector-c/blob/3.1/libmariadb/mariadb_lib.c#L810), it handles the default_value
      and set the "def" field accordingly. But there is the "def_length" field that should specify then
      length of the string pointed by "def". It is not initialized in the function. The mysql Haskell
      library uses this field to know the length of the string to copy internally. With a weird and
      big enough number, the program cashes with a sigsegv.

      Attachments

        Activity

          georg Georg Richter added a comment -

          default value and length are only used for api function

          mysql_list_fields 
          

          • however this function is marked as deprecated (and therefore not documented in our docs).
            To retrieve the default value you should use SQL syntax "SHOW COLUMNS" or retrieve the information from information_schema
          georg Georg Richter added a comment - default value and length are only used for api function mysql_list_fields however this function is marked as deprecated (and therefore not documented in our docs). To retrieve the default value you should use SQL syntax "SHOW COLUMNS" or retrieve the information from information_schema
          georg Georg Richter added a comment -

          Update: In C/C 3.0.9 values for def and def_length will be NULL/zero.

          georg Georg Richter added a comment - Update: In C/C 3.0.9 values for def and def_length will be NULL/zero.

          Having def=NULL and def_length=0 will be fine for the code in Haskell that was causing the problem:

          https://github.com/paul-rouse/mysql/blob/master/Database/MySQL/Base/Types.hsc#L221

          The peekS function was calling memcpy to simply copy the char* as an Haskell ByteString. This will simply
          be an empty string.

          Thank you.

          sylvainf Sylvain Falardeau added a comment - Having def=NULL and def_length=0 will be fine for the code in Haskell that was causing the problem: https://github.com/paul-rouse/mysql/blob/master/Database/MySQL/Base/Types.hsc#L221 The peekS function was calling memcpy to simply copy the char* as an Haskell ByteString. This will simply be an empty string. Thank you.

          People

            georg Georg Richter
            sylvainf Sylvain Falardeau
            Votes:
            0 Vote for this issue
            Watchers:
            2 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.