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

SIGSEGV in sequence_definition::read_fields when a corrupted .frm marks an ordinary table as a SEQUENCE

    XMLWordPrintable

Details

    • Can result in hang or crash

    Description

      CREATE TABLE t (c INT);
      INSERT INTO t VALUES (1);
      FLUSH TABLES;
      perl;
      open my $f, '+<', "$ENV{MYSQLTEST_VARDIR}/mysqld.1/data/test/t.frm"; seek $f, 39, 0; print $f chr(0x20); close $f;
      EOF
      SELECT * FROM t;
      

      Leads to:

      CS 12.3.4 691265a82e526e336e56c32fc8a98a74eea544f7 (Debug, Clang 18.1.3-11) Build 11/11/2026

      Core was generated by `/test/MD111126-mariadb-12.3.4-linux-x86_64-dbg/bin/mariadbd --no-defaults --loo'.
      Program terminated with signal SIGSEGV, Segmentation fault.
      #0  0x00005d9fa198a68f in sequence_definition::read_fields (this=0x708e240342d0, table=0x708e240603f0)at /test/12.3_dbg/sql/sql_sequence.cc:292
       
      [Current thread is 1 (LWP 639821)]
      (gdb) bt
      #0  0x00005d9fa198a68f in sequence_definition::read_fields (this=0x708e240342d0, table=0x708e240603f0)at /test/12.3_dbg/sql/sql_sequence.cc:292
      #1  0x00005d9fa198c176 in SEQUENCE::read_stored_values (this=0x708e240342d0, table=0x708e240603f0) at /test/12.3_dbg/sql/sql_sequence.cc:755
      #2  0x00005d9fa198bf01 in SEQUENCE::read_initial_values (this=0x708e240342d0, table=0x708e240603f0) at /test/12.3_dbg/sql/sql_sequence.cc:679
      #3  0x00005d9fa1e81bde in ha_sequence::open (this=0x708e24029310, name=0x708e240342a0 "./test/t", mode=2, flags=18)at /test/12.3_dbg/sql/ha_sequence.cc:123
      #4  0x00005d9fa1abc864 in handler::ha_open (this=0x708e24029310, table_arg=0x708e240603f0, name=0x708e240342a0 "./test/t", mode=2, test_if_locked=18, mem_root=0x0, partitions_to_open=0x0)at /test/12.3_dbg/sql/handler.cc:4014
      #5  0x00005d9fa17e9653 in open_table_from_share (thd=0x708e24000d60, share=0x708e24033be0, alias=0x708e2401af50, db_stat=33, prgflag=8, ha_open_flags=18, outparam=0x708e240603f0, is_create_table=false, partitions_to_open=0x0) at /test/12.3_dbg/sql/table.cc:4830
      #6  0x00005d9fa158139e in open_table (thd=0x708e24000d60, table_list=0x708e2401af00, ot_ctx=0x788f40bd7c28)at /test/12.3_dbg/sql/sql_base.cc:2320
      #7  0x00005d9fa1586f0d in open_and_process_table (thd=0x708e24000d60, tables=0x708e2401af00, counter=0x788f40bd7cdc, flags=0, prelocking_strategy=0x788f40bd7d40, has_prelocking_list=false, ot_ctx=0x788f40bd7c28) at /test/12.3_dbg/sql/sql_base.cc:4298
      #8  0x00005d9fa1585ac0 in open_tables (thd=0x708e24000d60, options=@0x708e2400687c: {m_options = DDL_options_st::OPT_NONE}, start=0x788f40bd7cf0, counter=0x788f40bd7cdc, flags=0, prelocking_strategy=0x788f40bd7d40) at /test/12.3_dbg/sql/sql_base.cc:4781
      #9  0x00005d9fa158911d in open_and_lock_tables (thd=0x708e24000d60, options=@0x708e2400687c: {m_options = DDL_options_st::OPT_NONE}, tables=0x708e2401af00, derived=true, flags=0, prelocking_strategy=0x788f40bd7d40) at /test/12.3_dbg/sql/sql_base.cc:5809
      #10 0x00005d9fa1598a9e in open_and_lock_tables (thd=0x708e24000d60, tables=0x708e2401af00, derived=true, flags=0)at /test/12.3_dbg/sql/sql_base.h:545
      #11 0x00005d9fa165f73e in execute_sqlcom_select (thd=0x708e24000d60, all_tables=0x708e2401af00) at /test/12.3_dbg/sql/sql_parse.cc:6134
      #12 0x00005d9fa1654bf9 in mysql_execute_command (thd=0x708e24000d60, is_called_from_prepared_stmt=false) at /test/12.3_dbg/sql/sql_parse.cc:3990
      #13 0x00005d9fa164cd44 in mysql_parse (thd=0x708e24000d60, rawbuf=0x708e2401a800 "SELECT * FROM t", length=15, parser_state=0x788f40bd9ab0) at /test/12.3_dbg/sql/sql_parse.cc:7947
      #14 0x00005d9fa164a12d in dispatch_command (command=COM_QUERY, thd=0x708e24000d60, packet=0x708e2400b631 "SELECT * FROM t", packet_length=15, blocking=true) at /test/12.3_dbg/sql/sql_parse.cc:1903
      #15 0x00005d9fa164d8f3 in do_command (thd=0x708e24000d60, blocking=true)at /test/12.3_dbg/sql/sql_parse.cc:1437
      #16 0x00005d9fa184eb89 in do_handle_one_connection (connect=0x5d9fd72b1240, put_in_cache=true) at /test/12.3_dbg/sql/sql_connect.cc:1529
      #17 0x00005d9fa184e92e in handle_one_connection (arg=0x5d9fd721eda0)at /test/12.3_dbg/sql/sql_connect.cc:1441
      #18 0x0000788f6909cb84 in start_thread (arg=<optimized out>)at ./nptl/pthread_create.c:447
      #19 0x0000788f69129ecc in clone3 ()at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:78
      

      Bug Detection Matrix

          Rel    o/d  Build   Commit                                    UniqueID observed
      CS  10.11  dbg  031126  8034c5bcaf3da89151cdae2a22e10d07aba5de45  SIGSEGV|sequence_definition::read_fields|SEQUENCE::read_stored_values|SEQUENCE::read_initial_values|ha_sequence::open
      CS  10.11  opt  031126  8034c5bcaf3da89151cdae2a22e10d07aba5de45  SIGSEGV|sequence_definition::read_fields|SEQUENCE::read_stored_values|SEQUENCE::read_initial_values|ha_sequence::open
      CS  11.4   dbg  031126  3060a8806d76b7e7379925b2f0e46d65054011ae  SIGSEGV|sequence_definition::read_fields|SEQUENCE::read_stored_values|SEQUENCE::read_initial_values|ha_sequence::open
      CS  11.4   opt  031126  3060a8806d76b7e7379925b2f0e46d65054011ae  SIGSEGV|sequence_definition::read_fields|SEQUENCE::read_stored_values|SEQUENCE::read_initial_values|ha_sequence::open
      CS  11.8   dbg  031126  ebde32c352878e57a73853a926eb9be99be91217  SIGSEGV|sequence_definition::read_fields|SEQUENCE::read_stored_values|SEQUENCE::read_initial_values|ha_sequence::open
      CS  11.8   opt  031126  ebde32c352878e57a73853a926eb9be99be91217  SIGSEGV|sequence_definition::read_fields|SEQUENCE::read_stored_values|SEQUENCE::read_initial_values|ha_sequence::open
      CS  12.3   dbg  111126  691265a82e526e336e56c32fc8a98a74eea544f7  SIGSEGV|sequence_definition::read_fields|SEQUENCE::read_stored_values|SEQUENCE::read_initial_values|ha_sequence::open
      CS  12.3   opt  111126  691265a82e526e336e56c32fc8a98a74eea544f7  SIGSEGV|sequence_definition::read_fields|SEQUENCE::read_stored_values|SEQUENCE::read_initial_values|ha_sequence::open
      CS  13.1   dbg  041126  5290908f05d1b580cf2bc17dee3c7a8527ae2a53  SIGSEGV|sequence_definition::read_fields|SEQUENCE::read_stored_values|SEQUENCE::read_initial_values|ha_sequence::open
      CS  13.1   opt  041126  5290908f05d1b580cf2bc17dee3c7a8527ae2a53  SIGSEGV|sequence_definition::read_fields|SEQUENCE::read_stored_values|SEQUENCE::read_initial_values|ha_sequence::open
      CS  13.2   dbg  301026  5104ebf86a1015cb96cbf50c37c7659a45d92d54  SIGSEGV|sequence_definition::read_fields|SEQUENCE::read_stored_values|SEQUENCE::read_initial_values|ha_sequence::open
      CS  13.2   opt  301026  5104ebf86a1015cb96cbf50c37c7659a45d92d54  SIGSEGV|sequence_definition::read_fields|SEQUENCE::read_stored_values|SEQUENCE::read_initial_values|ha_sequence::open
      ES  11.4   dbg  060526  90f707057d44f1b5c013a0c3672fd12f32ea7085  SIGSEGV|sequence_definition::read_fields|SEQUENCE::read_stored_values|SEQUENCE::read_initial_values|ha_sequence::open
      ES  11.4   opt  060526  90f707057d44f1b5c013a0c3672fd12f32ea7085  SIGSEGV|sequence_definition::read_fields|SEQUENCE::read_stored_values|SEQUENCE::read_initial_values|ha_sequence::open
      ES  11.8   dbg  060526  1499789de285a8109d68d79347de0281865b28f4  SIGSEGV|sequence_definition::read_fields|SEQUENCE::read_stored_values|SEQUENCE::read_initial_values|ha_sequence::open
      ES  11.8   opt  060526  1499789de285a8109d68d79347de0281865b28f4  SIGSEGV|sequence_definition::read_fields|SEQUENCE::read_stored_values|SEQUENCE::read_initial_values|ha_sequence::open
      ES  12.3   dbg  280926  082387a5f3cbb877157998bb4baa95928f4aa121  SIGSEGV|sequence_definition::read_fields|SEQUENCE::read_stored_values|SEQUENCE::read_initial_values|ha_sequence::open
      ES  12.3   opt  280926  082387a5f3cbb877157998bb4baa95928f4aa121  SIGSEGV|sequence_definition::read_fields|SEQUENCE::read_stored_values|SEQUENCE::read_initial_values|ha_sequence::open
      

      Attachments

        Activity

          People

            sanja Oleksandr Byelkin
            ramesh Ramesh Sivaraman
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0d
                0d
                Logged:
                Time Spent - 0.25h
                0.25h

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.