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

SIGSEGVs in inline_mysql_prlock_wrlock, ilist and Assertion `ticket->m_duration == MDL_EXPLICIT' failed in MDL_context::release_lock

    XMLWordPrintable

Details

    • Not for Release Notes

    Description

      CREATE GLOBAL TEMPORARY TABLE t1 (c INT) ON COMMIT PRESERVE ROWS AS SELECT 0 'a';
      CREATE TABLE t2 (c INT);
      HANDLER t1 OPEN;
      LOCK TABLES t2 WRITE;
      LOCK TABLES t2 WRITE;
      INSERT t2 VALUES (0);
      SHUTDOWN;
      

      Leads to:

      MDEV-35915-2 CS 12.0.1 5d52514d536e9d141963f956408ac0efb4958a74 (Optimized, Clang 21.1.0-20250811) Build 06/09/2025

      Core was generated by `/test/MDEV-35915_2_MD060925-mariadb-12.0.1-linux-x86_64-opt/bin/mariadbd --no-d'.
      Program terminated with signal SIGSEGV, Segmentation fault.
      #0  inline_mysql_prlock_wrlock (that=0x190, src_line=1834, src_file=<optimized out>)at /test/bb-12.0-nikita-global-tmp_opt/include/mysql/psi/mysql_thread.h:946
       
      [Current thread is 1 (LWP 1952678)]
      (gdb) bt
      #0  inline_mysql_prlock_wrlock (that=0x190, src_line=1834, src_file=<optimized out>)at /test/bb-12.0-nikita-global-tmp_opt/include/mysql/psi/mysql_thread.h:946
      #1  MDL_lock::remove_ticket (this=0x0, pins=0x5b30bd1d2ad8, list=list@entry=&MDL_lock::m_granted, ticket=ticket@entry=0x711dbc013890)at /test/bb-12.0-nikita-global-tmp_opt/sql/mdl.cc:1834
      #2  0x00005b30bb3464d4 in MDL_context::release_lock (this=<optimized out>, duration=MDL_EXPLICIT, ticket=0x711dbc013890)at /test/bb-12.0-nikita-global-tmp_opt/sql/mdl.cc:2936
      #3  MDL_context::release_lock (this=<optimized out>, ticket=0x711dbc013890)at /test/bb-12.0-nikita-global-tmp_opt/sql/mdl.cc:2956
      #4  0x00005b30bb1a64ee in mysql_ha_close_table (handler=0x711dbc027e60)at /test/bb-12.0-nikita-global-tmp_opt/sql/sql_handler.cc:231
      #5  0x00005b30bb1a7aa5 in mysql_ha_cleanup_no_free (thd=thd@entry=0x711dbc000c68)at /test/bb-12.0-nikita-global-tmp_opt/sql/sql_handler.cc:1220
      #6  mysql_ha_cleanup (thd=thd@entry=0x711dbc000c68)at /test/bb-12.0-nikita-global-tmp_opt/sql/sql_handler.cc:1229
      #7  0x00005b30bb12f8dc in THD::cleanup (this=0x711dbc000c68)at /test/bb-12.0-nikita-global-tmp_opt/sql/sql_class.cc:1687
      #8  0x00005b30baef83ee in unlink_thd (thd=0x0, thd@entry=0x711dbc000c68)at /test/bb-12.0-nikita-global-tmp_opt/sql/mysqld.cc:2868
      #9  0x00005b30bb33a2fd in do_handle_one_connection (connect=<optimized out>, connect@entry=0x5b30bd3e2a18, put_in_cache=true)at /test/bb-12.0-nikita-global-tmp_opt/sql/sql_connect.cc:1425
      #10 0x00005b30bb33a03f in handle_one_connection (arg=arg@entry=0x5b30bd3e2a18)at /test/bb-12.0-nikita-global-tmp_opt/sql/sql_connect.cc:1326
      #11 0x00005b30bb4f87e9 in pfs_spawn_thread (arg=0x5b30bd392728)at /test/bb-12.0-nikita-global-tmp_opt/storage/perfschema/pfs.cc:2198
      #12 0x0000711eec49ca94 in start_thread (arg=<optimized out>)at ./nptl/pthread_create.c:447
      #13 0x0000711eec529c3c in clone3 ()at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:78
      

      And the debug stack matches the IN TESTING MDEV-37579.:

      MDEV-35915-2 CS 12.0.1 f88831afe2e18d124dfeaaf15ac51725a319b8e2 (Debug, Clang 21.1.0-20250811) Build 06/09/2025

      mariadbd: /test/bb-12.0-nikita-global-tmp_dbg/sql/mdl.cc:2954: void MDL_context::release_lock(MDL_ticket *): Assertion `ticket->m_duration == MDL_EXPLICIT' failed.
      

      MDEV-35915-2 CS 12.0.1 f88831afe2e18d124dfeaaf15ac51725a319b8e2 (Debug, Clang 21.1.0-20250811) Build 06/09/2025

      Core was generated by `/test/MDEV-35915_2_MD060925-mariadb-12.0.1-linux-x86_64-dbg/bin/mariadbd --no-d'.
      Program terminated with signal SIGABRT, Aborted.
      #0  __pthread_kill_implementation (no_tid=0, signo=6, threadid=<optimized out>)at ./nptl/pthread_kill.c:44
       
      [Current thread is 1 (LWP 1958944)]
      (gdb) bt
      #0  __pthread_kill_implementation (no_tid=0, signo=6, threadid=<optimized out>)at ./nptl/pthread_kill.c:44
      #1  __pthread_kill_internal (signo=6, threadid=<optimized out>)at ./nptl/pthread_kill.c:78
      #2  __GI___pthread_kill (threadid=<optimized out>, signo=signo@entry=6)at ./nptl/pthread_kill.c:89
      #3  0x0000790901e4526e in __GI_raise (sig=sig@entry=6)at ../sysdeps/posix/raise.c:26
      #4  0x0000790901e288ff in __GI_abort () at ./stdlib/abort.c:79
      #5  0x0000790901e2881b in __assert_fail_base (fmt=0x790901fd01e8 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=assertion@entry=0x5dfb74e1007c "ticket->m_duration == MDL_EXPLICIT", file=file@entry=0x5dfb74e2aa73 "/test/bb-12.0-nikita-global-tmp_dbg/sql/mdl.cc", line=line@entry=2954, function=function@entry=0x5dfb74d928c3 "void MDL_context::release_lock(MDL_ticket *)") at ./assert/assert.c:94
      #6  0x0000790901e3b507 in __assert_fail (assertion=0x5dfb74e1007c "ticket->m_duration == MDL_EXPLICIT", file=0x5dfb74e2aa73 "/test/bb-12.0-nikita-global-tmp_dbg/sql/mdl.cc", line=2954, function=0x5dfb74d928c3 "void MDL_context::release_lock(MDL_ticket *)")at ./assert/assert.c:103
      #7  0x00005dfb75b60e36 in MDL_context::release_lock (this=0x7907d4000f70, ticket=0x7907d4015f50)at /test/bb-12.0-nikita-global-tmp_dbg/sql/mdl.cc:2954
      #8  0x00005dfb7590158e in mysql_ha_close_table (handler=0x7907d40269e0)at /test/bb-12.0-nikita-global-tmp_dbg/sql/sql_handler.cc:231
      #9  0x00005dfb7590344f in mysql_ha_cleanup_no_free (thd=0x7907d4000d58)at /test/bb-12.0-nikita-global-tmp_dbg/sql/sql_handler.cc:1220
      #10 0x00005dfb75903485 in mysql_ha_cleanup (thd=0x7907d4000d58)at /test/bb-12.0-nikita-global-tmp_dbg/sql/sql_handler.cc:1229
      #11 0x00005dfb7582e994 in THD::cleanup (this=0x7907d4000d58)at /test/bb-12.0-nikita-global-tmp_dbg/sql/sql_class.cc:1687
      #12 0x00005dfb754d3e67 in unlink_thd (thd=0x7907d4000d58)at /test/bb-12.0-nikita-global-tmp_dbg/sql/mysqld.cc:2868
      #13 0x00005dfb75b4ec7c in do_handle_one_connection (connect=0x5dfb77b18038, put_in_cache=true)at /test/bb-12.0-nikita-global-tmp_dbg/sql/sql_connect.cc:1425
      #14 0x00005dfb75b4ea01 in handle_one_connection (arg=0x5dfb77a407c8)at /test/bb-12.0-nikita-global-tmp_dbg/sql/sql_connect.cc:1326
      #15 0x0000790901e9ca94 in start_thread (arg=<optimized out>)at ./nptl/pthread_create.c:447
      #16 0x0000790901f29c3c in clone3 ()at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:78
      

      Also, if SHUTDOWN is removed from the testcase, optimized builds will crash only upon CLI/client exit. For debug, the result of removing SHUTDOWN is that sometimes it does not crash and other times it crashes on the following stack. I have also seen this stack when using mariadb-admin shutdown one time:

      MDEV-35915-2 CS 12.0.1 f88831afe2e18d124dfeaaf15ac51725a319b8e2 (Debug, Clang 21.1.0-20250811) Build 06/09/2025

      Core was generated by `/test/MDEV-35915_2_MD060925-mariadb-12.0.1-linux-x86_64-dbg/bin/mariadbd --no-d'.
      Program terminated with signal SIGSEGV, Segmentation fault.
      #0  0x000057d0e5c75caf in ilist<MDL_ticket, void>::erase (this=0x57d0e7ee3128, pos=...) at /test/bb-12.0-nikita-global-tmp_dbg/include/ilist.h:192
       
      [Current thread is 1 (LWP 2691018)]
      (gdb) bt
      #0  0x000057d0e5c75caf in ilist<MDL_ticket, void>::erase (this=0x57d0e7ee3128, pos={node_ = 0x7d5e70015f58})at /test/bb-12.0-nikita-global-tmp_dbg/include/ilist.h:192
      #1  0x000057d0e5c74ab2 in ilist<MDL_ticket, void>::remove (this=0x57d0e7ee3128, value=@0x7d5e70015f50: {<MDL_wait_for_subgraph> = {_vptr$MDL_wait_for_subgraph = 0x7d59a5e27785, static _vtable$ = <optimized out>}, <ilist_node<void>> = {next = 0xb89bb768ec4944f1, prev = 0x0}, next_in_context = 0x7d5e7002bee0, prev_in_context = 0x7d5e70001070, m_duration = MDL_EXPLICIT, m_time = 0, m_type = 13, m_ctx = 0x7d5e70000f70, m_lock = 0x57d0e7ee2f20, m_psi = 0x0, static _vtable$ = <optimized out>}) at /test/bb-12.0-nikita-global-tmp_dbg/include/ilist.h:212
      #2  0x000057d0e5c70621 in MDL_lock::Ticket_list::remove_ticket (this=0x57d0e7ee3128, ticket=0x7d5e70015f50)at /test/bb-12.0-nikita-global-tmp_dbg/sql/mdl.cc:1291
      #3  0x000057d0e5c70cad in MDL_lock::remove_ticket (this=0x57d0e7ee2f20, pins=0x57d0e83003e8, list=&MDL_lock::m_granted, ticket=0x7d5e70015f50)at /test/bb-12.0-nikita-global-tmp_dbg/sql/mdl.cc:1835
      #4  0x000057d0e5c72d84 in MDL_context::release_lock (this=0x7d5e70000f70, duration=MDL_EXPLICIT, ticket=0x7d5e70015f50)at /test/bb-12.0-nikita-global-tmp_dbg/sql/mdl.cc:2936
      #5  0x000057d0e5c72e4c in MDL_context::release_lock (this=0x7d5e70000f70, ticket=0x7d5e70015f50)at /test/bb-12.0-nikita-global-tmp_dbg/sql/mdl.cc:2956
      #6  0x000057d0e5a1358e in mysql_ha_close_table (handler=0x7d5e70026ce0)at /test/bb-12.0-nikita-global-tmp_dbg/sql/sql_handler.cc:231
      #7  0x000057d0e5a1544f in mysql_ha_cleanup_no_free (thd=0x7d5e70000d58)at /test/bb-12.0-nikita-global-tmp_dbg/sql/sql_handler.cc:1220
      #8  0x000057d0e5a15485 in mysql_ha_cleanup (thd=0x7d5e70000d58)at /test/bb-12.0-nikita-global-tmp_dbg/sql/sql_handler.cc:1229
      #9  0x000057d0e5940994 in THD::cleanup (this=0x7d5e70000d58)at /test/bb-12.0-nikita-global-tmp_dbg/sql/sql_class.cc:1687
      #10 0x000057d0e55e5e67 in unlink_thd (thd=0x7d5e70000d58)at /test/bb-12.0-nikita-global-tmp_dbg/sql/mysqld.cc:2868
      #11 0x000057d0e5c60c7c in do_handle_one_connection (connect=0x57d0e85a0ea8, put_in_cache=true)at /test/bb-12.0-nikita-global-tmp_dbg/sql/sql_connect.cc:1425
      #12 0x000057d0e5c60a01 in handle_one_connection (arg=0x57d0e84c9638)at /test/bb-12.0-nikita-global-tmp_dbg/sql/sql_connect.cc:1326
      #13 0x00007d5f9d89ca94 in start_thread (arg=<optimized out>)at ./nptl/pthread_create.c:447
      #14 0x00007d5f9d929c3c in clone3 ()at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:78
      

      Attachments

        Issue Links

          Activity

            People

              Roel Roel Van de Paar
              Roel Roel Van de Paar
              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.