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

mysql_upgrade segfault due to missing /etc/my.cnf.d

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Fixed
    • 5.5(EOL), 10.0(EOL), 10.1(EOL)
    • 5.5.49
    • Scripts & Clients
    • 10.0.24

    Description

      Hello, I'm building a custom script which builds/installs/upgrades mariadb from 10.0.22 to 10.1.9. One part of this script is to run mysql_upgrade to ensure that the dbs are properly upgraded from 10.0.22 to 10.1.9.

      In 10.0.22 mysql_upgrade works without issues if '/etc/my.cnf.d' doesn't exists, but seems that this is an issue with 10.1.9:

      root@debian8:~# mysql_upgrade --force -u root -pMyPass -h localhost
      mysql_upgrade: Can't read dir of '/etc/my.cnf.d' (Errcode: 2 "No such file or directory")
      Fatal error in defaults handling. Program aborted
      Segmentation fault

      NOTE: I don't use /etc/my.cnf.d nor I want to.

      Attachments

        Activity

          robertalks,

          I've checked that neither 10.0, nor 5.5, nor MySQL up to and including 5.7 are able to start with a non-existing include directory. It appears to be reasonable, because there is no hardcoded magic about using it – the includedir directive is a part of the cnf file, so if it's there, its use is assumed to be intentional.

          When standard packages are installed, they use cnf file templates, which have this directive, but they also create the desired include directory, so there is no problem with them.

          Now, I don't know how your custom packaging/installation script works, but my best guess is that it uses some pre-created cnf files provided with the source code, but doesn't do the job required to make them actually usable. From the error message, it appears that you might be using support-files/rpm/my.cnf file (which is also strange since you're on Debian).

          Anyway, if you do not want to use the include dir, the solution is to generate your own cnf file rather than take an existing one.

          elenst Elena Stepanova added a comment - robertalks , I've checked that neither 10.0, nor 5.5, nor MySQL up to and including 5.7 are able to start with a non-existing include directory. It appears to be reasonable, because there is no hardcoded magic about using it – the includedir directive is a part of the cnf file, so if it's there, its use is assumed to be intentional. When standard packages are installed, they use cnf file templates, which have this directive, but they also create the desired include directory, so there is no problem with them. Now, I don't know how your custom packaging/installation script works, but my best guess is that it uses some pre-created cnf files provided with the source code, but doesn't do the job required to make them actually usable. From the error message, it appears that you might be using support-files/rpm/my.cnf file (which is also strange since you're on Debian). Anyway, if you do not want to use the include dir, the solution is to generate your own cnf file rather than take an existing one.

          OK, agreed, just that the my.cnf actually got copied when doing the default install, wasn't even able to replace it in time. My problem is that is 'stupid' to have a segfault, an error, agreed, but segfault due to missing directory, sounds like a bug.

          You can do what you want with the bug, close or fix a segfault, as you wish.

          robertalks Robert Milasan added a comment - OK, agreed, just that the my.cnf actually got copied when doing the default install, wasn't even able to replace it in time. My problem is that is 'stupid' to have a segfault, an error, agreed, but segfault due to missing directory, sounds like a bug. You can do what you want with the bug, close or fix a segfault, as you wish.
          elenst Elena Stepanova added a comment - - edited

          I agree, crashing is never the right thing to do.

          Apparently it's fixed in 5.7 – while 5.6 also segfaults, 5.7 instead produces the error message "Upgrade process encountered error and will not continue.".

          Stack trace from 10.0 commit 2553f143fdeb9068eb02a8fda58750c24071f5ef

          [New LWP 20305]
          [Thread debugging using libthread_db enabled]
          Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
          Core was generated by `client/mysql_upgrade --defaults-file=10.0/1.cnf --port=3306 --'.
          Program terminated with signal 11, Segmentation fault.
          #0  0x000000000041cd15 in free_defaults (argv=0x0) at 10.0/mysys/my_default.c:652
          652       memcpy(&ptr, ((char *) argv) - sizeof(ptr), sizeof(ptr));
           
          Thread 1 (Thread 0x7f02d1445720 (LWP 20305)):
          #0  0x000000000041cd15 in free_defaults (argv=0x0) at 10.0/mysys/my_default.c:652
          #1  0x0000000000408a0f in free_used_memory () at 10.0/client/mysql_upgrade.c:183
          #2  0x0000000000408b61 in die (fmt=0x0) at 10.0/client/mysql_upgrade.c:207
          #3  0x000000000040a8b6 in main (argc=5, argv=0x7ffc792332e8) at 10.0/client/mysql_upgrade.c:1059

          To reproduce, start the server (normally), and then run mysql_upgrade with --defaults-file=<filename> where <filename> contains a directive to include a non-existing folder, e.g.

          [mysqld]
          lock-wait-timeout=30
           
          !includedir /home/elenst/nonexisting_include

          elenst Elena Stepanova added a comment - - edited I agree, crashing is never the right thing to do. Apparently it's fixed in 5.7 – while 5.6 also segfaults, 5.7 instead produces the error message "Upgrade process encountered error and will not continue.". Stack trace from 10.0 commit 2553f143fdeb9068eb02a8fda58750c24071f5ef [New LWP 20305] [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1". Core was generated by `client/mysql_upgrade --defaults-file=10.0/1.cnf --port=3306 --'. Program terminated with signal 11, Segmentation fault. #0 0x000000000041cd15 in free_defaults (argv=0x0) at 10.0/mysys/my_default.c:652 652 memcpy(&ptr, ((char *) argv) - sizeof(ptr), sizeof(ptr));   Thread 1 (Thread 0x7f02d1445720 (LWP 20305)): #0 0x000000000041cd15 in free_defaults (argv=0x0) at 10.0/mysys/my_default.c:652 #1 0x0000000000408a0f in free_used_memory () at 10.0/client/mysql_upgrade.c:183 #2 0x0000000000408b61 in die (fmt=0x0) at 10.0/client/mysql_upgrade.c:207 #3 0x000000000040a8b6 in main (argc=5, argv=0x7ffc792332e8) at 10.0/client/mysql_upgrade.c:1059 To reproduce, start the server (normally), and then run mysql_upgrade with --defaults-file=<filename> where <filename> contains a directive to include a non-existing folder, e.g. [mysqld] lock-wait-timeout=30   !includedir /home/elenst/nonexisting_include

          The bug-fix can not be taken from upstream as it includes a complete refactoring of the related code. However, the fix is simple. We were freeing a null pointer (as can be seen in the stacktrace, where argv=0x0). free_defaults should check if the argv pointer is NULL.

          cvicentiu Vicențiu Ciorbaru added a comment - The bug-fix can not be taken from upstream as it includes a complete refactoring of the related code. However, the fix is simple. We were freeing a null pointer (as can be seen in the stacktrace, where argv=0x0). free_defaults should check if the argv pointer is NULL.

          Thanks, yes, a pointer should be checked before freeing

          robertalks Robert Milasan added a comment - Thanks, yes, a pointer should be checked before freeing
          cvicentiu Vicențiu Ciorbaru added a comment - Fixed with: https://github.com/MariaDB/server/commit/2a4781789612c6c53cbe12c1426f93b15737a148

          People

            cvicentiu Vicențiu Ciorbaru
            robertalks Robert Milasan
            Votes:
            0 Vote for this issue
            Watchers:
            3 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.