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

Assertion `copied_in' failed in virtual String *Item_copy_string::val_str(String *)

    XMLWordPrintable

Details

    Description

      --source include/have_innodb.inc
       
      CREATE TABLE t1 (a TEXT, b TEXT) ENGINE=INNODB;
      INSERT INTO t1 (a) VALUES (1);
      FLUSH TABLES WITH READ LOCK;
      SELECT (SELECT (SELECT t1.a)) aa, COUNT(DISTINCT b) FROM t1 GROUP BY aa; 
      

      Leads to:

      CS 10.6.22 19644f6821d59ecca0f9b1f44fadb3b887061965 (Debug) Build 28/04/2025

      mariadbd: /test/10.6_dbg/sql/item.cc:5330: virtual String *Item_copy_string::val_str(String *): Assertion `copied_in' failed.
      

      CS 10.6.22 19644f6821d59ecca0f9b1f44fadb3b887061965 (Debug) Build 28/04/2025

      Core was generated by `/test/MD280425-mariadb-10.6.22-linux-x86_64-dbg/bin/mariadbd --no-defaults --ma'.
      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 (Thread 0xe2660fb46c0 (LWP 1969614))]
      (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  0x00000e266dc4527e in __GI_raise (sig=sig@entry=6)at ../sysdeps/posix/raise.c:26
      #4  0x00000e266dc288ff in __GI_abort () at ./stdlib/abort.c:79
      #5  0x00000e266dc2881b in __assert_fail_base (fmt=0xe266ddd01e8 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=assertion@entry=0x651126d7aa1d "copied_in", file=file@entry=0x651126dac134 "/test/10.6_dbg/sql/item.cc", line=line@entry=5330, function=function@entry=0x651126dad83b "virtual String *Item_copy_string::val_str(String *)") at ./assert/assert.c:96
      #6  0x00000e266dc3b517 in __assert_fail (assertion=0x651126d7aa1d "copied_in", file=0x651126dac134 "/test/10.6_dbg/sql/item.cc", line=5330, function=0x651126dad83b "virtual String *Item_copy_string::val_str(String *)") at ./assert/assert.c:105
      #7  0x0000651126192bc1 in Item_copy_string::val_str (this=0xe261401a850, str=0xe26140185c8) at /test/10.6_dbg/sql/item.cc:5330
      #8  0x000065112619e19f in Item_direct_ref::val_str (this=0xe2614018620, tmp=0xe26140185c8) at /test/10.6_dbg/sql/item.cc:8916
      #9  0x000065112619e19f in Item_direct_ref::val_str (this=0xe2614018360, tmp=0xe26140185c8) at /test/10.6_dbg/sql/item.cc:8916
      #10 0x000065112619d28e in Item_ref::str_result (this=0xe2614018360, str=0xe26140185c8) at /test/10.6_dbg/sql/item.cc:8683
      #11 0x00006511261a42a1 in Item_cache_str::cache_value (this=0xe26140184d8)at /test/10.6_dbg/sql/item.cc:10766
      #12 0x0000651126271211 in Item_singlerow_subselect::store (this=0xe2614014c28, i=0, item=0xe2614018360) at /test/10.6_dbg/sql/item_subselect.cc:1297
      #13 0x0000651125d34081 in select_singlerow_subselect::send_data (this=0xe2614014d80, items=@0xe26140140b0: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0xe26140143e8, last = 0xe26140143e8, elements = 1}, <No data fields>})at /test/10.6_dbg/sql/sql_class.cc:3778
      #14 0x0000651125e5fdf0 in select_result_sink::send_data_with_check (this=0xe2614014d80, items=@0xe26140140b0: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0xe26140143e8, last = 0xe26140143e8, elements = 1}, <No data fields>}, u=0xe2614014408, sent=0) at /test/10.6_dbg/sql/sql_class.h:5963
      #15 0x0000651125e2479e in JOIN::exec_inner (this=0xe2614017d20)at /test/10.6_dbg/sql/sql_select.cc:4805
      #16 0x0000651125e23fde in JOIN::exec (this=0xe2614017d20)at /test/10.6_dbg/sql/sql_select.cc:4717
      #17 0x000065112627ebb8 in subselect_single_select_engine::exec (this=0xe2614014db0) at /test/10.6_dbg/sql/item_subselect.cc:4138
      #18 0x000065112626f7dd in Item_subselect::exec (this=0xe2614014c28)at /test/10.6_dbg/sql/item_subselect.cc:816
      #19 0x0000651126271d73 in Item_singlerow_subselect::val_str (this=0xe2614014c28, str=0xe261401a428)at /test/10.6_dbg/sql/item_subselect.cc:1501
      #20 0x0000651125c765d1 in Item::str_result (this=0xe2614014c28, tmp=0xe261401a428) at /test/10.6_dbg/sql/item.h:1813
      #21 0x00006511261a42a1 in Item_cache_str::cache_value (this=0xe261401a338)at /test/10.6_dbg/sql/item.cc:10766
      #22 0x00006511261a879c in Item_cache_wrapper::cache (this=0xe261401a298)at /test/10.6_dbg/sql/item.cc:9144
      #23 0x000065112619efd3 in Item_cache_wrapper::val_str (this=0xe261401a298, str=0xe261401a610) at /test/10.6_dbg/sql/item.cc:9252
      #24 0x00006511261b3375 in Cached_item_str::cmp (this=0xe261401a5d0)at /test/10.6_dbg/sql/item_buff.cc:84
      #25 0x0000651125e4980f in test_if_group_changed (list=@0xe2614016ee0: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0xe261401a630, last = 0xe261401a630, elements = 1}, <No data fields>})at /test/10.6_dbg/sql/sql_select.cc:27309
      #26 0x0000651125e472df in end_send_group (join=0xe2614016d58, join_tab=0xe2614019628, end_of_records=false)at /test/10.6_dbg/sql/sql_select.cc:23903
      #27 0x0000651125e47de9 in evaluate_join_record (join=0xe2614016d58, join_tab=0xe2614019268, error=0) at /test/10.6_dbg/sql/sql_select.cc:22623
      #28 0x0000651125e00369 in sub_select (join=0xe2614016d58, join_tab=0xe2614019268, end_of_records=false)at /test/10.6_dbg/sql/sql_select.cc:22393
      #29 0x0000651125e25d7d in do_select (join=0xe2614016d58, procedure=0x0)at /test/10.6_dbg/sql/sql_select.cc:21916
      #30 0x0000651125e250ac in JOIN::exec_inner (this=0xe2614016d58)at /test/10.6_dbg/sql/sql_select.cc:4939
      #31 0x0000651125e23fde in JOIN::exec (this=0xe2614016d58)at /test/10.6_dbg/sql/sql_select.cc:4717
      #32 0x0000651125e00c31 in mysql_select (thd=0xe2614000d58, tables=0xe2614015b38, fields=@0xe2614013710: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0xe2614015828, last = 0xe2614015ab0, elements = 2}, <No data fields>}, conds=0x0, og_num=1, order=0x0, group=0xe2614016370, having=0x0, proc_param=0x0, select_options=2147748608, result=0xe2614016d30, unit=0xe2614004f38, select_lex=0xe2614013450)at /test/10.6_dbg/sql/sql_select.cc:5196
      #33 0x0000651125e006f5 in handle_select (thd=0xe2614000d58, lex=0xe2614004e70, result=0xe2614016d30, setup_tables_done_option=0)at /test/10.6_dbg/sql/sql_select.cc:573
      #34 0x0000651125dc21ad in execute_sqlcom_select (thd=0xe2614000d58, all_tables=0xe2614015b38) at /test/10.6_dbg/sql/sql_parse.cc:6422
      #35 0x0000651125db5c9d in mysql_execute_command (thd=0xe2614000d58, is_called_from_prepared_stmt=false) at /test/10.6_dbg/sql/sql_parse.cc:4013
      #36 0x0000651125dade94 in mysql_parse (thd=0xe2614000d58, rawbuf=0xe2614013360 "SELECT (SELECT (SELECT t1.a)) aa, COUNT(DISTINCT b) FROM t1  GROUP BY aa", length=72, parser_state=0xe2660fb2a48)at /test/10.6_dbg/sql/sql_parse.cc:8200
      #37 0x0000651125dab354 in dispatch_command (command=COM_QUERY, thd=0xe2614000d58, packet=0xe261400ade9 "", packet_length=72, blocking=true) at /test/10.6_dbg/sql/sql_parse.cc:1908
      #38 0x0000651125daea43 in do_command (thd=0xe2614000d58, blocking=true)at /test/10.6_dbg/sql/sql_parse.cc:1421
      #39 0x0000651125f6aeb9 in do_handle_one_connection (connect=0x6511388b0c78, put_in_cache=true) at /test/10.6_dbg/sql/sql_connect.cc:1386
      #40 0x0000651125f6ac52 in handle_one_connection (arg=0x65113884d958)at /test/10.6_dbg/sql/sql_connect.cc:1298
      #41 0x00000e266dc9caa4 in start_thread (arg=<optimized out>)at ./nptl/pthread_create.c:447
      #42 0x00000e266dd29c3c 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  copied_in|SIGABRT|Item_copy_string::val_str|Item_direct_ref::val_str|Item_direct_ref::val_str|Item_ref::str_result             
      CS  10.5   opt  280425  c461188ca6ad6ec3a54201eb87ebd75797d296df  No bug found
      CS  10.6   dbg  280425  19644f6821d59ecca0f9b1f44fadb3b887061965  copied_in|SIGABRT|Item_copy_string::val_str|Item_direct_ref::val_str|Item_direct_ref::val_str|Item_ref::str_result                
      CS  10.6   opt  280425  19644f6821d59ecca0f9b1f44fadb3b887061965  No bug found              
      CS  10.11  dbg  280425  4d41ec081e34671a1997ce797dcb9f7b7997437e  copied_in|SIGABRT|Item_copy_string::val_str|Item_direct_ref::val_str|Item_direct_ref::val_str|Item_ref::str_result               
      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  280425  a9bdfccbc63708749b3b60fbb98719605401cc8b  No bug found                                    
      CS  12.0   opt  280425  a9bdfccbc63708749b3b60fbb98719605401cc8b  No bug found                  
      ES  10.5   dbg  170325  e99e19fae843c6ab174d0793e82b76bf6d980147  No bug found                  
      ES  10.5   opt  170325  e99e19fae843c6ab174d0793e82b76bf6d980147  No bug found                  
      ES  10.6   dbg  170325  ee1d68c27bc578f7750b898d7c65acfec33dc30b  No bug found                  
      ES  10.6   opt  170325  ee1d68c27bc578f7750b898d7c65acfec33dc30b  No bug found                  
      ES  11.4   dbg  170325  c623275dc5fb705004d716e4c32386cf89649b9d  No bug found                  
      ES  11.4   opt  170325  c623275dc5fb705004d716e4c32386cf89649b9d  No bug found                  
      

      The assertion happens after this commit

      commit ba34657cd22fc831bdfd06fd088644b288043652 (HEAD)
      Author: Oleksandr Byelkin <sanja@mariadb.com>
      Date:   Wed Jan 22 22:08:56 2025 +0100
       
          MDEV-35238 (MDEV-34922) Wrong results from a tables with a single record and an aggregate
          
          The problem is that copy function was used in field list but never
          copied in this execution path.
          
          So copy should be performed before returning result.
          
          Protection against uninitialized copy usage added.
      

      Attachments

        Issue Links

          Activity

            People

              sanja Oleksandr Byelkin
              ramesh Ramesh Sivaraman
              Votes:
              0 Vote for this issue
              Watchers:
              5 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.