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

CHECK TABLE corrupts latin7 table, server hangs

    XMLWordPrintable

Details

    Description

      CREATE TABLE t (c CHAR(16) NOT NULL, KEY(c)) ENGINE=MyISAM CHARACTER SET latin7 COLLATE latin7_general_ci;
      INSERT INTO t VALUES ('-'),('');
      SELECT * FROM t;
      CHECK TABLE t;
      SELECT * FROM t;
       
      DROP TABLE t;
      

      main 637f8c4db7533fc4f22433f042cc83f7ba3bfb41

      SELECT * FROM t;
      c
       
      -
      CHECK TABLE t;
      Table	Op	Msg_type	Msg_text
      test.t	check	error	Key in wrong position at page 1024
      test.t	check	error	Corrupt
      SELECT * FROM t;
      

      The second SELECT hangs, or rather loops at 100% CPU, somewhere in

      main d755574c47f101917aee29ea847e214c24c92c0b

      Thread 6 (Thread 0x7f46af7d06c0 (LWP 1606720) "one_connection"):
      #0  0x0000564ee9f872a8 in my_convert (to=0x629000131219 "-ef\004test\001t\001t\001c\001c", to_length=1, to_cs=0x564ef9f61bc0 <my_charset_latin1>, from=0x6250002741a9 "-", ' ' <repeats 15 times>, '\276' <repeats 39 times>, "\230B'", from_length=1, from_cs=0x564ef9f41950 <compiled_charsets+5200>, errors=0x7f46af7cbee0) at /data/bld/main-asan-ubsan/strings/ctype.c:1276
      #1  0x0000564ee56c561f in copy_and_convert (errors=0x7f46af7cbee0, from_cs=0x564ef9f41950 <compiled_charsets+5200>, from_length=1, from=0x6250002741a9 "-", ' ' <repeats 15 times>, '\276' <repeats 39 times>, "\230B'", to_cs=0x564ef9f61bc0 <my_charset_latin1>, to_length=1, to=0x629000131219 "-ef\004test\001t\001t\001c\001c") at /data/bld/main-asan-ubsan/sql/sql_string.h:53
      #2  Protocol::net_store_data_cs (this=0x62c0000b08f8, from=<optimized out>, length=<optimized out>, from_cs=0x564ef9f41950 <compiled_charsets+5200>, to_cs=<optimized out>) at /data/bld/main-asan-ubsan/sql/protocol.cc:114
      #3  0x0000564ee56daa2b in Protocol::store_string_aux (this=this@entry=0x62c0000b08f8, from=from@entry=0x6250002741a9 "-", ' ' <repeats 15 times>, '\276' <repeats 39 times>, "\230B'", length=length@entry=1, fromcs=fromcs@entry=0x564ef9f41950 <compiled_charsets+5200>, tocs=tocs@entry=0x564ef9f61bc0 <my_charset_latin1>) at /data/bld/main-asan-ubsan/sql/protocol.cc:1460
      #4  0x0000564ee56daeb2 in Protocol_text::store_str (this=this@entry=0x62c0000b08f8, from=from@entry=0x6250002741a9 "-", ' ' <repeats 15 times>, '\276' <repeats 39 times>, "\230B'", length=length@entry=1, fromcs=fromcs@entry=0x564ef9f41950 <compiled_charsets+5200>, tocs=0x564ef9f61bc0 <my_charset_latin1>) at /data/bld/main-asan-ubsan/sql/protocol.cc:1499
      #5  0x0000564ee56eefba in Protocol::store (this=this@entry=0x62c0000b08f8, from=0x6250002741a9 "-", ' ' <repeats 15 times>, '\276' <repeats 39 times>, "\230B'", length=1, cs=0x564ef9f41950 <compiled_charsets+5200>) at /data/bld/main-asan-ubsan/sql/protocol.h:153
      #6  0x0000564ee74a2042 in Field_longstr::send (this=0x625000274298, protocol=<optimized out>) at /data/bld/main-asan-ubsan/sql/field.cc:7504
      #7  0x0000564ee56c9b7c in Protocol_text::store (this=0x62c0000b08f8, field=0x625000274298) at /data/bld/main-asan-ubsan/sql/protocol.cc:1615
      #8  0x0000564ee7699145 in Item_field::send (this=0x62d0000fce38, protocol=0x62c0000b08f8, buffer=<optimized out>) at /data/bld/main-asan-ubsan/sql/item.cc:7971
      #9  0x0000564ee56d9ab3 in Protocol::send_result_set_row (this=this@entry=0x62c0000b08f8, row_items=row_items@entry=0x62d0000fa778) at /data/bld/main-asan-ubsan/sql/protocol.cc:1358
      #10 0x0000564ee5a8b7a7 in select_send::send_data (this=0x62d0000fc608, items=...) at /data/bld/main-asan-ubsan/sql/sql_class.cc:3411
      #11 0x0000564ee5ab0ecb in select_result_sink::send_data_with_check (this=this@entry=0x62d0000fc608, items=..., u=u@entry=0x62c0000b4938, sent=sent@entry=22795206) at /data/bld/main-asan-ubsan/sql/sql_class.cc:3309
      #12 0x0000564ee6094279 in end_send (join=0x62d0000fc638, join_tab=0x62d0000fe340, end_of_records=<optimized out>) at /data/bld/main-asan-ubsan/sql/sql_select.cc:25935
      #13 0x0000564ee600e781 in evaluate_join_record (join=join@entry=0x62d0000fc638, join_tab=join_tab@entry=0x62d0000fdec8, error=error@entry=0) at /data/bld/main-asan-ubsan/sql/sql_select.cc:24808
      #14 0x0000564ee6041f7b in sub_select (join=<optimized out>, join_tab=<optimized out>, end_of_records=<optimized out>) at /data/bld/main-asan-ubsan/sql/sql_select.cc:24612
      #15 0x0000564ee60e305b in do_select (join=join@entry=0x62d0000fc638, procedure=<optimized out>) at /data/bld/main-asan-ubsan/sql/sql_select.cc:24086
      #16 0x0000564ee61b77cd in JOIN::exec_inner (this=this@entry=0x62d0000fc638) at /data/bld/main-asan-ubsan/sql/sql_select.cc:5125
      #17 0x0000564ee61b7d71 in JOIN::exec (this=this@entry=0x62d0000fc638) at /data/bld/main-asan-ubsan/sql/sql_select.cc:4913
      #18 0x0000564ee61aea7c in mysql_select (thd=thd@entry=0x62c0000b0218, tables=<optimized out>, fields=..., conds=conds@entry=0x0, og_num=og_num@entry=0, order=order@entry=0x0, group=<optimized out>, having=<optimized out>, proc_param=<optimized out>, select_options=<optimized out>, result=<optimized out>, unit=<optimized out>, select_lex=<optimized out>) at /data/bld/main-asan-ubsan/sql/sql_select.cc:5439
      #19 0x0000564ee61afbc4 in handle_select (thd=thd@entry=0x62c0000b0218, lex=lex@entry=0x62c0000b4858, result=result@entry=0x62d0000fc608, setup_tables_done_option=setup_tables_done_option@entry=0) at /data/bld/main-asan-ubsan/sql/sql_select.cc:636
      #20 0x0000564ee5ddc4c8 in execute_sqlcom_select (thd=thd@entry=0x62c0000b0218, all_tables=<optimized out>) at /data/bld/main-asan-ubsan/sql/sql_parse.cc:6209
      #21 0x0000564ee5e1cb13 in mysql_execute_command (thd=thd@entry=0x62c0000b0218, is_called_from_prepared_stmt=is_called_from_prepared_stmt@entry=false) at /data/bld/main-asan-ubsan/sql/sql_parse.cc:3987
      #22 0x0000564ee5e3b0db in mysql_parse (thd=thd@entry=0x62c0000b0218, rawbuf=<optimized out>, length=<optimized out>, parser_state=parser_state@entry=0x7f46af7cea00) at /data/bld/main-asan-ubsan/sql/sql_parse.cc:7937
      #23 0x0000564ee5e441d0 in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x62c0000b0218, packet=packet@entry=0x6290002a3219 "", packet_length=packet_length@entry=15, blocking=blocking@entry=true) at /data/bld/main-asan-ubsan/sql/sql_parse.cc:1896
      #24 0x0000564ee5e51342 in do_command (thd=thd@entry=0x62c0000b0218, blocking=blocking@entry=true) at /data/bld/main-asan-ubsan/sql/sql_parse.cc:1432
      #25 0x0000564ee6800a7c in do_handle_one_connection (connect=<optimized out>, connect@entry=0x6080000082b8, put_in_cache=put_in_cache@entry=true) at /data/bld/main-asan-ubsan/sql/sql_connect.cc:1503
      #26 0x0000564ee6801be5 in handle_one_connection (arg=0x6080000082b8) at /data/bld/main-asan-ubsan/sql/sql_connect.cc:1415
      #27 0x0000564ee8788083 in pfs_spawn_thread (arg=0x617000007798) at /data/bld/main-asan-ubsan/storage/perfschema/pfs.cc:2198
      #28 0x00007f46bd0a81c4 in start_thread (arg=<optimized out>) at ./nptl/pthread_create.c:442
      #29 0x00007f46bd12885c in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:81
      

      Error log:

      2026-02-25 18:17:58 4 [ERROR] Got an error from thread_id=4, /data/bld/main-asan-ubsan/storage/myisam/ha_myisam.cc:1097
      2026-02-25 18:17:58 4 [ERROR] MariaDB thread id 4, OS thread handle 139941568644800, query id 25 localhost root Checking table
      CHECK TABLE t
      2026-02-25 18:17:58 4 [ERROR] mariadbd: Table './test/t' is marked as crashed and should be repaired
      2026-02-25 18:17:58 4 [Warning] Checking table:   './test/t'
      2026-02-25 18:17:58 4 [Warning] Recovering table: './test/t'
      2026-02-25 18:17:58 4 [Note] mariadbd: Making backup of data file ./test/t.MYD with extension '-260225181758.BAK'
      

      Reproducible (with variations in logging and stack traces) with MyISAM and Aria, not reproducible with MyISAM.

      Attachments

        Activity

          People

            gkodinov Georgi Kodinov
            elenst Elena Stepanova
            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.