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

SIGSEGV & UBASAN null-pointer-use in myrocks::Rdb_transaction_impl::get_write_batch on opt builds

    XMLWordPrintable

Details

    Description

      Different from MDEV-24706 (which the below testcase also triggers, upon the CREATE TABLE but only in debug builds), we have:

      INSTALL SONAME 'ha_rocksdb';
      SET sql_mode='';
      CREATE OR REPLACE TABLE mysql.general_log (c INT) ENGINE=RocksDB;
      SET GLOBAL log_output='TABLE', GLOBAL general_log=TRUE;
      CREATE TABLE t (c INT) ENGINE=RocksDB;  # Debug crash, i.e. MDEV-24706
      XA START 'x';
      INSERT INTO t VALUES (1);
      XA END 'x';
      SET autocommit=0;
      XA COMMIT 'x' ONE PHASE;  # Optimized builds crash, i.e. the bug described in this ticket, MDEV-36611
      

      Leading to (note optimized builds only):

      CS 10.11.12 acd071f599f416ddb4821dec485c4d912844213f (Optimized) Build 12/04/2025

      Core was generated by `/test/MD120425-mariadb-10.11.12-linux-x86_64-opt/bin/mariadbd --no-defaults --m'.
      Program terminated with signal SIGSEGV, Segmentation fault.
      #0  0x00007e7a7842620f in myrocks::Rdb_transaction_impl::get_write_batch (this=<optimized out>) at /test/10.11_opt/storage/rocksdb/ha_rocksdb.cc:3134
      3134	  bool is_two_phase() const { return m_is_two_phase; }
      [Current thread is 1 (LWP 1134505)]
      (gdb) bt
      #0  0x00007e7a7842620f in myrocks::Rdb_transaction_impl::get_write_batch (this=<optimized out>) at /test/10.11_opt/storage/rocksdb/ha_rocksdb.cc:3134
      #1  0x00007e7a7842d6fa in myrocks::Rdb_transaction::make_stmt_savepoint_permanent (this=0x0, this@entry=0x7e79b825e150)at /test/10.11_opt/storage/rocksdb/ha_rocksdb.cc:3071
      #2  0x00007e7a7841573f in myrocks::rocksdb_commit (hton=<optimized out>, thd=0x7e79b8000c68, commit_tx=false)at /test/10.11_opt/storage/rocksdb/ha_rocksdb.cc:4247
      #3  0x000065082eea19b0 in commit_one_phase_2 (thd=thd@entry=0x7e79b8000c68, all=false, trans=0x7e79b8004518, is_real_trans=true)at /test/10.11_opt/sql/handler.cc:2160
      #4  0x000065082eea1464 in ha_commit_one_phase (thd=0x7e79b8000c68, all=false)at /test/10.11_opt/sql/handler.cc:2111
      #5  ha_commit_trans (thd=thd@entry=0x7e79b8000c68, all=false)at /test/10.11_opt/sql/handler.cc:1903
      #6  0x000065082ed8913a in trans_commit_stmt (thd=thd@entry=0x7e79b8000c68)at /test/10.11_opt/sql/transaction.cc:501
      #7  0x000065082ec5be41 in mysql_execute_command (thd=thd@entry=0x7e79b8000c68, is_called_from_prepared_stmt=<optimized out>)at /test/10.11_opt/sql/sql_parse.cc:6225
      #8  0x000065082ec53c11 in mysql_parse (thd=thd@entry=0x7e79b8000c68, rawbuf=<optimized out>, length=<optimized out>, parser_state=parser_state@entry=0x7e7aa1bfe480)at /test/10.11_opt/sql/sql_parse.cc:8188
      #9  0x000065082ec520cc in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x7e79b8000c68, packet=packet@entry=0x7e79b8008759 "XA COMMIT 'x' ONE PHASE", packet_length=packet_length@entry=23, blocking=true)at /test/10.11_opt/sql/sql_parse.cc:1905
      #10 0x000065082ec54021 in do_command (thd=thd@entry=0x7e79b8000c68, blocking=true) at /test/10.11_opt/sql/sql_parse.cc:1418
      #11 0x000065082ed781cd in do_handle_one_connection (connect=<optimized out>, connect@entry=0x6508323ba998, put_in_cache=true)at /test/10.11_opt/sql/sql_connect.cc:1386
      #12 0x000065082ed77f93 in handle_one_connection (arg=arg@entry=0x6508323ba998)at /test/10.11_opt/sql/sql_connect.cc:1298
      #13 0x000065082f0d664e in pfs_spawn_thread (arg=0x65083235a328)at /test/10.11_opt/storage/perfschema/pfs.cc:2201
      #14 0x00007e7aa889ca94 in start_thread (arg=<optimized out>)at ./nptl/pthread_create.c:447
      #15 0x00007e7aa8929c3c in clone3 ()at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:78
      

      Bug Detection Matrix

          Rel    o/d  Build   Commit                                    UniqueID observed             
      CS  10.5   dbg  120425  e6ea5d568c0fb972a391a8c64716846ddb7c57ef  thd->transaction->stmt.is_empty() || thd->in_sub_stmt|SIGABRT|mysql_execute_command|mysql_parse|dispatch_command|do_command
      CS  10.5   opt  120425  e6ea5d568c0fb972a391a8c64716846ddb7c57ef  SIGSEGV|myrocks::Rdb_transaction_impl::get_write_batch|myrocks::Rdb_transaction::make_stmt_savepoint_permanent|myrocks::rocksdb_commit|commit_one_phase_2
      CS  10.6   dbg  120425  690b2cf776faa2e1a6832077cec2246c86cd00bf  thd->transaction->stmt.is_empty() || thd->in_sub_stmt|SIGABRT|mysql_execute_command|mysql_parse|dispatch_command|do_command
      CS  10.6   opt  120425  690b2cf776faa2e1a6832077cec2246c86cd00bf  SIGSEGV|myrocks::Rdb_transaction_impl::get_write_batch|myrocks::Rdb_transaction::make_stmt_savepoint_permanent|myrocks::rocksdb_commit|commit_one_phase_2
      CS  10.11  dbg  120425  acd071f599f416ddb4821dec485c4d912844213f  thd->transaction->stmt.is_empty() || thd->in_sub_stmt|SIGABRT|mysql_execute_command|mysql_parse|dispatch_command|do_command
      CS  10.11  opt  120425  acd071f599f416ddb4821dec485c4d912844213f  SIGSEGV|myrocks::Rdb_transaction_impl::get_write_batch|myrocks::Rdb_transaction::make_stmt_savepoint_permanent|myrocks::rocksdb_commit|commit_one_phase_2
      CS  11.4   dbg  120425  4a701e8ce4a178faf955641caf59fc13fcc718e9  thd->transaction->stmt.is_empty() || thd->in_sub_stmt|SIGABRT|mysql_execute_command|mysql_parse|dispatch_command|do_command
      CS  11.4   opt  120425  4a701e8ce4a178faf955641caf59fc13fcc718e9  SIGSEGV|myrocks::Rdb_transaction_impl::get_write_batch|myrocks::Rdb_transaction::make_stmt_savepoint_permanent|myrocks::rocksdb_commit|commit_one_phase_2
      CS  11.8   dbg  120425  db5bb6f3339be5a49c0f397eb80a0f259f73f447  thd->transaction->stmt.is_empty() || thd->in_sub_stmt|SIGABRT|mysql_execute_command|mysql_parse|dispatch_command|do_command
      CS  11.8   opt  120425  db5bb6f3339be5a49c0f397eb80a0f259f73f447  SIGSEGV|myrocks::Rdb_transaction_impl::get_write_batch|myrocks::Rdb_transaction::make_stmt_savepoint_permanent|myrocks::rocksdb_commit|commit_one_phase_2
      CS  12.0   dbg  120425  22efc2c784e1b7199fb5804e6330168277ea7dce  thd->transaction->stmt.is_empty() || thd->in_sub_stmt|SIGABRT|mysql_execute_command|mysql_parse|dispatch_command|do_command
      CS  12.0   opt  120425  22efc2c784e1b7199fb5804e6330168277ea7dce  SIGSEGV|myrocks::Rdb_transaction_impl::get_write_batch|myrocks::Rdb_transaction::make_stmt_savepoint_permanent|myrocks::rocksdb_commit|commit_one_phase_2
      ES  10.5   dbg  120425  0d368ec0042a81d9549fc939fb742f82350b20ab  thd->transaction->stmt.is_empty() || thd->in_sub_stmt|SIGABRT|mysql_execute_command|mysql_parse|dispatch_command|do_command
      ES  10.5   opt  120425  0d368ec0042a81d9549fc939fb742f82350b20ab  SIGSEGV|myrocks::Rdb_transaction_impl::get_write_batch|myrocks::Rdb_transaction::make_stmt_savepoint_permanent|myrocks::rocksdb_commit|commit_one_phase_2
      ES  10.6   dbg  120425  74602d1b054ba6c9ee20af79d6e7807440a7a98e  thd->transaction->stmt.is_empty() || thd->in_sub_stmt|SIGABRT|mysql_execute_command|mysql_parse|dispatch_command|do_command
      ES  10.6   opt  120425  74602d1b054ba6c9ee20af79d6e7807440a7a98e  SIGSEGV|myrocks::Rdb_transaction_impl::get_write_batch|myrocks::Rdb_transaction::make_stmt_savepoint_permanent|myrocks::rocksdb_commit|commit_one_phase_2
      ES  11.4   dbg  120425  9cd12544ebfd0d52d2158af66b5aced58121cf1f  thd->transaction->stmt.is_empty() || thd->in_sub_stmt|SIGABRT|mysql_execute_command|mysql_parse|dispatch_command|do_command
      ES  11.4   opt  120425  9cd12544ebfd0d52d2158af66b5aced58121cf1f  SIGSEGV|myrocks::Rdb_transaction_impl::get_write_batch|myrocks::Rdb_transaction::make_stmt_savepoint_permanent|myrocks::rocksdb_commit|commit_one_phase_2              
      

      Note: bug also present in bb-10.11.11-mdev16253-rocksdb-6.29fb. Testcase is CLI and MTR compatible.

      Attachments

        Activity

          People

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