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

Assertion `strlen(Ptr) == str_length' failed

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Critical
    • Resolution: Duplicate
    • 12.1
    • N/A
    • JSON
    • None
    • Can result in hang or crash

    Description

      SET SESSION sql_buffer_result=1;
      CREATE TABLE t (a JSON);
      ALTER TABLE t CONVERT TO CHARACTER SET ucs2 COLLATE ucs2_czech_ci;
      INSERT INTO t SELECT '[1,[2,[3,[4,[5,[6,[7,[8,[9,[1,[1,[1,[1,[1,[1,[1,[1,[1,[1,[1,[1,[1,[1,[1,[1,[1,[1,[1,[1,[1,[1,[1,[1,[1,[1,[1,[1,[1,[1,[1,[1,[1,[1,[1,[1,[1,[1,[1,[1,[1,[1,[1,[1,[1,[1,[1,[1,[1,[1,[1,[1,[1,[1,[1,[1,[1,[1,[1,[1,[1,[1,[1,[1,[1,[1,[1,[1,[1,[1,[1,[1,[1,[1,[1,[1,[1,[1,[1,[1,[1,[1,[1,[1,[1,[1,[1,[1,[1,[1,[1]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]' FROM seq_1_to_1;
      SELECT JSON_DETAILED (a) FROM t;
      SELECT JSON_DETAILED (a) FROM t;
      

      Leads to :-

      bb-12.1-json_depth_unlimited CS 12.1.0 725532989637af2a0a3e35862d25737fb0dae21f (Debug) Build 25/06/2025

      mariadbd: /test/bb-12.1-json_depth_unlimited_dbg/sql/sql_string.h:362: void Binary_string::chop(): Assertion `strlen(Ptr) == str_length' failed.
      

      Stacktrace

      Core was generated by `/test/bb-12.1-json_depth_unlimited_MD250625-mariadb-12.1.0-linux-x86_64-dbg/bin'.
      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 3337873)]
      (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  0x00007606f644527e in __GI_raise (sig=sig@entry=6)at ../sysdeps/posix/raise.c:26
      #4  0x00007606f64288ff in __GI_abort () at ./stdlib/abort.c:79
      #5  0x00007606f642881b in __assert_fail_base (fmt=0x7606f65d01e8 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=assertion@entry=0x5bdf058adc4f "strlen(Ptr) == str_length", file=file@entry=0x5bdf058ab1f0 "/test/bb-12.1-json_depth_unlimited_dbg/sql/sql_string.h", line=line@entry=362, function=function@entry=0x5bdf058adc69 "void Binary_string::chop()")at ./assert/assert.c:96
      #6  0x00007606f643b517 in __assert_fail (assertion=0x5bdf058adc4f "strlen(Ptr) == str_length", file=0x5bdf058ab1f0 "/test/bb-12.1-json_depth_unlimited_dbg/sql/sql_string.h", line=362, function=0x5bdf058adc69 "void Binary_string::chop()")at ./assert/assert.c:105
      #7  0x00005bdf0471848e in Binary_string::chop (this=0x7605cc01a608)at /test/bb-12.1-json_depth_unlimited_dbg/sql/sql_string.h:362
      #8  0x00005bdf04ad8279 in json_nice (je=0x7605cc01a6b0, nice_js=0x7605cc01a600, mode=Item_func_json_format::DETAILED, tab_size=4)at /test/bb-12.1-json_depth_unlimited_dbg/sql/item_jsonfunc.cc:454
      #9  0x00005bdf04ae3557 in Item_func_json_format::val_str (this=0x7605cc01a5d8, str=0x7605cc01a600)at /test/bb-12.1-json_depth_unlimited_dbg/sql/item_jsonfunc.cc:4659
      #10 0x00005bdf04cd1a1c in Item::save_str_in_field (this=0x7605cc01a5d8, field=0x7605cc0f26b8, no_conversions=true)at /test/bb-12.1-json_depth_unlimited_dbg/sql/item.cc:7158
      #11 0x00005bdf04b41810 in Type_handler_string_result::Item_save_in_field (this=0x5bdf064c6ed8 <type_handler_long_blob_json>, item=0x7605cc01a5d8, field=0x7605cc0f26b8, no_conversions=true)at /test/bb-12.1-json_depth_unlimited_dbg/sql/sql_type.cc:4431
      #12 0x00005bdf04cd1ec5 in Item::save_in_field (this=0x7605cc01a5d8, field=0x7605cc0f26b8, no_conversions=true)at /test/bb-12.1-json_depth_unlimited_dbg/sql/item.cc:7216
      #13 0x00005bdf046f9a1e in Item_result_field::save_in_result_field (this=0x7605cc01a5d8, no_conversions=true)at /test/bb-12.1-json_depth_unlimited_dbg/sql/item.h:3611
      #14 0x00005bdf0491e4c8 in copy_funcs (func_ptr=0x7605cc0f2390, thd=0x7605cc000d58)at /test/bb-12.1-json_depth_unlimited_dbg/sql/sql_select.cc:30073
      #15 0x00005bdf0491af6b in end_write (join=0x7605cc01b890, join_tab=0x7605cc01d4f0, end_of_records=false)at /test/bb-12.1-json_depth_unlimited_dbg/sql/sql_select.cc:26064
      #16 0x00005bdf04927afa in AGGR_OP::put_record (this=0x7605cc01e358, end_of_records=false)at /test/bb-12.1-json_depth_unlimited_dbg/sql/sql_select.cc:33564
      #17 0x00005bdf04939327 in AGGR_OP::put_record (this=0x7605cc01e358)at /test/bb-12.1-json_depth_unlimited_dbg/sql/sql_select.h:1204
      #18 0x00005bdf048f1319 in sub_select_postjoin_aggr (join=0x7605cc01b890, join_tab=0x7605cc01d4f0, end_of_records=false)at /test/bb-12.1-json_depth_unlimited_dbg/sql/sql_select.cc:24126
      #19 0x00005bdf0491c1fd in evaluate_join_record (join=0x7605cc01b890, join_tab=0x7605cc01d078, error=0)at /test/bb-12.1-json_depth_unlimited_dbg/sql/sql_select.cc:24675
      #20 0x00005bdf048cfa2e in sub_select (join=0x7605cc01b890, join_tab=0x7605cc01d078, end_of_records=false)at /test/bb-12.1-json_depth_unlimited_dbg/sql/sql_select.cc:24442
      #21 0x00005bdf048f6fb5 in do_select (join=0x7605cc01b890, procedure=0x0)at /test/bb-12.1-json_depth_unlimited_dbg/sql/sql_select.cc:23953
      #22 0x00005bdf048f6361 in JOIN::exec_inner (this=0x7605cc01b890)at /test/bb-12.1-json_depth_unlimited_dbg/sql/sql_select.cc:5068
      #23 0x00005bdf048f555e in JOIN::exec (this=0x7605cc01b890)at /test/bb-12.1-json_depth_unlimited_dbg/sql/sql_select.cc:4856
      #24 0x00005bdf048d035d in mysql_select (thd=0x7605cc000d58, tables=0x7605cc01a7f0, fields=@0x7605cc01a240: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x7605cc01a768, last = 0x7605cc01a768, elements = 1}, <No data fields>}, conds=0x0, og_num=0, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=2164656896, result=0x7605cc01b868, unit=0x7605cc005150, select_lex=0x7605cc019f88)at /test/bb-12.1-json_depth_unlimited_dbg/sql/sql_select.cc:5384
      #25 0x00005bdf048cfde5 in handle_select (thd=0x7605cc000d58, lex=0x7605cc005070, result=0x7605cc01b868, setup_tables_done_option=0)at /test/bb-12.1-json_depth_unlimited_dbg/sql/sql_select.cc:634
      #26 0x00005bdf04877b01 in execute_sqlcom_select (thd=0x7605cc000d58, all_tables=0x7605cc01a7f0)at /test/bb-12.1-json_depth_unlimited_dbg/sql/sql_parse.cc:6166
      #27 0x00005bdf0486c94e in mysql_execute_command (thd=0x7605cc000d58, is_called_from_prepared_stmt=false)at /test/bb-12.1-json_depth_unlimited_dbg/sql/sql_parse.cc:3954
      #28 0x00005bdf04864bf4 in mysql_parse (thd=0x7605cc000d58, rawbuf=0x7605cc019ef0 "SELECT JSON_DETAILED (a) FROM t", length=31, parser_state=0x7606d02b1a10)at /test/bb-12.1-json_depth_unlimited_dbg/sql/sql_parse.cc:7882
      #29 0x00005bdf04861fc8 in dispatch_command (command=COM_QUERY, thd=0x7605cc000d58, packet=0x7605cc00b269 "", packet_length=31, blocking=true)at /test/bb-12.1-json_depth_unlimited_dbg/sql/sql_parse.cc:1877
      #30 0x00005bdf048657a3 in do_command (thd=0x7605cc000d58, blocking=true)at /test/bb-12.1-json_depth_unlimited_dbg/sql/sql_parse.cc:1416
      #31 0x00005bdf04a51439 in do_handle_one_connection (connect=0x5bdf1ff1e178, put_in_cache=true)at /test/bb-12.1-json_depth_unlimited_dbg/sql/sql_connect.cc:1414
      #32 0x00005bdf04a511de in handle_one_connection (arg=0x5bdf1ffdeb18)at /test/bb-12.1-json_depth_unlimited_dbg/sql/sql_connect.cc:1326
      #33 0x00007606f649caa4 in start_thread (arg=<optimized out>)at ./nptl/pthread_create.c:447
      #34 0x00007606f6529c3c in clone3 ()at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:78
      

      Attachments

        Issue Links

          Activity

            People

              rucha174 Rucha Deodhar
              saahil Saahil Alam
              Votes:
              0 Vote for this issue
              Watchers:
              2 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.