check_mysql_query segfaults with mysql-connector-c

This forum is intended for the discussion of Nagios plugin development. Feature requests, patches, bug fixes, and all types of development-related discussions are welcome!

NOTE: The SourceForge.net nagiosplug-devel mailing list has been deprecated in favor of this forum in order to expedite support and provide additional features not available on the old mailing list.

check_mysql_query segfaults with mysql-connector-c

Postby internethering » Thu Oct 04, 2018 2:35 am

Hi, I got a problem after the last mysql update on Gentoo Linux:

/usr/lib64/nagios/plugins/check_mysql_query -q "SELECT CASE WHEN variable_value = 'ON' THEN 0 ELSE 2 END FROM information_schema.global_status WHERE variable_name='SLAVE_RUNNING'" -u munin -w 0 -c 1
Speicherzugriffsfehler (Speicherabzug geschrieben)


GDB tell me:

Code: Select all
           PID: 9288 (check_mysql_que)
           UID: 0 (root)
           GID: 0 (root)
        Signal: 11 (SEGV)
     Timestamp: Thu 2018-10-04 09:29:04 CEST (2s ago)
  Command Line: /usr/lib64/nagios/plugins/check_mysql_query -q SELECT CASE WHEN variable_value = 'ON' THEN 0 ELSE 2 END FROM information_schema.global_status WHERE variable_name='SLAVE_RUNNING' -u munin -w 0 -c 1
    Executable: /usr/lib64/nagios/plugins/check_mysql_query
Control Group: /user.slice/user-1000.slice/session-7.scope
          Unit: session-7.scope
         Slice: user-1000.slice
       Session: 7
     Owner UID: 1000 (rhering)
       Boot ID: 437acb707f724b768bded532e1b7cb15
    Machine ID: 4a76fc793097f21873d0e38754d384fc
      Hostname: alpha.web
       Storage: /var/lib/systemd/coredump/core.check_mysql_que.0.437acb707f724b768bded532e1b7cb15.9288.1538638144000000.lz4
       Message: Process 9288 (check_mysql_que) of user 0 dumped core.
               
                Stack trace of thread 9288:
                #0  0x00007f66b9772507 memset (libcrypto.so.1.0.0)
                #1  0x00007f66ba5771ca my_aes_decrypt (libmysqlclient.so.18)
                #2  0x00007f66ba57363f mysql_file_getline (libmysqlclient.so.18)
                #3  0x00007f66ba573b45 search_default_file (libmysqlclient.so.18)
                #4  0x00007f66ba573f6e my_search_option_files (libmysqlclient.so.18)
                #5  0x00007f66ba574735 my_load_defaults (libmysqlclient.so.18)
                #6  0x00007f66ba535ec8 mysql_read_default_options (libmysqlclient.so.18)
                #7  0x00007f66ba53d3fc mysql_real_connect (libmysqlclient.so.18)
                #8  0x0000558383e705b6 main (check_mysql_query)
                #9  0x00007f66b9f3c011 __libc_start_main (libc.so.6)
                #10 0x0000558383e70a1a _start (check_mysql_query)

GNU gdb (Gentoo 8.2 p1) 8.2
Copyright (C) 2018 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-pc-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://bugs.gentoo.org/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from /usr/lib64/nagios/plugins/check_mysql_query...Reading symbols from /usr/lib64/debug//usr/lib64/nagios/plugins/check_mysql_query.debug...done.
done.

