Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-20314

Segmentation fault

    XMLWordPrintable

Details

    • Bug
    • Status: Open (View Workflow)
    • Major
    • Resolution: Unresolved
    • 10.2(EOL), 10.3(EOL), 10.4(EOL)
    • None
    • None
    • None
    • MariaDB official docker image ( Ubuntu Linux )

    Description

      I am seeing the mariadb server core dumping while using libmysqludf_ta, but only if the derived_merge optimizer switch is turned off. This happens in mariadb 10.2 and above. It works on 10.1.

      While I first imagined this was most likely a bug in libmysqludf_ta, the attached stack trace does not mention libmysqludf_ta, hinting that perhaps something else is wrong.

      The problem is fairly easy to reproduce, ie:

      # Clone the udf repo
      git clone git@github.com:joaocosta/lib_mysqludf_ta.git
       
      cd lib_mysqludf_ta/
       
      # change to a mariadb version where the problem happens
      sed -i 's/10.1/10.4/' Dockerfile
       
      docker build --tag db_test .
       
      # Turn off derived_merge, it does not segfault if derived_merge is ON (but then the query returns the wrong results)
      echo "[mysqld]
      optimizer_switch='derived_merge=OFF'
      " > /tmp/custom.cnf
       
      # Run a mariadb instance with the required setup in place
      docker run -v /tmp/database:/var/lib/mysql \
                 -v /tmp/custom.cnf:/etc/mysql/conf.d/custom.cnf \
                 --name db \
                 -e "MYSQL_ROOT_PASSWORD=root" \
                 -e "MYSQL_DATABASE=db" \
                 -e "MYSQL_USER=db" \
                 -e "MYSQL_PASSWORD=db" -d db_test
       
       
      docker exec -ti db bash
       
      # Create a sample database to run the offending query against
      mysql -uroot -proot db < sampledb.sql
       
      mysql -uroot -proot db
      
      

      Once you have a mysql client prompt, run the query:

      SELECT * FROM (
       
      SELECT datetime as `datetime`, ta_previous(round(ta_rsi(close,14), 2),40) AS F1, ta_previous(close,40), ta_max(high,40), ta_min(low,40)
      FROM (
        SELECT * FROM EURUSD_86400
        WHERE datetime >= '0001-01-01' AND datetime <= '9999-12-31'
        ORDER BY datetime DESC
        LIMIT 5000
      ) AS R
      ORDER BY datetime ASC
       
      ) AS LIMIT_ROWS
       
      WHERE F1 > 75
      ORDER BY datetime DESC
      LIMIT 20;
      

      After running that query a couple of times, the server will crash with the attached stack trace, that can be retrieved with:

      docker logs db
      

      Thanks

      Attachments

        1. stacktrace.txt
          5 kB
        2. sampledb.sql
          126 kB
        3. custom.cnf
          0.0 kB

        Activity

          People

            Unassigned Unassigned
            joaocosta João Costa
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:

              Git Integration

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