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

SIGSEGV in my_b_printf / MYSQL_QUERY_LOG::write when slow-logging a statement inside an anonymous BEGIN NOT ATOMIC block

    XMLWordPrintable

Details

    • Bug
    • Status: Open (View Workflow)
    • Major
    • Resolution: Unresolved
    • 12.3, 13.1, 13.2
    • 12.3, 13.1
    • Stored routines
    • None
    • Can result in hang or crash

    Description

      SET log_slow_query=ON;
      SET SESSION long_query_time=0;
      SET log_slow_disabled_statements=0;
      SET GLOBAL slow_query_log=1;
      DELIMITER //
      BEGIN NOT ATOMIC SELECT 1;END//
      DELIMITER ;
      

      Leads to:

      CS 12.3.3 0fcc374c2df8b9a7a5004b3afcc7cc42c3b7c13f (Optimized, Clang 18.1.3-11) Build 14/09/2026

      Core was generated by `/test/MD140926-mariadb-12.3.3-linux-x86_64-opt/bin/mariadbd --no-defaults --loo'.
      Program terminated with signal SIGSEGV, Segmentation fault.
      #0  __strlen_evex () at ../sysdeps/x86_64/multiarch/strlen-evex-base.S:81
       
      [Current thread is 1 (LWP 174305)]
      (gdb) bt
      #0  __strlen_evex () at ../sysdeps/x86_64/multiarch/strlen-evex-base.S:81
      #1  0x000056b87696a932 in my_b_vprintf (info=0x56b89b907540, fmt=0x56b876c052f6 "s\n", args=args@entry=0x7a68ecb66840)at /test/12.3_opt/mysys/mf_iocache2.c:437
      #2  0x000056b87696a4bb in my_b_printf (info=0x0, fmt=0x56b876c052f5 "%s\n")at /test/12.3_opt/mysys/mf_iocache2.c:333
      #3  0x000056b8765b1089 in MYSQL_QUERY_LOG::write (this=this@entry=0x56b89b907228, thd=thd@entry=0x7267fc000c70, current_time=1790660946, user_host=user_host@entry=0x7a68ecb66ea0 "root[root] @ localhost []", user_host_len=user_host_len@entry=25, query_utime=query_utime@entry=141, lock_utime=0, is_command=<optimized out>, sql_text=0x7267fc037d00 "SELECT 1", sql_text_len=8)at /test/12.3_opt/sql/log.cc:4200
      #4  0x000056b8765b0ba6 in Log_to_file_event_handler::log_slow (this=<optimized out>, thd=0x7267fc000c70, current_time={val = 1790660946710639}, user_host=0x7a68ecb66ea0 "root[root] @ localhost []", user_host_len=25, query_utime=141, lock_utime=0, is_command=<optimized out>, sql_text=0x7267fc037d00 "SELECT 1", sql_text_len=8)at /test/12.3_opt/sql/log.cc:1373
      #5  0x000056b8765b26cb in LOGGER::slow_log_print (this=0x56b87760a698 <logger>, thd=0x7267fc000c70, query=<optimized out>, query_length=<optimized out>, current_utime=<optimized out>)at /test/12.3_opt/sql/log.cc:1650
      #6  0x000056b8762266af in log_slow_statement (thd=thd@entry=0x7267fc000c70)at /test/12.3_opt/sql/sql_parse.cc:2610
      #7  0x000056b8763cd4f7 in sp_instr_stmt::execute (this=0x7267fc035a30, thd=0x7267fc000c70, nextp=0x7a68ecb67714)at /test/12.3_opt/sql/sp_instr.cc:1202
      #8  0x000056b876183efa in sp_head::execute (this=this@entry=0x7267fc0313c0, thd=thd@entry=0x7267fc000c70, merge_da_on_success=true)at /test/12.3_opt/sql/sp_head.cc:1332
      #9  0x000056b8761857db in sp_head::execute_procedure (this=0x7267fc0313c0, thd=0x7267fc000c70, args=0x7267fc006180)at /test/12.3_opt/sql/sp_head.cc:2369
      #10 0x000056b876227ff3 in do_execute_sp (thd=thd@entry=0x7267fc000c70, sp=0x0)at /test/12.3_opt/sql/sql_parse.cc:3076
      #11 0x000056b87622acf6 in mysql_execute_command (thd=thd@entry=0x7267fc000c70, is_called_from_prepared_stmt=false) at /test/12.3_opt/sql/sql_parse.cc:5651
      #12 0x000056b876224d02 in mysql_parse (thd=thd@entry=0x7267fc000c70, rawbuf=<optimized out>, length=<optimized out>, parser_state=parser_state@entry=0x7a68ecb68590)at /test/12.3_opt/sql/sql_parse.cc:7932
      #13 0x000056b87622324a in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x7267fc000c70, packet=packet@entry=0x7267fc008dc1 "", packet_length=packet_length@entry=29, blocking=true)at /test/12.3_opt/sql/sql_parse.cc:1903
      #14 0x000056b876225181 in do_command (thd=thd@entry=0x7267fc000c70, blocking=true) at /test/12.3_opt/sql/sql_parse.cc:1437
      #15 0x000056b87634d26d in do_handle_one_connection (connect=<optimized out>, connect@entry=0x56b89c187e30, put_in_cache=true)at /test/12.3_opt/sql/sql_connect.cc:1514
      #16 0x000056b87634d0a2 in handle_one_connection (arg=arg@entry=0x56b89c187e30)at /test/12.3_opt/sql/sql_connect.cc:1426
      #17 0x000056b8766eca13 in pfs_spawn_thread (arg=0x56b89c1a8590)at /test/12.3_opt/storage/perfschema/pfs.cc:2198
      #18 0x00007a68f669cb84 in start_thread (arg=<optimized out>)at ./nptl/pthread_create.c:447
      #19 0x00007a68f6729ecc in clone3 ()at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:78
      

      CS 12.3.3 0fcc374c2df8b9a7a5004b3afcc7cc42c3b7c13f (Debug, Clang 18.1.3-11) Build 14/09/2026

      Core was generated by `/test/MD140926-mariadb-12.3.3-linux-x86_64-dbg/bin/mariadbd --no-defaults --loo'.
      Program terminated with signal SIGSEGV, Segmentation fault.
      #0  __strlen_evex () at ../sysdeps/x86_64/multiarch/strlen-evex-base.S:81
       
      [Current thread is 1 (LWP 174676)]
      (gdb) bt
      #0  __strlen_evex () at ../sysdeps/x86_64/multiarch/strlen-evex-base.S:81
      #1  0x00005efc12667454 in my_b_vprintf (info=0x5efc35d91e00, fmt=0x5efc12b098d1 "s\n", args=0x7957ec1ec980)at /test/12.3_dbg/mysys/mf_iocache2.c:437
      #2  0x00005efc12666ef2 in my_b_printf (info=0x5efc35d91e00, fmt=0x5efc12b098be "# Stored_routine: %s\n")at /test/12.3_dbg/mysys/mf_iocache2.c:333
      #3  0x00005efc11eacba5 in MYSQL_QUERY_LOG::write (this=0x5efc35d91a68, thd=0x7156d8000d60, current_time=1790660946, user_host=0x7957ec1ed320 "root[root] @ localhost []", user_host_len=25, query_utime=258, lock_utime=0, is_command=false, sql_text=0x7156d80410e0 "SELECT 1", sql_text_len=8)at /test/12.3_dbg/sql/log.cc:4200
      #4  0x00005efc11eac306 in Log_to_file_event_handler::log_slow (this=0x5efc35d91530, thd=0x7156d8000d60, current_time={val = 1790660946746170}, user_host=0x7957ec1ed320 "root[root] @ localhost []", user_host_len=25, query_utime=258, lock_utime=0, is_command=false, sql_text=0x7156d80410e0 "SELECT 1", sql_text_len=8)at /test/12.3_dbg/sql/log.cc:1373
      #5  0x00005efc11eaea45 in LOGGER::slow_log_print (this=0x5efc136ed7c8 <logger>, thd=0x7156d8000d60, query=0x7156d80410e0 "SELECT 1", query_length=8, current_utime=9425127382274) at /test/12.3_dbg/sql/log.cc:1650
      #6  0x00005efc11ec4d84 in slow_log_print (thd=0x7156d8000d60, query=0x7156d80410e0 "SELECT 1", query_length=8, current_utime=9425127382274) at /test/12.3_dbg/sql/log.cc:9166
      #7  0x00005efc11897d84 in log_slow_statement (thd=0x7156d8000d60)at /test/12.3_dbg/sql/sql_parse.cc:2610
      #8  0x00005efc11b6f94e in sp_instr_stmt::execute (this=0x7156d803ee10, thd=0x7156d8000d60, nextp=0x7957ec1eda88)at /test/12.3_dbg/sql/sp_instr.cc:1202
      #9  0x00005efc1177055c in sp_head::execute (this=0x7156d803a2b0, thd=0x7156d8000d60, merge_da_on_success=true)at /test/12.3_dbg/sql/sp_head.cc:1332
      #10 0x00005efc11772f5e in sp_head::execute_procedure (this=0x7156d803a2b0, thd=0x7156d8000d60, args=0x7156d8006248)at /test/12.3_dbg/sql/sp_head.cc:2369
      #11 0x00005efc1189a2f7 in do_execute_sp (thd=0x7156d8000d60, sp=0x7156d803a2b0)at /test/12.3_dbg/sql/sql_parse.cc:3076
      #12 0x00005efc118a527c in mysql_execute_command (thd=0x7156d8000d60, is_called_from_prepared_stmt=false) at /test/12.3_dbg/sql/sql_parse.cc:5651
      #13 0x00005efc11895474 in mysql_parse (thd=0x7156d8000d60, rawbuf=0x7156d801a3f0 "BEGIN NOT ATOMIC SELECT 1;END", length=29, parser_state=0x7957ec1efab0) at /test/12.3_dbg/sql/sql_parse.cc:7932
      #14 0x00005efc1189285d in dispatch_command (command=COM_QUERY, thd=0x7156d8000d60, packet=0x7156d800b621 "", packet_length=29, blocking=true) at /test/12.3_dbg/sql/sql_parse.cc:1903
      #15 0x00005efc11896023 in do_command (thd=0x7156d8000d60, blocking=true)at /test/12.3_dbg/sql/sql_parse.cc:1437
      #16 0x00005efc11a943c9 in do_handle_one_connection (connect=0x5efc3649ed60, put_in_cache=true) at /test/12.3_dbg/sql/sql_connect.cc:1514
      #17 0x00005efc11a9416e in handle_one_connection (arg=0x5efc36484e60)at /test/12.3_dbg/sql/sql_connect.cc:1426
      #18 0x00007957f609cb84 in start_thread (arg=<optimized out>)at ./nptl/pthread_create.c:447
      #19 0x00007957f6129ecc 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  280926  f24a3ef7edd4080d4cf6e109dac26e93872068dc  No bug found
      CS  10.11  opt  280926  f24a3ef7edd4080d4cf6e109dac26e93872068dc  No bug found
      CS  11.4   dbg  140926  03acdd67d599ab7136ef18c36f3479a306870290  No bug found
      CS  11.4   opt  140926  03acdd67d599ab7136ef18c36f3479a306870290  No bug found
      CS  11.8   dbg  140926  08c28e3fbd56c26fe0973bfcc807fa95c2b23ee3  No bug found
      CS  11.8   opt  140926  08c28e3fbd56c26fe0973bfcc807fa95c2b23ee3  No bug found
      CS  12.3   dbg  140926  0fcc374c2df8b9a7a5004b3afcc7cc42c3b7c13f  SIGSEGV|__strlen_evex|my_b_vprintf|my_b_printf|MYSQL_QUERY_LOG::write
      CS  12.3   opt  140926  0fcc374c2df8b9a7a5004b3afcc7cc42c3b7c13f  SIGSEGV|__strlen_evex|my_b_vprintf|my_b_printf|MYSQL_QUERY_LOG::write
      CS  13.1   dbg  140926  e30f2bd21e463d5f5f9f9210b75193a0257b8a8c  SIGSEGV|__strlen_evex|my_b_vprintf|my_b_printf|MYSQL_QUERY_LOG::write
      CS  13.1   opt  140926  e30f2bd21e463d5f5f9f9210b75193a0257b8a8c  SIGSEGV|__strlen_evex|my_b_vprintf|my_b_printf|MYSQL_QUERY_LOG::write
      CS  13.2   dbg  240926  45717ef4c736a6a92e0acf49399ce677bfcaea89  SIGSEGV|__strlen_evex|my_b_vprintf|my_b_printf|MYSQL_QUERY_LOG::write
      CS  13.2   opt  240926  45717ef4c736a6a92e0acf49399ce677bfcaea89  SIGSEGV|__strlen_evex|my_b_vprintf|my_b_printf|MYSQL_QUERY_LOG::write
      ES  11.4   dbg  060526  90f707057d44f1b5c013a0c3672fd12f32ea7085  No bug found
      ES  11.4   opt  060526  90f707057d44f1b5c013a0c3672fd12f32ea7085  No bug found
      ES  11.8   dbg  060526  1499789de285a8109d68d79347de0281865b28f4  No bug found
      ES  11.8   opt  060526  1499789de285a8109d68d79347de0281865b28f4  No bug found
      ES  12.3   dbg  280926  082387a5f3cbb877157998bb4baa95928f4aa121  SIGSEGV|__strlen_evex|my_b_vprintf|my_b_printf|MYSQL_QUERY_LOG::write
      ES  12.3   opt  280926  082387a5f3cbb877157998bb4baa95928f4aa121  SIGSEGV|__strlen_evex|my_b_vprintf|my_b_printf|MYSQL_QUERY_LOG::write
      

      Attachments

        Activity

          People

            shulga Dmitry Shulga
            ramesh Ramesh Sivaraman
            Votes:
            0 Vote for this issue
            Watchers:
            2 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.5h
                0.5h

                Git Integration

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