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

Loading MyRocks plugin back after it has been unloaded causes a crash

Details

    Description

      Running the following sequence of commands

      INSTALL SONAME 'ha_rocksdb';
      UNINSTALL SONAME 'ha_rocksdb';
      INSTALL SONAME 'ha_rocksdb';
      

      causes an assertion failure:

      mysqld: /home/psergey/dev-git/10.2-r5-debug/storage/rocksdb/rdb_threads.cc:46: 
      void myrocks::Rdb_thread::init(PSI_mutex_key, PSI_cond_key): Assertion `!m_run_once' failed.
      

      Looking at the code there, indeed MyRocks code did not intend to allow the plugin to be started after it was stopped.

      Attachments

        Issue Links

          Activity

            If I comment out that assert, I get a different crash:

            Program terminated with signal SIGSEGV, Segmentation fault.
            #0  __pthread_kill (threadid=<optimized out>, signo=11) at ../sysdeps/unix/sysv/linux/pthread_kill.c:62
            62      ../sysdeps/unix/sysv/linux/pthread_kill.c: No such file or directory.
            #0  __pthread_kill (threadid=<optimized out>, signo=11) at ../sysdeps/unix/sysv/linux/pthread_kill.c:62
            #1  0x00007fa533cbac69 in my_write_core (sig=11) at /home/psergey/dev-git/10.2-compatibility-mdev15509-debug/mysys/stacktrace.c:484
            #2  0x00007fa53355da88 in handle_fatal_signal (sig=11) at /home/psergey/dev-git/10.2-compatibility-mdev15509-debug/sql/signal_handler.cc:305
            #3  <signal handler called>
            #4  0x00007fa529f07867 in std::__shared_ptr<rocksdb::Statistics, (__gnu_cxx::_Lock_policy)2>::operator= (this=0x58) at /usr/include/c++/4.9/bits/shared_ptr_base.h:860
            #5  0x00007fa529f078af in std::shared_ptr<rocksdb::Statistics>::operator= (this=0x58) at /usr/include/c++/4.9/bits/shared_ptr.h:93
            #6  0x00007fa529edabac in myrocks::rocksdb_init_func (p=0x7fa518358db0) at /home/psergey/dev-git/10.2-compatibility-mdev15509-debug/storage/rocksdb/ha_rocksdb.cc:4034
            #7  0x00007fa53355f774 in ha_initialize_handlerton (plugin=0x7fa536448e58) at /home/psergey/dev-git/10.2-compatibility-mdev15509-debug/sql/handler.cc:521
            #8  0x00007fa5332c04d4 in plugin_initialize (tmp_root=0x7fa518005db8, plugin=0x7fa536448e58, argc=0x7fa52a8ec83c, argv=0x7fa51832a8b8, options_only=false) at /home/psergey/dev-git/10.2-compatibility-mdev15509-debug/sql/sql_plugin.cc:1414
            #9  0x00007fa5332c2454 in finalize_install (thd=0x7fa518000b00, table=0x7fa518134e90, name=0x7fa52a8ec880, argc=0x7fa52a8ec83c, argv=0x7fa51832a8b8) at /home/psergey/dev-git/10.2-compatibility-mdev15509-debug/sql/sql_plugin.cc:2081
            #10 0x00007fa5332c2a54 in mysql_install_plugin (thd=0x7fa518000b00, name=0x7fa5180053c0, dl_arg=0x7fa5180053d0) at /home/psergey/dev-git/10.2-compatibility-mdev15509-debug/sql/sql_plugin.cc:2188
            #11 0x00007fa5332b0cc8 in mysql_execute_command (thd=0x7fa518000b00) at /home/psergey/dev-git/10.2-compatibility-mdev15509-debug/sql/sql_parse.cc:6162
            #12 0x00007fa5332b5d5c in mysql_parse (thd=0x7fa518000b00, rawbuf=0x7fa5180127f8 "INSTALL SONAME 'ha_rocksdb'", length=27, parser_state=0x7fa52a8ee200, is_com_multi=false, is_next_command=false) at /home/psergey/dev-git/10.2-compatibility-mdev15509-debug/sql/sql_parse.cc:7974
            

            psergei Sergei Petrunia added a comment - If I comment out that assert, I get a different crash: Program terminated with signal SIGSEGV, Segmentation fault. #0 __pthread_kill (threadid=<optimized out>, signo=11) at ../sysdeps/unix/sysv/linux/pthread_kill.c:62 62 ../sysdeps/unix/sysv/linux/pthread_kill.c: No such file or directory. #0 __pthread_kill (threadid=<optimized out>, signo=11) at ../sysdeps/unix/sysv/linux/pthread_kill.c:62 #1 0x00007fa533cbac69 in my_write_core (sig=11) at /home/psergey/dev-git/10.2-compatibility-mdev15509-debug/mysys/stacktrace.c:484 #2 0x00007fa53355da88 in handle_fatal_signal (sig=11) at /home/psergey/dev-git/10.2-compatibility-mdev15509-debug/sql/signal_handler.cc:305 #3 <signal handler called> #4 0x00007fa529f07867 in std::__shared_ptr<rocksdb::Statistics, (__gnu_cxx::_Lock_policy)2>::operator= (this=0x58) at /usr/include/c++/4.9/bits/shared_ptr_base.h:860 #5 0x00007fa529f078af in std::shared_ptr<rocksdb::Statistics>::operator= (this=0x58) at /usr/include/c++/4.9/bits/shared_ptr.h:93 #6 0x00007fa529edabac in myrocks::rocksdb_init_func (p=0x7fa518358db0) at /home/psergey/dev-git/10.2-compatibility-mdev15509-debug/storage/rocksdb/ha_rocksdb.cc:4034 #7 0x00007fa53355f774 in ha_initialize_handlerton (plugin=0x7fa536448e58) at /home/psergey/dev-git/10.2-compatibility-mdev15509-debug/sql/handler.cc:521 #8 0x00007fa5332c04d4 in plugin_initialize (tmp_root=0x7fa518005db8, plugin=0x7fa536448e58, argc=0x7fa52a8ec83c, argv=0x7fa51832a8b8, options_only=false) at /home/psergey/dev-git/10.2-compatibility-mdev15509-debug/sql/sql_plugin.cc:1414 #9 0x00007fa5332c2454 in finalize_install (thd=0x7fa518000b00, table=0x7fa518134e90, name=0x7fa52a8ec880, argc=0x7fa52a8ec83c, argv=0x7fa51832a8b8) at /home/psergey/dev-git/10.2-compatibility-mdev15509-debug/sql/sql_plugin.cc:2081 #10 0x00007fa5332c2a54 in mysql_install_plugin (thd=0x7fa518000b00, name=0x7fa5180053c0, dl_arg=0x7fa5180053d0) at /home/psergey/dev-git/10.2-compatibility-mdev15509-debug/sql/sql_plugin.cc:2188 #11 0x00007fa5332b0cc8 in mysql_execute_command (thd=0x7fa518000b00) at /home/psergey/dev-git/10.2-compatibility-mdev15509-debug/sql/sql_parse.cc:6162 #12 0x00007fa5332b5d5c in mysql_parse (thd=0x7fa518000b00, rawbuf=0x7fa5180127f8 "INSTALL SONAME 'ha_rocksdb'", length=27, parser_state=0x7fa52a8ee200, is_com_multi=false, is_next_command=false) at /home/psergey/dev-git/10.2-compatibility-mdev15509-debug/sql/sql_parse.cc:7974

            I don't think that getting MyRocks to load after it has been unloaded should be my priority. This is a rarely used feature.

            Upstream is not affected by this as they link statically. Percona Server should be affected.

            We shouldn't allow the server to crash, though. Idea by Serg: return an error from myrocks_init_func on the second load.

            psergei Sergei Petrunia added a comment - I don't think that getting MyRocks to load after it has been unloaded should be my priority. This is a rarely used feature. Upstream is not affected by this as they link statically. Percona Server should be affected. We shouldn't allow the server to crash, though. Idea by Serg: return an error from myrocks_init_func on the second load.

            Ouch the above crash was observed on a rather dated 10.2 tree (bb-10.2-compatiblity based)

            commit 14d1af00586d05f89381ea28c9890c3dd501dbfc
            Author: Alexander Barkov <bar@mariadb.org>
            Date:   Fri Aug 18 23:36:42 2017 +0400
             
                MDEV-11952 Oracle-style packages: stage#5
            
            

            The current 10.2 should still have this problem. Actually, it crashes before the execution can reach the point where the original crash was.

            The exact way it crashes depends on the details of the testcase. The original one hangs here (note frame #7, sig=11)

            Thread 4 (Thread 0x7efc70821700 (LWP 10476)):
            #0  __lll_lock_wait_private () at ../sysdeps/unix/sysv/linux/x86_64/lowlevellock.S:95
            #1  0x00007efc763c10e3 in ptmalloc_lock_all () at arena.c:227
            #2  0x00007efc7640dcd2 in __libc_fork () at ../sysdeps/nptl/fork.c:89
            #3  0x00007efc799e9ef1 in start_addr2line_fork (binary_path=0x7ffd28973270 "/home/psergey/dev-git/10.2-r10/sql/mysqld")
                at /home/psergey/dev-git/10.2-r10/mysys/my_addr_resolve.c:172
            #4  0x00007efc799ea088 in my_addr_resolve (ptr=0x7efc799cba09 <my_print_stacktrace+56>, loc=0x7efc7081e0a0) at /home/psergey/dev-git/10.2-r10/mysys/my_addr_resolve.c:220
            #5  0x00007efc799cb944 in print_with_addr_resolve (addrs=0x7efc7081e0f0, n=20) at /home/psergey/dev-git/10.2-r10/mysys/stacktrace.c:253
            #6  0x00007efc799cba48 in my_print_stacktrace (stack_bottom=0x7efc70820e70 "", thread_stack=299008) at /home/psergey/dev-git/10.2-r10/mysys/stacktrace.c:271
            #7  0x00007efc7926cd7f in handle_fatal_signal (sig=11) at /home/psergey/dev-git/10.2-r10/sql/signal_handler.cc:166
            #8  <signal handler called>
            #9  _int_malloc (av=av@entry=0x7efc60000020, bytes=bytes@entry=180) at malloc.c:3694
            #10 0x00007efc763c750e in __GI___libc_malloc (bytes=180) at malloc.c:2895
            #11 0x00007efc799d7e4b in sf_malloc (size=64, my_flags=48) at /home/psergey/dev-git/10.2-r10/mysys/safemalloc.c:118
            ---Type <return> to continue, or q <return> to quit---
            #12 0x00007efc799c548a in my_malloc (size=64, my_flags=48) at /home/psergey/dev-git/10.2-r10/mysys/my_malloc.c:101
            #13 0x00007efc790a8a04 in initialize_schema_table (plugin=0x7efc7ca99c88) at /home/psergey/dev-git/10.2-r10/sql/sql_show.cc:9405
            #14 0x00007efc79014dc0 in plugin_initialize (tmp_root=0x7efc60005c58, plugin=0x7efc7ca99c88, argc=0x7efc7081ef2c, argv=0x7efc603572e0, options_only=false)
                at /home/psergey/dev-git/10.2-r10/sql/sql_plugin.cc:1416
            #15 0x00007efc79016d39 in finalize_install (thd=0x7efc60000b00, table=0x7efc6010f620, name=0x7efc7081ef70, argc=0x7efc7081ef2c, argv=0x7efc603572e0)
                at /home/psergey/dev-git/10.2-r10/sql/sql_plugin.cc:2080
            #16 0x00007efc79017339 in mysql_install_plugin (thd=0x7efc60000b00, name=0x7efc60005250, dl_arg=0x7efc60005260) at /home/psergey/dev-git/10.2-r10/sql/sql_plugin.cc:2187
            #17 0x00007efc79004f87 in mysql_execute_command (thd=0x7efc60000b00) at /home/psergey/dev-git/10.2-r10/sql/sql_parse.cc:6131
            #18 0x00007efc79009ec8 in mysql_parse (thd=0x7efc60000b00, rawbuf=0x7efc600124f8 "INSTALL SONAME 'ha_rocksdb'", length=27, parser_state=0x7efc70820200, is_com_multi=false, 
                is_next_command=false) at /home/psergey/dev-git/10.2-r10/sql/sql_parse.cc:7914
            #19 0x00007efc78ff7d83 in dispatch_command (command=COM_QUERY, thd=0x7efc60000b00, packet=0x7efc6016bc01 "INSTALL SONAME 'ha_rocksdb'", packet_length=27, is_com_multi=false, 
                is_next_command=false) at /home/psergey/dev-git/10.2-r10/sql/sql_parse.cc:1815
            #20 0x00007efc78ff66e6 in do_command (thd=0x7efc60000b00) at /home/psergey/dev-git/10.2-r10/sql/sql_parse.cc:1369
            #21 0x00007efc79144fa0 in do_handle_one_connection (connect=0x7efc7cc4e7f0) at /home/psergey/dev-git/10.2-r10/sql/sql_connect.cc:1335
            #22 0x00007efc79144d2d in handle_one_connection (arg=0x7efc7cc4e7f0) at /home/psergey/dev-git/10.2-r10/sql/sql_connect.cc:1241
            #23 0x00007efc795d3afe in pfs_spawn_thread (arg=0x7efc7cc71b30) at /home/psergey/dev-git/10.2-r10/storage/perfschema/pfs.cc:1862
            #24 0x00007efc76f416aa in start_thread (arg=0x7efc70821700) at pthread_create.c:333
            #25 0x00007efc76449eed in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109
            

            psergei Sergei Petrunia added a comment - Ouch the above crash was observed on a rather dated 10.2 tree (bb-10.2-compatiblity based) commit 14d1af00586d05f89381ea28c9890c3dd501dbfc Author: Alexander Barkov <bar@mariadb.org> Date: Fri Aug 18 23:36:42 2017 +0400   MDEV-11952 Oracle-style packages: stage#5 The current 10.2 should still have this problem. Actually, it crashes before the execution can reach the point where the original crash was. The exact way it crashes depends on the details of the testcase. The original one hangs here (note frame #7, sig=11) Thread 4 (Thread 0x7efc70821700 (LWP 10476)): #0 __lll_lock_wait_private () at ../sysdeps/unix/sysv/linux/x86_64/lowlevellock.S:95 #1 0x00007efc763c10e3 in ptmalloc_lock_all () at arena.c:227 #2 0x00007efc7640dcd2 in __libc_fork () at ../sysdeps/nptl/fork.c:89 #3 0x00007efc799e9ef1 in start_addr2line_fork (binary_path=0x7ffd28973270 "/home/psergey/dev-git/10.2-r10/sql/mysqld") at /home/psergey/dev-git/10.2-r10/mysys/my_addr_resolve.c:172 #4 0x00007efc799ea088 in my_addr_resolve (ptr=0x7efc799cba09 <my_print_stacktrace+56>, loc=0x7efc7081e0a0) at /home/psergey/dev-git/10.2-r10/mysys/my_addr_resolve.c:220 #5 0x00007efc799cb944 in print_with_addr_resolve (addrs=0x7efc7081e0f0, n=20) at /home/psergey/dev-git/10.2-r10/mysys/stacktrace.c:253 #6 0x00007efc799cba48 in my_print_stacktrace (stack_bottom=0x7efc70820e70 "", thread_stack=299008) at /home/psergey/dev-git/10.2-r10/mysys/stacktrace.c:271 #7 0x00007efc7926cd7f in handle_fatal_signal (sig=11) at /home/psergey/dev-git/10.2-r10/sql/signal_handler.cc:166 #8 <signal handler called> #9 _int_malloc (av=av@entry=0x7efc60000020, bytes=bytes@entry=180) at malloc.c:3694 #10 0x00007efc763c750e in __GI___libc_malloc (bytes=180) at malloc.c:2895 #11 0x00007efc799d7e4b in sf_malloc (size=64, my_flags=48) at /home/psergey/dev-git/10.2-r10/mysys/safemalloc.c:118 ---Type <return> to continue, or q <return> to quit--- #12 0x00007efc799c548a in my_malloc (size=64, my_flags=48) at /home/psergey/dev-git/10.2-r10/mysys/my_malloc.c:101 #13 0x00007efc790a8a04 in initialize_schema_table (plugin=0x7efc7ca99c88) at /home/psergey/dev-git/10.2-r10/sql/sql_show.cc:9405 #14 0x00007efc79014dc0 in plugin_initialize (tmp_root=0x7efc60005c58, plugin=0x7efc7ca99c88, argc=0x7efc7081ef2c, argv=0x7efc603572e0, options_only=false) at /home/psergey/dev-git/10.2-r10/sql/sql_plugin.cc:1416 #15 0x00007efc79016d39 in finalize_install (thd=0x7efc60000b00, table=0x7efc6010f620, name=0x7efc7081ef70, argc=0x7efc7081ef2c, argv=0x7efc603572e0) at /home/psergey/dev-git/10.2-r10/sql/sql_plugin.cc:2080 #16 0x00007efc79017339 in mysql_install_plugin (thd=0x7efc60000b00, name=0x7efc60005250, dl_arg=0x7efc60005260) at /home/psergey/dev-git/10.2-r10/sql/sql_plugin.cc:2187 #17 0x00007efc79004f87 in mysql_execute_command (thd=0x7efc60000b00) at /home/psergey/dev-git/10.2-r10/sql/sql_parse.cc:6131 #18 0x00007efc79009ec8 in mysql_parse (thd=0x7efc60000b00, rawbuf=0x7efc600124f8 "INSTALL SONAME 'ha_rocksdb'", length=27, parser_state=0x7efc70820200, is_com_multi=false, is_next_command=false) at /home/psergey/dev-git/10.2-r10/sql/sql_parse.cc:7914 #19 0x00007efc78ff7d83 in dispatch_command (command=COM_QUERY, thd=0x7efc60000b00, packet=0x7efc6016bc01 "INSTALL SONAME 'ha_rocksdb'", packet_length=27, is_com_multi=false, is_next_command=false) at /home/psergey/dev-git/10.2-r10/sql/sql_parse.cc:1815 #20 0x00007efc78ff66e6 in do_command (thd=0x7efc60000b00) at /home/psergey/dev-git/10.2-r10/sql/sql_parse.cc:1369 #21 0x00007efc79144fa0 in do_handle_one_connection (connect=0x7efc7cc4e7f0) at /home/psergey/dev-git/10.2-r10/sql/sql_connect.cc:1335 #22 0x00007efc79144d2d in handle_one_connection (arg=0x7efc7cc4e7f0) at /home/psergey/dev-git/10.2-r10/sql/sql_connect.cc:1241 #23 0x00007efc795d3afe in pfs_spawn_thread (arg=0x7efc7cc71b30) at /home/psergey/dev-git/10.2-r10/storage/perfschema/pfs.cc:1862 #24 0x00007efc76f416aa in start_thread (arg=0x7efc70821700) at pthread_create.c:333 #25 0x00007efc76449eed in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109
            psergei Sergei Petrunia added a comment - - edited

            A modified mariadb_plugin.test causes a different crash:

            --source include/have_log_bin.inc
            --source include/have_binlog_format_row.inc
             
            --echo #
            --echo # MDEV-14843: Assertion `s_tx_list.size() == 0' failed in myrocks::Rdb_transaction::term_mutex
            --echo #
             
            INSTALL SONAME 'ha_rocksdb';
             
            CREATE TABLE t1 (i INT) ENGINE=RocksDB;
            insert into t1 values (1);
             
            connect (con1,localhost,root,,);
            connection con1;
            insert into test.t1 values (1);
             
            connection default;
             
            # Cleanup
            DROP TABLE t1;
            UNINSTALL SONAME 'ha_rocksdb';
             
            select 1;
            INSTALL SONAME 'ha_rocksdb';
            

            Crash:

            180327 12:53:16 [ERROR] mysqld got signal 11 ;
            ..
            Thread 1 (Thread 0x7f8e201e4700 (LWP 13292)):
            #0  __pthread_kill (threadid=<optimized out>, signo=11) at ../sysdeps/unix/sysv/linux/pthread_kill.c:62
            #1  0x00007f8e28432afa in my_write_core (sig=11) at /home/psergey/dev-git/10.2-r10/mysys/stacktrace.c:477
            #2  0x00007f8e27cd41a8 in handle_fatal_signal (sig=11) at /home/psergey/dev-git/10.2-r10/sql/signal_handler.cc:305
            #3  <signal handler called>
            #4  0x00007f8e2843f672 in bad_ptr (where=0x7f8e287b32fd "Freeing", ptr=0x7f8e081842a0) at /home/psergey/dev-git/10.2-r10/mysys/safemalloc.c:326
            #5  0x00007f8e2843f0f5 in sf_free (ptr=0x7f8e081842a0) at /home/psergey/dev-git/10.2-r10/mysys/safemalloc.c:194
            #6  0x00007f8e2842c90b in my_free (ptr=0x7f8e081842a0) at /home/psergey/dev-git/10.2-r10/mysys/my_malloc.c:217
            #7  0x00007f8e2842054c in free_root (root=0x7f8e201e1eb0, MyFlags=0) at /home/psergey/dev-git/10.2-r10/mysys/my_alloc.c:392
            #8  0x00007f8e28407e95 in free_defaults (argv=0x7f8e0836df90) at /home/psergey/dev-git/10.2-r10/mysys/my_default.c:652
            #9  0x00007f8e27a7e3b7 in mysql_install_plugin (thd=0x7f8e08000b00, name=0x7f8e08005250, dl_arg=0x7f8e08005260) at /home/psergey/dev-git/10.2-r10/sql/sql_plugin.cc:2199
            #10 0x00007f8e27a6bf87 in mysql_execute_command (thd=0x7f8e08000b00) at /home/psergey/dev-git/10.2-r10/sql/sql_parse.cc:6131
            #11 0x00007f8e27a70ec8 in mysql_parse (thd=0x7f8e08000b00, rawbuf=0x7f8e080125f8 "INSTALL SONAME 'ha_rocksdb'", length=27, parser_state=0x7f8e201e3200, is_com_multi=false, is_next_command=false) at /home/psergey/dev-git/10.2-r10/sql/sql_parse.cc:7914
            #12 0x00007f8e27a5ed83 in dispatch_command (command=COM_QUERY, thd=0x7f8e08000b00, packet=0x7f8e0816a951 "INSTALL SONAME 'ha_rocksdb'", packet_length=27, is_com_multi=false, is_next_command=false) at /home/psergey/dev-git/10.2-r10/sql/sql_parse.cc:1815
            #13 0x00007f8e27a5d6e6 in do_command (thd=0x7f8e08000b00) at /home/psergey/dev-git/10.2-r10/sql/sql_parse.cc:1369
            #14 0x00007f8e27babfa0 in do_handle_one_connection (connect=0x7f8e29c0e0b0) at /home/psergey/dev-git/10.2-r10/sql/sql_connect.cc:1335
            #15 0x00007f8e27babd2d in handle_one_connection (arg=0x7f8e29c0e0b0) at /home/psergey/dev-git/10.2-r10/sql/sql_connect.cc:1241
            #16 0x00007f8e2803aafe in pfs_spawn_thread (arg=0x7f8e29bf10a0) at /home/psergey/dev-git/10.2-r10/storage/perfschema/pfs.cc:1862
            #17 0x00007f8e259a86aa in start_thread (arg=0x7f8e201e4700) at pthread_create.c:333
            #18 0x00007f8e24eb0eed in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109
            

            psergei Sergei Petrunia added a comment - - edited A modified mariadb_plugin.test causes a different crash: --source include/have_log_bin.inc --source include/have_binlog_format_row.inc   --echo # --echo # MDEV-14843: Assertion `s_tx_list.size() == 0' failed in myrocks::Rdb_transaction::term_mutex --echo #   INSTALL SONAME 'ha_rocksdb';   CREATE TABLE t1 (i INT) ENGINE=RocksDB; insert into t1 values (1);   connect (con1,localhost,root,,); connection con1; insert into test.t1 values (1);   connection default;   # Cleanup DROP TABLE t1; UNINSTALL SONAME 'ha_rocksdb';   select 1; INSTALL SONAME 'ha_rocksdb'; Crash: 180327 12:53:16 [ERROR] mysqld got signal 11 ; .. Thread 1 (Thread 0x7f8e201e4700 (LWP 13292)): #0 __pthread_kill (threadid=<optimized out>, signo=11) at ../sysdeps/unix/sysv/linux/pthread_kill.c:62 #1 0x00007f8e28432afa in my_write_core (sig=11) at /home/psergey/dev-git/10.2-r10/mysys/stacktrace.c:477 #2 0x00007f8e27cd41a8 in handle_fatal_signal (sig=11) at /home/psergey/dev-git/10.2-r10/sql/signal_handler.cc:305 #3 <signal handler called> #4 0x00007f8e2843f672 in bad_ptr (where=0x7f8e287b32fd "Freeing", ptr=0x7f8e081842a0) at /home/psergey/dev-git/10.2-r10/mysys/safemalloc.c:326 #5 0x00007f8e2843f0f5 in sf_free (ptr=0x7f8e081842a0) at /home/psergey/dev-git/10.2-r10/mysys/safemalloc.c:194 #6 0x00007f8e2842c90b in my_free (ptr=0x7f8e081842a0) at /home/psergey/dev-git/10.2-r10/mysys/my_malloc.c:217 #7 0x00007f8e2842054c in free_root (root=0x7f8e201e1eb0, MyFlags=0) at /home/psergey/dev-git/10.2-r10/mysys/my_alloc.c:392 #8 0x00007f8e28407e95 in free_defaults (argv=0x7f8e0836df90) at /home/psergey/dev-git/10.2-r10/mysys/my_default.c:652 #9 0x00007f8e27a7e3b7 in mysql_install_plugin (thd=0x7f8e08000b00, name=0x7f8e08005250, dl_arg=0x7f8e08005260) at /home/psergey/dev-git/10.2-r10/sql/sql_plugin.cc:2199 #10 0x00007f8e27a6bf87 in mysql_execute_command (thd=0x7f8e08000b00) at /home/psergey/dev-git/10.2-r10/sql/sql_parse.cc:6131 #11 0x00007f8e27a70ec8 in mysql_parse (thd=0x7f8e08000b00, rawbuf=0x7f8e080125f8 "INSTALL SONAME 'ha_rocksdb'", length=27, parser_state=0x7f8e201e3200, is_com_multi=false, is_next_command=false) at /home/psergey/dev-git/10.2-r10/sql/sql_parse.cc:7914 #12 0x00007f8e27a5ed83 in dispatch_command (command=COM_QUERY, thd=0x7f8e08000b00, packet=0x7f8e0816a951 "INSTALL SONAME 'ha_rocksdb'", packet_length=27, is_com_multi=false, is_next_command=false) at /home/psergey/dev-git/10.2-r10/sql/sql_parse.cc:1815 #13 0x00007f8e27a5d6e6 in do_command (thd=0x7f8e08000b00) at /home/psergey/dev-git/10.2-r10/sql/sql_parse.cc:1369 #14 0x00007f8e27babfa0 in do_handle_one_connection (connect=0x7f8e29c0e0b0) at /home/psergey/dev-git/10.2-r10/sql/sql_connect.cc:1335 #15 0x00007f8e27babd2d in handle_one_connection (arg=0x7f8e29c0e0b0) at /home/psergey/dev-git/10.2-r10/sql/sql_connect.cc:1241 #16 0x00007f8e2803aafe in pfs_spawn_thread (arg=0x7f8e29bf10a0) at /home/psergey/dev-git/10.2-r10/storage/perfschema/pfs.cc:1862 #17 0x00007f8e259a86aa in start_thread (arg=0x7f8e201e4700) at pthread_create.c:333 #18 0x00007f8e24eb0eed in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109
            psergei Sergei Petrunia added a comment - - edited

            The data that gets corrupted was allocated here:

              $172 = {
                0x5555564c6f7e <alloc_root+487>, 
                0x5555564b028b <init_default_directories+68>, 
                0x5555564ae73b <my_load_defaults+168>, 
                0x555555b251b8 <mysql_install_plugin(THD*, st_mysql_lex_string const*, st_mysql_lex_string const*)+572>, 
                0x555555b12f87 <mysql_execute_command(THD*)+41983>, 
                0x555555b17ec8 <mysql_parse(THD*, char*, unsigned int, Parser_state*, bool, bool)+671>, 
                0x1000, 
                0x100000000a}
            

            The location where memory gets corrupted:

            (gdb) wher
              #0  init_one_value (option=0x7fff802277c8, variable=0x7fff80024ca0, value=0) at /home/psergey/dev-git/10.2-r10/mysys/my_getopt.c:1266
              #1  0x00005555564cec22 in init_variables (options=0x7fff802277c8, func_init_one_value=0x5555564ce8c4 <init_one_value>) at /home/psergey/dev-git/10.2-r10/mysys/my_getopt.c:1387
              #2  0x00005555564cc046 in handle_options (argc=0x7ffff40abf7c, argv=0x7ffff40abd40, longopts=0x7fff802232a8, get_one_option=0x555555b2a645 <mark_changed(int, my_option const*, char*)>) at /home/psergey/dev-git/10.2-r10/mysys/my_getopt.c:216
              #3  0x0000555555b2ad4a in test_plugin_options (tmp_root=0x7fff80005c58, tmp=0x5555579ac288, argc=0x7ffff40abf7c, argv=0x7fff8001ed28) at /home/psergey/dev-git/10.2-r10/sql/sql_plugin.cc:4073
              #4  0x0000555555b22d18 in plugin_initialize (tmp_root=0x7fff80005c58, plugin=0x5555579ac288, argc=0x7ffff40abf7c, argv=0x7fff8001ed20, options_only=false) at /home/psergey/dev-git/10.2-r10/sql/sql_plugin.cc:1403
              #5  0x0000555555b24d39 in finalize_install (thd=0x7fff80000b00, table=0x7fff80018430, name=0x7ffff40abfc0, argc=0x7ffff40abf7c, argv=0x7fff8001ed20) at /home/psergey/dev-git/10.2-r10/sql/sql_plugin.cc:2080
              #6  0x0000555555b25339 in mysql_install_plugin (thd=0x7fff80000b00, name=0x7fff80005250, dl_arg=0x7fff80005260) at /home/psergey/dev-git/10.2-r10/sql/sql_plugin.cc:2187
              #7  0x0000555555b12f87 in mysql_execute_command (thd=0x7fff80000b00) at /home/psergey/dev-git/10.2-r10/sql/sql_parse.cc:6131
              #8  0x0000555555b17ec8 in mysql_parse (thd=0x7fff80000b00, rawbuf=0x7fff800111c8 "INSTALL SONAME 'ha_rocksdb'", length=27, parser_state=0x7ffff40ad250, is_com_multi=false, is_next_command=false) at /home/psergey/dev-git/10.2-r10/sql/sql_parse.cc:7914
              #9  0x0000555555b05d83 in dispatch_command (command=COM_QUERY, thd=0x7fff80000b00, packet=0x7fff800089e1 "INSTALL SONAME 'ha_rocksdb'", packet_length=27, is_com_multi=false, is_next_command=false) at /home/psergey/dev-git/10.2-r10/sql/sql_parse.cc:1815
            

            We are initializing this option (doesn't seem to be any special, it may be a different option if the testcase changes slightly):

            (gdb) p *option
              $189 = {name = 0x7fff800129a8 "rocksdb-whole-key-filtering", id = 0, comment = 0x7fff87ac7860 "BlockBasedTableOptions::whole_key_filtering for RocksDB", value = 0x7fff80024ca0, u_max_value = 0x7fff80024ca0, typelib = 0x555556ebada0 <bool_typelib>, var_type = 2, arg_type = REQUIRED_ARG, def_value = 1, min_value = 0, max_value = 0, sub_size = 0, block_size = 0, app_type = 0x7fff8023ff08}
            

            psergei Sergei Petrunia added a comment - - edited The data that gets corrupted was allocated here: $172 = { 0x5555564c6f7e <alloc_root+487>, 0x5555564b028b <init_default_directories+68>, 0x5555564ae73b <my_load_defaults+168>, 0x555555b251b8 <mysql_install_plugin(THD*, st_mysql_lex_string const*, st_mysql_lex_string const*)+572>, 0x555555b12f87 <mysql_execute_command(THD*)+41983>, 0x555555b17ec8 <mysql_parse(THD*, char*, unsigned int, Parser_state*, bool, bool)+671>, 0x1000, 0x100000000a} The location where memory gets corrupted: (gdb) wher #0 init_one_value (option=0x7fff802277c8, variable=0x7fff80024ca0, value=0) at /home/psergey/dev-git/10.2-r10/mysys/my_getopt.c:1266 #1 0x00005555564cec22 in init_variables (options=0x7fff802277c8, func_init_one_value=0x5555564ce8c4 <init_one_value>) at /home/psergey/dev-git/10.2-r10/mysys/my_getopt.c:1387 #2 0x00005555564cc046 in handle_options (argc=0x7ffff40abf7c, argv=0x7ffff40abd40, longopts=0x7fff802232a8, get_one_option=0x555555b2a645 <mark_changed(int, my_option const*, char*)>) at /home/psergey/dev-git/10.2-r10/mysys/my_getopt.c:216 #3 0x0000555555b2ad4a in test_plugin_options (tmp_root=0x7fff80005c58, tmp=0x5555579ac288, argc=0x7ffff40abf7c, argv=0x7fff8001ed28) at /home/psergey/dev-git/10.2-r10/sql/sql_plugin.cc:4073 #4 0x0000555555b22d18 in plugin_initialize (tmp_root=0x7fff80005c58, plugin=0x5555579ac288, argc=0x7ffff40abf7c, argv=0x7fff8001ed20, options_only=false) at /home/psergey/dev-git/10.2-r10/sql/sql_plugin.cc:1403 #5 0x0000555555b24d39 in finalize_install (thd=0x7fff80000b00, table=0x7fff80018430, name=0x7ffff40abfc0, argc=0x7ffff40abf7c, argv=0x7fff8001ed20) at /home/psergey/dev-git/10.2-r10/sql/sql_plugin.cc:2080 #6 0x0000555555b25339 in mysql_install_plugin (thd=0x7fff80000b00, name=0x7fff80005250, dl_arg=0x7fff80005260) at /home/psergey/dev-git/10.2-r10/sql/sql_plugin.cc:2187 #7 0x0000555555b12f87 in mysql_execute_command (thd=0x7fff80000b00) at /home/psergey/dev-git/10.2-r10/sql/sql_parse.cc:6131 #8 0x0000555555b17ec8 in mysql_parse (thd=0x7fff80000b00, rawbuf=0x7fff800111c8 "INSTALL SONAME 'ha_rocksdb'", length=27, parser_state=0x7ffff40ad250, is_com_multi=false, is_next_command=false) at /home/psergey/dev-git/10.2-r10/sql/sql_parse.cc:7914 #9 0x0000555555b05d83 in dispatch_command (command=COM_QUERY, thd=0x7fff80000b00, packet=0x7fff800089e1 "INSTALL SONAME 'ha_rocksdb'", packet_length=27, is_com_multi=false, is_next_command=false) at /home/psergey/dev-git/10.2-r10/sql/sql_parse.cc:1815 We are initializing this option (doesn't seem to be any special, it may be a different option if the testcase changes slightly): (gdb) p *option $189 = {name = 0x7fff800129a8 "rocksdb-whole-key-filtering", id = 0, comment = 0x7fff87ac7860 "BlockBasedTableOptions::whole_key_filtering for RocksDB", value = 0x7fff80024ca0, u_max_value = 0x7fff80024ca0, typelib = 0x555556ebada0 <bool_typelib>, var_type = 2, arg_type = REQUIRED_ARG, def_value = 1, min_value = 0, max_value = 0, sub_size = 0, block_size = 0, app_type = 0x7fff8023ff08}

            Trying to narrow down the corruption:

            This is my_getopt.c,

              case GET_BOOL:
                *((my_bool*) variable)= (my_bool) value;
            

            in

            static void init_one_value(const struct my_option *option, void *variable,
            			   longlong value)
            

            which is called from init_variables():

                /*
                  We must set u_max_value first as for some variables
                  options->u_max_value == options->value and in this case we want to
                  set the value to default value.
                */
                if (options->u_max_value)
                  func_init_one_value(options, options->u_max_value, options->max_value);
            

            Seems like options->u_max_value has the wrong value?

            psergei Sergei Petrunia added a comment - Trying to narrow down the corruption: This is my_getopt.c, case GET_BOOL: *((my_bool*) variable)= (my_bool) value; in static void init_one_value(const struct my_option *option, void *variable, longlong value) which is called from init_variables(): /* We must set u_max_value first as for some variables options->u_max_value == options->value and in this case we want to set the value to default value. */ if (options->u_max_value) func_init_one_value(options, options->u_max_value, options->max_value); Seems like options->u_max_value has the wrong value?

            The value of u_max_value is set here in sql_plugin.cc, construct_options:

                  options->value= options->u_max_value= *(uchar***) (opt + 1);
            

            This looks a bit odd as options comes from here

            static int construct_options(MEM_ROOT *mem_root, struct st_plugin_int *tmp,
                                         my_option *options)
            

            include/my_getopt.h has struct my_option which has

              void       *u_max_value;              /**< The user def. max variable value */
            

            Note that it's void*, not uchar**.

            psergei Sergei Petrunia added a comment - The value of u_max_value is set here in sql_plugin.cc , construct_options : options->value= options->u_max_value= *(uchar***) (opt + 1); This looks a bit odd as options comes from here static int construct_options(MEM_ROOT *mem_root, struct st_plugin_int *tmp, my_option *options) include/my_getopt.h has struct my_option which has void *u_max_value; /**< The user def. max variable value */ Note that it's void*, not uchar** .

            ... opt comes from here:

            st_mysql_sys_var *opt,
            

            ...

              for (plugin_option= tmp->plugin->system_vars;
                   plugin_option && *plugin_option; plugin_option++, index++)
              {
                opt= *plugin_option;
            

            and the function has "interesting" things like:

                  *(int*)(opt + 1)= offset= v->offset;
            

            psergei Sergei Petrunia added a comment - ... opt comes from here: st_mysql_sys_var *opt, ... for (plugin_option= tmp->plugin->system_vars; plugin_option && *plugin_option; plugin_option++, index++) { opt= *plugin_option; and the function has "interesting" things like: *( int *)(opt + 1)= offset= v->offset;

            Ok, running this under ASAN produces a clear report:

            ==28053==ERROR: AddressSanitizer: heap-use-after-free on address 0x61500002e980 at pc 0x5622f1709b0d bp 0x7fe1c2bf02e0 sp 0x7fe1c2bf02d0
            WRITE of size 1 at 0x61500002e980 thread T6
                #0 0x5622f1709b0c in init_one_value /home/ubuntu/mariadb-10.2/mysys/my_getopt.c:1265
                #1 0x5622f170a3a5 in init_variables /home/ubuntu/mariadb-10.2/mysys/my_getopt.c:1387
                #2 0x5622f1703a3e in handle_options /home/ubuntu/mariadb-10.2/mysys/my_getopt.c:216
                #3 0x5622f01c4043 in test_plugin_options /home/ubuntu/mariadb-10.2/sql/sql_plugin.cc:4073
                #4 0x5622f01b169f in plugin_initialize /home/ubuntu/mariadb-10.2/sql/sql_plugin.cc:1403
                #5 0x5622f01b536b in finalize_install /home/ubuntu/mariadb-10.2/sql/sql_plugin.cc:2080
                #6 0x5622f01b62c2 in mysql_install_plugin(THD*, st_mysql_lex_string const*, st_mysql_lex_string const*) /home/ubuntu/mariadb-10.2/sql/sql_plugin.cc:2187
                #7 0x5622f018c1da in mysql_execute_command(THD*) /home/ubuntu/mariadb-10.2/sql/sql_parse.cc:6130
                #8 0x5622f0196b6f in mysql_parse(THD*, char*, unsigned int, Parser_state*, bool, bool) /home/ubuntu/mariadb-10.2/sql/sql_parse.cc:7914
                #9 0x5622f0172840 in dispatch_command(enum_server_command, THD*, char*, unsigned int, bool, bool) /home/ubuntu/mariadb-10.2/sql/sql_parse.cc:1815
                #10 0x5622f016f9f4 in do_command(THD*) /home/ubuntu/mariadb-10.2/sql/sql_parse.cc:1369
                #11 0x5622f048c824 in do_handle_one_connection(CONNECT*) /home/ubuntu/mariadb-10.2/sql/sql_connect.cc:1335
                #12 0x5622f048c22c in handle_one_connection /home/ubuntu/mariadb-10.2/sql/sql_connect.cc:1241
                #13 0x5622f151ae19 in pfs_spawn_thread /home/ubuntu/mariadb-10.2/storage/perfschema/pfs.cc:1862
                #14 0x7fe1cd2716b9 in start_thread (/lib/x86_64-linux-gnu/libpthread.so.0+0x76b9)
                #15 0x7fe1cc70641c in clone (/lib/x86_64-linux-gnu/libc.so.6+0x10741c)
            

            0x61500002e980 is located 0 bytes inside of 504-byte region [0x61500002e980,0x61500002eb78)
            freed by thread T6 here:
                #0 0x7fe1cea55b2a in operator delete(void*) (/usr/lib/x86_64-linux-gnu/libasan.so.2+0x99b2a)
                #1 0x7fe1c18a726d in std::default_delete<rocksdb::DBOptions>::operator()(rocksdb::DBOptions*) const (/home/ubuntu/mariadb-10.2/mysql-test/var/plugins/ha_rocksdb.so+0xaa326d)
                #2 0x7fe1c18ab6ee in std::unique_ptr<rocksdb::DBOptions, std::default_delete<rocksdb::DBOptions> >::reset(rocksdb::DBOptions*) (/home/ubuntu/mariadb-10.2/mysql-test/var/plugins/ha_rocksdb.so+0xaa76ee)
                #3 0x7fe1c18a0110 in std::unique_ptr<rocksdb::DBOptions, std::default_delete<rocksdb::DBOptions> >::operator=(decltype(nullptr)) (/home/ubuntu/mariadb-10.2/mysql-test/var/plugins/ha_rocksdb.so+0xa9c110)
                #4 0x7fe1c183a510 in rocksdb_done_func /home/ubuntu/mariadb-10.2/storage/rocksdb/ha_rocksdb.cc:4508
                #5 0x5622f072799e in ha_finalize_handlerton(st_plugin_int*) /home/ubuntu/mariadb-10.2/sql/handler.cc:468
                #6 0x5622f01affb1 in plugin_deinitialize /home/ubuntu/mariadb-10.2/sql/sql_plugin.cc:1219
                #7 0x5622f01b0ab4 in reap_plugins /home/ubuntu/mariadb-10.2/sql/sql_plugin.cc:1295
                #8 0x5622f01b73c9 in mysql_uninstall_plugin(THD*, st_mysql_lex_string const*, st_mysql_lex_string const*) /home/ubuntu/mariadb-10.2/sql/sql_plugin.cc:2333
                #9 0x5622f018c276 in mysql_execute_command(THD*) /home/ubuntu/mariadb-10.2/sql/sql_parse.cc:6135
                #10 0x5622f0196b6f in mysql_parse(THD*, char*, unsigned int, Parser_state*, bool, bool) /home/ubuntu/mariadb-10.2/sql/sql_parse.cc:7914
                #11 0x5622f0172840 in dispatch_command(enum_server_command, THD*, char*, unsigned int, bool, bool) /home/ubuntu/mariadb-10.2/sql/sql_parse.cc:1815
                #12 0x5622f016f9f4 in do_command(THD*) /home/ubuntu/mariadb-10.2/sql/sql_parse.cc:1369
                #13 0x5622f048c824 in do_handle_one_connection(CONNECT*) /home/ubuntu/mariadb-10.2/sql/sql_connect.cc:1335
                #14 0x5622f048c22c in handle_one_connection /home/ubuntu/mariadb-10.2/sql/sql_connect.cc:1241
                #15 0x5622f151ae19 in pfs_spawn_thread /home/ubuntu/mariadb-10.2/storage/perfschema/pfs.cc:1862
                #16 0x7fe1cd2716b9 in start_thread (/lib/x86_64-linux-gnu/libpthread.so.0+0x76b9)
            

            previously allocated by thread T6 here:
                #0 0x7fe1cea55532 in operator new(unsigned long) (/usr/lib/x86_64-linux-gnu/libasan.so.2+0x99532)
                #1 0x7fe1c183026d in rdb_init_rocksdb_db_options /home/ubuntu/mariadb-10.2/storage/rocksdb/ha_rocksdb.cc:507
                #2 0x7fe1c1875ba9 in __static_initialization_and_destruction_0 /home/ubuntu/mariadb-10.2/storage/rocksdb/ha_rocksdb.cc:523
                #3 0x7fe1c1878e39 in _GLOBAL__sub_I_ha_rocksdb.cc /home/ubuntu/mariadb-10.2/storage/rocksdb/ha_rocksdb.cc:12591
                #4 0x7fe1cf9396b9  (/lib64/ld-linux-x86-64.so.2+0x106b9)
            

            psergei Sergei Petrunia added a comment - Ok, running this under ASAN produces a clear report: ==28053==ERROR: AddressSanitizer: heap-use-after-free on address 0x61500002e980 at pc 0x5622f1709b0d bp 0x7fe1c2bf02e0 sp 0x7fe1c2bf02d0 WRITE of size 1 at 0x61500002e980 thread T6 #0 0x5622f1709b0c in init_one_value /home/ubuntu/mariadb-10.2/mysys/my_getopt.c:1265 #1 0x5622f170a3a5 in init_variables /home/ubuntu/mariadb-10.2/mysys/my_getopt.c:1387 #2 0x5622f1703a3e in handle_options /home/ubuntu/mariadb-10.2/mysys/my_getopt.c:216 #3 0x5622f01c4043 in test_plugin_options /home/ubuntu/mariadb-10.2/sql/sql_plugin.cc:4073 #4 0x5622f01b169f in plugin_initialize /home/ubuntu/mariadb-10.2/sql/sql_plugin.cc:1403 #5 0x5622f01b536b in finalize_install /home/ubuntu/mariadb-10.2/sql/sql_plugin.cc:2080 #6 0x5622f01b62c2 in mysql_install_plugin(THD*, st_mysql_lex_string const*, st_mysql_lex_string const*) /home/ubuntu/mariadb-10.2/sql/sql_plugin.cc:2187 #7 0x5622f018c1da in mysql_execute_command(THD*) /home/ubuntu/mariadb-10.2/sql/sql_parse.cc:6130 #8 0x5622f0196b6f in mysql_parse(THD*, char*, unsigned int, Parser_state*, bool, bool) /home/ubuntu/mariadb-10.2/sql/sql_parse.cc:7914 #9 0x5622f0172840 in dispatch_command(enum_server_command, THD*, char*, unsigned int, bool, bool) /home/ubuntu/mariadb-10.2/sql/sql_parse.cc:1815 #10 0x5622f016f9f4 in do_command(THD*) /home/ubuntu/mariadb-10.2/sql/sql_parse.cc:1369 #11 0x5622f048c824 in do_handle_one_connection(CONNECT*) /home/ubuntu/mariadb-10.2/sql/sql_connect.cc:1335 #12 0x5622f048c22c in handle_one_connection /home/ubuntu/mariadb-10.2/sql/sql_connect.cc:1241 #13 0x5622f151ae19 in pfs_spawn_thread /home/ubuntu/mariadb-10.2/storage/perfschema/pfs.cc:1862 #14 0x7fe1cd2716b9 in start_thread (/lib/x86_64-linux-gnu/libpthread.so.0+0x76b9) #15 0x7fe1cc70641c in clone (/lib/x86_64-linux-gnu/libc.so.6+0x10741c) 0x61500002e980 is located 0 bytes inside of 504-byte region [0x61500002e980,0x61500002eb78) freed by thread T6 here: #0 0x7fe1cea55b2a in operator delete(void*) (/usr/lib/x86_64-linux-gnu/libasan.so.2+0x99b2a) #1 0x7fe1c18a726d in std::default_delete<rocksdb::DBOptions>::operator()(rocksdb::DBOptions*) const (/home/ubuntu/mariadb-10.2/mysql-test/var/plugins/ha_rocksdb.so+0xaa326d) #2 0x7fe1c18ab6ee in std::unique_ptr<rocksdb::DBOptions, std::default_delete<rocksdb::DBOptions> >::reset(rocksdb::DBOptions*) (/home/ubuntu/mariadb-10.2/mysql-test/var/plugins/ha_rocksdb.so+0xaa76ee) #3 0x7fe1c18a0110 in std::unique_ptr<rocksdb::DBOptions, std::default_delete<rocksdb::DBOptions> >::operator=(decltype(nullptr)) (/home/ubuntu/mariadb-10.2/mysql-test/var/plugins/ha_rocksdb.so+0xa9c110) #4 0x7fe1c183a510 in rocksdb_done_func /home/ubuntu/mariadb-10.2/storage/rocksdb/ha_rocksdb.cc:4508 #5 0x5622f072799e in ha_finalize_handlerton(st_plugin_int*) /home/ubuntu/mariadb-10.2/sql/handler.cc:468 #6 0x5622f01affb1 in plugin_deinitialize /home/ubuntu/mariadb-10.2/sql/sql_plugin.cc:1219 #7 0x5622f01b0ab4 in reap_plugins /home/ubuntu/mariadb-10.2/sql/sql_plugin.cc:1295 #8 0x5622f01b73c9 in mysql_uninstall_plugin(THD*, st_mysql_lex_string const*, st_mysql_lex_string const*) /home/ubuntu/mariadb-10.2/sql/sql_plugin.cc:2333 #9 0x5622f018c276 in mysql_execute_command(THD*) /home/ubuntu/mariadb-10.2/sql/sql_parse.cc:6135 #10 0x5622f0196b6f in mysql_parse(THD*, char*, unsigned int, Parser_state*, bool, bool) /home/ubuntu/mariadb-10.2/sql/sql_parse.cc:7914 #11 0x5622f0172840 in dispatch_command(enum_server_command, THD*, char*, unsigned int, bool, bool) /home/ubuntu/mariadb-10.2/sql/sql_parse.cc:1815 #12 0x5622f016f9f4 in do_command(THD*) /home/ubuntu/mariadb-10.2/sql/sql_parse.cc:1369 #13 0x5622f048c824 in do_handle_one_connection(CONNECT*) /home/ubuntu/mariadb-10.2/sql/sql_connect.cc:1335 #14 0x5622f048c22c in handle_one_connection /home/ubuntu/mariadb-10.2/sql/sql_connect.cc:1241 #15 0x5622f151ae19 in pfs_spawn_thread /home/ubuntu/mariadb-10.2/storage/perfschema/pfs.cc:1862 #16 0x7fe1cd2716b9 in start_thread (/lib/x86_64-linux-gnu/libpthread.so.0+0x76b9) previously allocated by thread T6 here: #0 0x7fe1cea55532 in operator new(unsigned long) (/usr/lib/x86_64-linux-gnu/libasan.so.2+0x99532) #1 0x7fe1c183026d in rdb_init_rocksdb_db_options /home/ubuntu/mariadb-10.2/storage/rocksdb/ha_rocksdb.cc:507 #2 0x7fe1c1875ba9 in __static_initialization_and_destruction_0 /home/ubuntu/mariadb-10.2/storage/rocksdb/ha_rocksdb.cc:523 #3 0x7fe1c1878e39 in _GLOBAL__sub_I_ha_rocksdb.cc /home/ubuntu/mariadb-10.2/storage/rocksdb/ha_rocksdb.cc:12591 #4 0x7fe1cf9396b9 (/lib64/ld-linux-x86-64.so.2+0x106b9)

            The above was fixed by not freeing rocksdb_db_options and rocksdb_tbl_options. Plugin's system variables point to the objects behind these two smart pointers, so they must not be freed until there's a chance that they are used.

            psergei Sergei Petrunia added a comment - The above was fixed by not freeing rocksdb_db_options and rocksdb_tbl_options . Plugin's system variables point to the objects behind these two smart pointers, so they must not be freed until there's a chance that they are used.

            http://buildbot.askmonty.org/buildbot/builders/mac-1012-bintar/builds/3153/steps/test/logs/stdio

            rocksdb.mariadb_plugin                   [ fail ]
                    Test ended at 2018-03-28 21:43:11
             
            CURRENT_TEST: rocksdb.mariadb_plugin
            mysqltest: At line 38: query 'INSTALL SONAME 'ha_rocksdb'' succeeded - should have failed with errno 1815...
             
            The result from queries just before the failure was:
            < snip >
            # MDEV-14843: Assertion `s_tx_list.size() == 0' failed in myrocks::Rdb_transaction::term_mutex
            #
            INSTALL SONAME 'ha_rocksdb';
            CREATE TABLE t1 (i INT) ENGINE=RocksDB;
            insert into t1 values (1);
            connect  con1,localhost,root,,;
            connection con1;
            insert into test.t1 values (1);
            connection default;
            DROP TABLE t1;
            UNINSTALL SONAME 'ha_rocksdb';
            #
            # MDEV-15686: Loading MyRocks plugin back after it has been unloaded causes a crash
            #
            call mtr.add_suppression("Plugin 'ROCKSDB.*' init function returned error.");
            call mtr.add_suppression("Plugin 'ROCKSDB.*' registration as a INFORMATION SCHEMA failed.");
            call mtr.add_suppression("Plugin 'ROCKSDB' registration as a STORAGE ENGINE failed");
            INSTALL SONAME 'ha_rocksdb';
            
            

            psergei Sergei Petrunia added a comment - http://buildbot.askmonty.org/buildbot/builders/mac-1012-bintar/builds/3153/steps/test/logs/stdio rocksdb.mariadb_plugin [ fail ] Test ended at 2018-03-28 21:43:11   CURRENT_TEST: rocksdb.mariadb_plugin mysqltest: At line 38: query 'INSTALL SONAME 'ha_rocksdb'' succeeded - should have failed with errno 1815...   The result from queries just before the failure was: < snip > # MDEV-14843: Assertion `s_tx_list.size() == 0' failed in myrocks::Rdb_transaction::term_mutex # INSTALL SONAME 'ha_rocksdb'; CREATE TABLE t1 (i INT) ENGINE=RocksDB; insert into t1 values (1); connect con1,localhost,root,,; connection con1; insert into test.t1 values (1); connection default; DROP TABLE t1; UNINSTALL SONAME 'ha_rocksdb'; # # MDEV-15686: Loading MyRocks plugin back after it has been unloaded causes a crash # call mtr.add_suppression("Plugin 'ROCKSDB.*' init function returned error."); call mtr.add_suppression("Plugin 'ROCKSDB.*' registration as a INFORMATION SCHEMA failed."); call mtr.add_suppression("Plugin 'ROCKSDB' registration as a STORAGE ENGINE failed"); INSTALL SONAME 'ha_rocksdb';

            Apparently on mac, unloading the plugin means that plugin's internal global variables are reset as well (that is, .so is unmapped?). In this case, loading it back succeeds but that is ok because its state is completely reset.

            psergei Sergei Petrunia added a comment - Apparently on mac, unloading the plugin means that plugin's internal global variables are reset as well (that is, .so is unmapped?). In this case, loading it back succeeds but that is ok because its state is completely reset.

            Pushed another cset to address this.

            psergei Sergei Petrunia added a comment - Pushed another cset to address this.

            People

              psergei Sergei Petrunia
              psergei Sergei Petrunia
              Votes:
              0 Vote for this issue
              Watchers:
              1 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.