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

Assertion `is_json_type_handler(th)' failed in static const Type_handler *Type_handler_json_common::json_type_handler_from_generic(const Type_handler *)

    XMLWordPrintable

Details

    • Bug
    • Status: Open (View Workflow)
    • Critical
    • Resolution: Unresolved
    • 12.0(EOL), 12.1
    • 12.1
    • JSON

    Description

      SELECT NULLIF(CASE WHEN 1 THEN NULL ELSE JSON_ARRAY() END,1);
      

      Leads to:

      CS 12.0.1 51c0afcd248ad57095fdcf56efec2865ea49bd83 (Debug) Build 07/05/2025

      mariadbd: /test/12.0_dbg/sql/sql_type_json.cc:59: static const Type_handler *Type_handler_json_common::json_type_handler_from_generic(const Type_handler *): Assertion `is_json_type_handler(th)' failed.
      

      CS 12.0.1 51c0afcd248ad57095fdcf56efec2865ea49bd83 (Debug) Build 07/05/2025

      Core was generated by `/test/MD070525-mariadb-12.0.1-linux-x86_64-dbg/bin/mariadbd --no-defaults --max'.
      Program terminated with signal SIGABRT, Aborted.
      Download failed: Invalid argument.  Continuing without source file ./nptl/./nptl/pthread_kill.c.
      #0  __pthread_kill_implementation (no_tid=0, signo=6, threadid=<optimized out>)at ./nptl/pthread_kill.c:44
       
      [Current thread is 1 (LWP 3914166)]
      (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  0x0000732dad64527e in __GI_raise (sig=sig@entry=6)at ../sysdeps/posix/raise.c:26
      #4  0x0000732dad6288ff in __GI_abort () at ./stdlib/abort.c:79
      #5  0x0000732dad62881b in __assert_fail_base (fmt=0x732dad7d01e8 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=assertion@entry=0x5bc0675f3300 "is_json_type_handler(th)", file=file@entry=0x5bc0675f32dc "/test/12.0_dbg/sql/sql_type_json.cc", line=line@entry=59, function=function@entry=0x5bc0675f3319 "static const Type_handler *Type_handler_json_common::json_type_handler_from_generic(const Type_handler *)")at ./assert/assert.c:96
      #6  0x0000732dad63b517 in __assert_fail (assertion=0x5bc0675f3300 "is_json_type_handler(th)", file=0x5bc0675f32dc "/test/12.0_dbg/sql/sql_type_json.cc", line=59, function=0x5bc0675f3319 "static const Type_handler *Type_handler_json_common::json_type_handler_from_generic(const Type_handler *)")at ./assert/assert.c:105
      #7  0x00005bc06684603a in Type_handler_json_common::json_type_handler_from_generic (th=0x5bc0681958d0 <type_handler_double>)at /test/12.0_dbg/sql/sql_type_json.cc:59
      #8  0x00005bc0668470c5 in Type_handler_general_purpose_string_to_json<Type_handler_varchar, type_handler_varchar>::Item_hybrid_func_fix_attributes (this=0x5bc068195cb0 <type_handler_varchar_json>, thd=0x731290000d58, name=@0x732da412f2f8: {str = 0x5bc06762d2f4 "nullif", length = 6}, hybrid=0x73129001ab90, attr=0x73129001aae0, items=0x73129001ad28, nitems=1)at /test/12.0_dbg/sql/sql_type_json.h:106
      #9  0x00005bc0669d5cdb in Item_func_nullif::fix_length_and_dec (this=0x73129001aae0, thd=0x731290000d58)at /test/12.0_dbg/sql/item_cmpfunc.cc:2729
      #10 0x00005bc066a15503 in Item_func::fix_fields (this=0x73129001aae0, thd=0x731290000d58, ref=0x73129001ad48)at /test/12.0_dbg/sql/item_func.cc:380
      #11 0x00005bc06640482a in Item::fix_fields_if_needed (this=0x73129001aae0, thd=0x731290000d58, ref=0x73129001ad48) at /test/12.0_dbg/sql/item.h:1113
      #12 0x00005bc066403779 in Item::fix_fields_if_needed_for_scalar (this=0x73129001aae0, thd=0x731290000d58, ref=0x73129001ad48)at /test/12.0_dbg/sql/item.h:1122
      #13 0x00005bc06648bb21 in setup_fields (thd=0x731290000d58, ref_pointer_array={m_array = 0x73129001bee0, m_size = 8}, fields=@0x73129001a3f0: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x73129001ad40, last = 0x73129001ad40, elements = 1}, <No data fields>}, column_usage=MARK_COLUMNS_READ, sum_func_list=0x73129001bac0, pre_fix=0x73129001a408, allow_sum_func=true, where=THD_WHERE::DEFAULT_WHERE) at /test/12.0_dbg/sql/sql_base.cc:8120
      #14 0x00005bc0665b584a in JOIN::prepare (this=0x73129001b718, tables_init=0x0, conds_init=0x0, og_num=0, order_init=0x0, skip_order_by=false, group_init=0x0, having_init=0x0, proc_param_init=0x0, select_lex_arg=0x73129001a138, unit_arg=0x731290005148)at /test/12.0_dbg/sql/sql_select.cc:1584
      #15 0x00005bc0665b11c9 in mysql_select (thd=0x731290000d58, tables=0x0, fields=@0x73129001a3f0: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x73129001ad40, last = 0x73129001ad40, elements = 1}, <No data fields>}, conds=0x0, og_num=0, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=2164525824, result=0x73129001b6f0, unit=0x731290005148, select_lex=0x73129001a138) at /test/12.0_dbg/sql/sql_select.cc:5365
      #16 0x00005bc0665b0d55 in handle_select (thd=0x731290000d58, lex=0x731290005068, result=0x73129001b6f0, setup_tables_done_option=0)at /test/12.0_dbg/sql/sql_select.cc:634
      #17 0x00005bc066558a61 in execute_sqlcom_select (thd=0x731290000d58, all_tables=0x0) at /test/12.0_dbg/sql/sql_parse.cc:6166
      #18 0x00005bc06654d8ae in mysql_execute_command (thd=0x731290000d58, is_called_from_prepared_stmt=false) at /test/12.0_dbg/sql/sql_parse.cc:3954
      #19 0x00005bc066545b34 in mysql_parse (thd=0x731290000d58, rawbuf=0x73129001a060 "SELECT NULLIF(CASE WHEN 1 THEN NULL ELSE JSON_ARRAY() END,1)", length=60, parser_state=0x732da4131a10)at /test/12.0_dbg/sql/sql_parse.cc:7891
      #20 0x00005bc066542f08 in dispatch_command (command=COM_QUERY, thd=0x731290000d58, packet=0x73129000b259 "SELECT NULLIF(CASE WHEN 1 THEN NULL ELSE JSON_ARRAY() END,1)", packet_length=60, blocking=true)at /test/12.0_dbg/sql/sql_parse.cc:1877
      #21 0x00005bc0665466e3 in do_command (thd=0x731290000d58, blocking=true)at /test/12.0_dbg/sql/sql_parse.cc:1416
      #22 0x00005bc066731bd9 in do_handle_one_connection (connect=0x5bc076f2f008, put_in_cache=true) at /test/12.0_dbg/sql/sql_connect.cc:1414
      #23 0x00005bc06673197e in handle_one_connection (arg=0x5bc077013eb8)at /test/12.0_dbg/sql/sql_connect.cc:1326
      #24 0x0000732dad69caa4 in start_thread (arg=<optimized out>)at ./nptl/pthread_create.c:447
      #25 0x0000732dad729c3c 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  280425  c461188ca6ad6ec3a54201eb87ebd75797d296df  No bug found
      CS  10.5   opt  280425  c461188ca6ad6ec3a54201eb87ebd75797d296df  No bug found
      CS  10.6   dbg  280425  19644f6821d59ecca0f9b1f44fadb3b887061965  No bug found
      CS  10.6   opt  280425  19644f6821d59ecca0f9b1f44fadb3b887061965  No bug found
      CS  10.11  dbg  280425  4d41ec081e34671a1997ce797dcb9f7b7997437e  No bug found
      CS  10.11  opt  280425  4d41ec081e34671a1997ce797dcb9f7b7997437e  No bug found
      CS  11.4   dbg  220425  820114bd2515759224f925528c8201e6155334fb  No bug found
      CS  11.4   opt  220425  820114bd2515759224f925528c8201e6155334fb  No bug found
      CS  11.8   dbg  220425  805e7ca3adef50e17889ea17a1b86da6c3fb8580  No bug found
      CS  11.8   opt  220425  805e7ca3adef50e17889ea17a1b86da6c3fb8580  No bug found
      CS  12.0   dbg  070525  51c0afcd248ad57095fdcf56efec2865ea49bd83  is_json_type_handler(th)|SIGABRT|Type_handler_json_common::json_type_handler_from_generic|Type_handler_general_purpose_string_to_json<Type_handler_varchar, type_handler_varchar>::Item_hybrid_func_fix_attributes|Item_func_nullif::fix_length_and_dec|Item_func::fix_fields
      CS  12.0   opt  070525  51c0afcd248ad57095fdcf56efec2865ea49bd83  No bug found
      ES  10.5   dbg  050525  0d368ec0042a81d9549fc939fb742f82350b20ab  No bug found
      ES  10.5   opt  050525  0d368ec0042a81d9549fc939fb742f82350b20ab  No bug found
      ES  10.6   dbg  050525  6111fbaf7bdcb6f1170f556ffd05d6e1a4159f62  No bug found
      ES  10.6   opt  050525  6111fbaf7bdcb6f1170f556ffd05d6e1a4159f62  No bug found
      ES  11.4   dbg  050525  9cd12544ebfd0d52d2158af66b5aced58121cf1f  No bug found
      ES  11.4   opt  050525  9cd12544ebfd0d52d2158af66b5aced58121cf1f  No bug found
      

      The assertion happens after this commit

      commit c5d8b9963a670e24a0cb8ed3b73561e50fa87a36 (HEAD, origin/bb-12.0-bar-MDEV-36716)
      Author: Alexander Barkov <bar@mariadb.com>
      Date:   Wed Apr 30 14:04:43 2025 +0400
       
          MDEV-36716 A case expression with ROW arguments in THEN crashes
       
          The patch for SYS_REFCURSOR (MDEV-20034) overrode these methods:
          - Item_func_case_searched::check_arguments()
          - Item_func_if::check_arguments()
      

      Attachments

        Issue Links

          Activity

            People

              bar Alexander Barkov
              ramesh Ramesh Sivaraman
              Votes:
              0 Vote for this issue
              Watchers:
              3 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.