[MDEV-9929] MariaDB segfaults on command "mysqld --version" with ignore-db-dir option on /etc/my.cnf Created: 2016-04-15  Updated: 2016-04-20  Resolved: 2016-04-20

Status: Closed
Project: MariaDB Server
Component/s: Platform RedHat
Affects Version/s: 5.5.47, 10.0.24, 10.1.12
Fix Version/s: 5.5.49, 10.0.25, 10.1.14

Type: Bug Priority: Major
Reporter: Alexey B Assignee: Sergei Golubchik
Resolution: Fixed Votes: 0
Labels: None
Environment:

clean Centos 7 system with MariaDB installed;

MariaDB server built with option:
-DWITH_EMBEDDED_SERVER=OFF
;

In my.cnf file added ignore-db-dir option:
[/etc]# cat /etc/my.cnf | grep ignore-db-dir
ignore-db-dir = .zfs
;



 Description   

When I execute command:
./mysqld --version
I get:

[~/rpmbuild/BUILD/mariadb-10.0.24/sql]# ./mysqld --version
./mysqld  Ver 10.0.24-MariaDB for Linux on x86_64 (MariaDB Server)
160415  7:58:06 [Note] ./mysqld (mysqld 10.0.24-MariaDB) starting as process 293912 ...
Segmentation fault (core dumped)

Here is the core-file content:

Using host libthread_db library "/lib64/libthread_db.so.1".
Core was generated by `./mysqld --version'.
Program terminated with signal 11, Segmentation fault.
#0  0x00007f30ce9b3ccc in free () from /lib64/libc.so.6
Missing separate debuginfos, use: debuginfo-install glibc-2.17-106.el7_2.4.x86_64 keyutils-libs-1.5.8-3.el7.x86_64 krb5-libs-1.13.2-12.el7_2.x86_64 libaio-0.3.109-13.el7.x86_64 libcom_err-1.42.9-7.el7.x86_64 libgcc-4.8.5-4.el7.x86_64 libselinux-2.2.2-6.el7.x86_64 libstdc++-4.8.5-4.el7.x86_64 nss-softokn-freebl-3.16.2.3-13.el7_1.x86_64 openssl-libs-1.0.1e-51.el7_2.4.x86_64 pcre-8.32-15.el7.x86_64 xz-libs-5.1.2-12alpha.el7.x86_64 zlib-1.2.7-15.el7.x86_64
(gdb) where
#0  0x00007f30ce9b3ccc in free () from /lib64/libc.so.6
#1  0x0000000000623b0d in ignore_db_dirs_free () at /root/rpmbuild/BUILD/mariadb-10.0.24/sql/sql_show.cc:648
#2  0x00000000005362cd in clean_up (print_message=<optimized out>) at /root/rpmbuild/BUILD/mariadb-10.0.24/sql/mysqld.cc:2011
#3  0x000000000053a3b4 in clean_up (print_message=<optimized out>) at /root/rpmbuild/BUILD/mariadb-10.0.24/sql/mysqld.cc:1954
#4  unireg_abort (exit_code=exit_code@entry=0) at /root/rpmbuild/BUILD/mariadb-10.0.24/sql/mysqld.cc:1954
#5  0x000000000053e5cc in init_common_variables () at /root/rpmbuild/BUILD/mariadb-10.0.24/sql/mysqld.cc:4082
#6  0x000000000053fabb in mysqld_main (argc=44, argv=0x2873058) at /root/rpmbuild/BUILD/mariadb-10.0.24/sql/mysqld.cc:5378
#7  0x00007f30ce955b15 in __libc_start_main () from /lib64/libc.so.6
#8  0x000000000053435d in _start ()
(gdb) frame 1
#1  0x0000000000623b0d in ignore_db_dirs_free () at /root/rpmbuild/BUILD/mariadb-10.0.24/sql/sql_show.cc:648
648         my_free(opt_ignore_db_dirs);
(gdb) p opt_ignore_db_dirs
$1 = 0x2872ec8 ".zfs"

Here what valgrind says:

valgrind --tool=memcheck --leak-check=full --track-fds=yes ./mysqld --version
....
==294076== Invalid free() / delete / delete[] / realloc()
==294076==    at 0x4C2AD17: free (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==294076==    by 0x623B0C: ignore_db_dirs_free() (sql_show.cc:648)
==294076==    by 0x5362CC: clean_up(bool) [clone .part.34] (mysqld.cc:2011)
==294076==    by 0x53A3B3: clean_up (mysqld.cc:1954)
==294076==    by 0x53A3B3: unireg_abort (mysqld.cc:1954)
==294076==    by 0x53E5CB: init_common_variables() (mysqld.cc:4082)
==294076==    by 0x53FABA: mysqld_main(int, char**) (mysqld.cc:5378)
==294076==    by 0x6525B14: (below main) (in /usr/lib64/libc-2.17.so)
==294076==  Address 0x832a6b0 is 240 bytes inside a block of size 480 alloc'd
==294076==    at 0x4C29BFD: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==294076==    by 0xBC6916: my_malloc (my_malloc.c:100)
==294076==    by 0xBBED23: alloc_root (my_alloc.c:233)
==294076==    by 0xBA6AD8: init_default_directories (my_default.c:1204)
==294076==    by 0xBA6AD8: my_load_defaults (my_default.c:524)
==294076==    by 0x53F818: mysqld_main(int, char**) (mysqld.cc:5241)
==294076==    by 0x6525B14: (below main) (in /usr/lib64/libc-2.17.so)
.......

I see that if macro EMBEDDED_LIBRARY is not defined in this case code below breaks normal mariadb stopping.
In mysqld.cc in function init_common_variables

#ifndef EMBEDDED_LIBRARY
  if (opt_abort && !opt_verbose)
    unireg_abort(0);
#endif /*!EMBEDDED_LIBRARY*/


Generated at Thu Feb 08 07:38:23 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.