warning: core file may not match specified executable file.
[New LWP 9288]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
Core was generated by `/usr/lib64/nagios/plugins/check_mysql_query -q SELECT CASE WHEN variable_value'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x00007f66b9772507 in memset (__len=168, __ch=0, __dest=__dest@entry=0x0) at /usr/include/bits/string_fortified.h:71
71        return __builtin___memset_chk (__dest, __ch, __len, __bos0 (__dest));
(gdb) bt
#0  0x00007f66b9772507 in memset (__len=168, __ch=0, __dest=__dest@entry=0x0) at /usr/include/bits/string_fortified.h:71
#1  EVP_CIPHER_CTX_init (ctx=ctx@entry=0x0) at evp_enc.c:82
#2  0x00007f66ba5771ca in my_aes_decrypt (source=source@entry=0x7fff29972ec0 "1\260#\251\327\001\263\277\363\371\320C(n\365{", source_length=source_length@entry=16, dest=dest@entry=0x7fff29970ec0 "interactive-timeout\n",
    key=key@entry=0x7f66baac1520 <mysql_file_getline(char*, int, st_mysql_file*, char)::my_key> "\002\036\037\b\b\022\t\037\032\022\035\020\023\031\032\021\032\035\032\016", key_length=key_length@entry=20, mode=mode@entry=my_aes_128_ecb, iv=0x0, padding=true)
    at /usr/src/debug/dev-db/mysql-connector-c-6.1.11-r1/mysql-connector-c-6.1.11-src/mysys_ssl/my_aes_openssl.cc:188
#3  0x00007f66ba57363f in mysql_file_getline (size=4095, is_login_file=1 '\001', file=0x558384c2e990, str=0x7fff29970ec0 "interactive-timeout\n") at /usr/src/debug/dev-db/mysql-connector-c-6.1.11-r1/mysql-connector-c-6.1.11-src/mysys_ssl/my_default.cc:1194
#4  search_default_file_with_ext (opt_handler=0x7f66ba5728c0 <handle_default_option(void*, char const*, char const*)>, handler_ctx=0x7fff299750e0, dir=<optimized out>, ext=<optimized out>, config_file=<optimized out>, recursion_level=0, is_login_file=<optimized out>)
    at /usr/src/debug/dev-db/mysql-connector-c-6.1.11-r1/mysql-connector-c-6.1.11-src/mysys_ssl/my_default.cc:917
#5  0x00007f66ba573b45 in search_default_file (opt_handler=opt_handler@entry=0x7f66ba5728c0 <handle_default_option(void*, char const*, char const*)>, handler_ctx=handler_ctx@entry=0x7fff299750e0, dir=dir@entry=0x0, config_file=config_file@entry=0x7fff299754c0 "/root/.mylogin.cnf",
    is_login_file=is_login_file@entry=1 '\001') at /usr/src/debug/dev-db/mysql-connector-c-6.1.11-r1/mysql-connector-c-6.1.11-src/mysys_ssl/my_default.cc:787
#6  0x00007f66ba573f6e in my_search_option_files (conf_file=conf_file@entry=0x7fff299754c0 "/root/.mylogin.cnf", argc=argc@entry=0x7fff29975724, argv=argv@entry=0x7fff29975728, args_used=args_used@entry=0x7fff299750dc, func=func@entry=0x7f66ba5728c0 <handle_default_option(void*, char const*, char const*)>,
    func_ctx=func_ctx@entry=0x7fff299750e0, default_directories=0x558384c2e7b0, is_login_file=1 '\001', found_no_defaults=0 '\000') at /usr/src/debug/dev-db/mysql-connector-c-6.1.11-r1/mysql-connector-c-6.1.11-src/mysys_ssl/my_default.cc:390
#7  0x00007f66ba574735 in my_load_defaults (conf_file=conf_file@entry=0x7f66ba57ed06 "my", groups=<optimized out>, groups@entry=0x7fff29975760, argc=argc@entry=0x7fff29975724, argv=argv@entry=0x7fff29975728, default_directories=default_directories@entry=0x0)
    at /usr/src/debug/dev-db/mysql-connector-c-6.1.11-r1/mysql-connector-c-6.1.11-src/mysys_ssl/my_default.cc:677
#8  0x00007f66ba535ec8 in mysql_read_default_options (options=options@entry=0x7fff299764c8, filename=0x7f66ba57ed06 "my", group=0x558384c2be50 "client") at /usr/src/debug/dev-db/mysql-connector-c-6.1.11-r1/mysql-connector-c-6.1.11-src/sql-common/client.c:1802
#9  0x00007f66ba53d3fc in mysql_real_connect (mysql=0x7fff29976130, host=0x558384c03160 "", user=0x7fff299770d3 "munin", passwd=0x0, db=0x558384c03180 "", port=3306, unix_socket=0x0, client_flag=0) at /usr/src/debug/dev-db/mysql-connector-c-6.1.11-r1/mysql-connector-c-6.1.11-src/sql-common/client.c:4220
#10 0x0000558383e705b6 in main (argc=<optimized out>, argv=<optimized out>) at check_mysql_query.c:101


I renamded the .mylogin.cnf, than I get following error:

Code: Select all
           PID: 9148 (check_mysql_que)
           UID: 117 (nagios)
           GID: 102 (nagios)
        Signal: 11 (SEGV)
     Timestamp: Thu 2018-10-04 09:27:01 CEST (57s ago)
  Command Line: /usr/lib64/nagios/plugins/check_mysql_query -q SELECT CASE WHEN variable_value = 'ON' THEN 0 ELSE 2 END FROM information_schema.global_status WHERE variable_name='SLAVE_RUNNING' -u munin -w 0 -c 1
    Executable: /usr/lib64/nagios/plugins/check_mysql_query
Control Group: /system.slice/nrpe.service
          Unit: nrpe.service
         Slice: system.slice
       Boot ID: 437acb707f724b768bded532e1b7cb15
    Machine ID: 4a76fc793097f21873d0e38754d384fc
      Hostname: alpha.web
       Storage: /var/lib/systemd/coredump/core.check_mysql_que.117.437acb707f724b768bded532e1b7cb15.9148.1538638021000000.lz4
       Message: Process 9148 (check_mysql_que) of user 117 dumped core.
               
                Stack trace of thread 9148:
                #0  0x00007f472ba73763 __rawmemchr_avx2 (libc.so.6)
                #1  0x00007f472b996082 _IO_str_init_static_internal (libc.so.6)
                #2  0x00007f472b9862fa _IO_vsscanf (libc.so.6)
                #3  0x00007f472b97f7cc __sscanf (libc.so.6)
                #4  0x0000556fea8492e8 is_numeric (check_mysql_query)
                #5  0x0000556fea84862a main (check_mysql_query)
                #6  0x00007f472b934011 __libc_start_main (libc.so.6)
                #7  0x0000556fea848a1a _start (check_mysql_query)

GNU gdb (Gentoo 8.2 p1) 8.2
Copyright (C) 2018 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-pc-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://bugs.gentoo.org/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from /usr/lib64/nagios/plugins/check_mysql_query...Reading symbols from /usr/lib64/debug//usr/lib64/nagios/plugins/check_mysql_query.debug...done.
done.

warning: core file may not match specified executable file.
[New LWP 9148]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
Core was generated by `/usr/lib64/nagios/plugins/check_mysql_query -q SELECT CASE WHEN variable_value'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  __rawmemchr_avx2 () at ../sysdeps/x86_64/multiarch/memchr-avx2.S:61
61              VPCMPEQ (%rdi), %ymm0, %ymm1
(gdb) bt
#0  __rawmemchr_avx2 () at ../sysdeps/x86_64/multiarch/memchr-avx2.S:61
#1  0x00007f472b996082 in _IO_str_init_static_internal (sf=sf@entry=0x7fff41b9eab0, ptr=ptr@entry=0x8f8f8f8f8f8f8f8f <error: Cannot access memory at address 0x8f8f8f8f8f8f8f8f>, size=size@entry=0, pstart=pstart@entry=0x0) at strops.c:41
#2  0x00007f472b9862fa in _IO_vsscanf (string=0x8f8f8f8f8f8f8f8f <error: Cannot access memory at address 0x8f8f8f8f8f8f8f8f>, format=0x556fea84fa54 "%f%c", args=args@entry=0x7fff41b9ebe0) at iovsscanf.c:40
#3  0x00007f472b97f7cc in __sscanf (s=<optimized out>, format=format@entry=0x556fea84fa54 "%f%c") at sscanf.c:32
#4  0x0000556fea8492e8 in is_numeric (number=<optimized out>) at utils.c:186
#5  0x0000556fea84862a in main (argc=<optimized out>, argv=<optimized out>) at check_mysql_query.c:149


The problem exists since gentoo switched from mysql client libs to mysql-connector-c.

some version info:
dev-db/mysql-connector-c: 6.1.11-r1
dev-db/mysql: 5.6.40-r2
net-analyzer/monitoring-plugins: 2.2-r3
internethering
 
Posts: 1
Joined: Thu Oct 04, 2018 1:40 am

Re: check_mysql_query segfaults with mysql-connector-c

Postby scottwilkerson » Thu Oct 04, 2018 3:23 pm

Where did you get this plugin from?

internethering wrote:net-analyzer/monitoring-plugins: 2.2-r3


We are not the author of this, are you sure you are working with the nagios-plugins package and not something else?
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
User avatar
scottwilkerson
DevOps Engineer
 
Posts: 12020
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises


Return to Nagios Plugin Development

Who is online

Users browsing this forum: Google [Bot] and 3 guests