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

ASAN errors in Item_func_json_contains_path::val_int upon PS execution

    XMLWordPrintable

Details

    Description

      CREATE TABLE test.tmp (f BLOB) ENGINE=MyISAM;
      PREPARE stmt FROM "SELECT * FROM test.tmp WHERE JSON_EXISTS(JSON_ARRAY('[true,1234567890]'), '$**.*') != JSON_CONTAINS_PATH(JSON_INSERT('{}', '$[1]', NULL), 'all', '$[1]')";
      EXECUTE stmt;
       
      # Cleanup
      DROP TABLE test.tmp;
      

      10.4 32c6849736211e27964953436aca86e91ac924fd

      ==208377==ERROR: AddressSanitizer: use-after-poison on address 0x62b000062bd0 at pc 0x7f8f77447681 bp 0x7f8f6dd19e60 sp 0x7f8f6dd19610
      WRITE of size 1 at 0x62b000062bd0 thread T5
          #0 0x7f8f77447680 in __interceptor_memset ../../../../src/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc:799
          #1 0x5618f7c27031 in Item_func_json_contains_path::val_int() /data/bld/10.4-asan/sql/item_jsonfunc.cc:1609
          #2 0x5618f77b99f3 in Arg_comparator::compare_int_signed() /data/bld/10.4-asan/sql/item_cmpfunc.cc:953
          #3 0x5618f77fa469 in Arg_comparator::compare() /data/bld/10.4-asan/sql/item_cmpfunc.h:104
          #4 0x5618f77c3583 in Item_func_ne::val_int() /data/bld/10.4-asan/sql/item_cmpfunc.cc:1813
          #5 0x5618f74b9af3 in Type_handler_int_result::Item_val_bool(Item*) const /data/bld/10.4-asan/sql/sql_type.cc:4638
          #6 0x5618f6c8f7a5 in Item::val_bool() /data/bld/10.4-asan/sql/item.h:1474
          #7 0x5618f70dac71 in Item::eval_const_cond() /data/bld/10.4-asan/sql/item.h:1482
          #8 0x5618f70790cf in Item_bool_func2::remove_eq_conds(THD*, Item::cond_result*, bool) /data/bld/10.4-asan/sql/sql_select.cc:17887
          #9 0x5618f7076552 in optimize_cond /data/bld/10.4-asan/sql/sql_select.cc:17423
          #10 0x5618f7003a18 in JOIN::optimize_inner() /data/bld/10.4-asan/sql/sql_select.cc:2133
          #11 0x5618f6fff3bc in JOIN::optimize() /data/bld/10.4-asan/sql/sql_select.cc:1731
          #12 0x5618f7020288 in mysql_select(THD*, TABLE_LIST*, unsigned int, List<Item>&, Item*, unsigned int, st_order*, st_order*, Item*, st_order*, unsigned long long, select_result*, st_select_lex_unit*, st_select_lex*) /data/bld/10.4-asan/sql/sql_select.cc:4832
          #13 0x5618f6ff0d5c in handle_select(THD*, LEX*, select_result*, unsigned long) /data/bld/10.4-asan/sql/sql_select.cc:442
          #14 0x5618f6f5b5fc in execute_sqlcom_select /data/bld/10.4-asan/sql/sql_parse.cc:6475
          #15 0x5618f6f48b11 in mysql_execute_command(THD*) /data/bld/10.4-asan/sql/sql_parse.cc:3978
          #16 0x5618f6fb89d4 in Prepared_statement::execute(String*, bool) /data/bld/10.4-asan/sql/sql_prepare.cc:5025
          #17 0x5618f6fb4014 in Prepared_statement::execute_loop(String*, bool, unsigned char*, unsigned char*) /data/bld/10.4-asan/sql/sql_prepare.cc:4472
          #18 0x5618f6fadd58 in mysql_sql_stmt_execute(THD*) /data/bld/10.4-asan/sql/sql_prepare.cc:3531
          #19 0x5618f6f48b56 in mysql_execute_command(THD*) /data/bld/10.4-asan/sql/sql_parse.cc:3994
          #20 0x5618f6f648ec in mysql_parse(THD*, char*, unsigned int, Parser_state*, bool, bool) /data/bld/10.4-asan/sql/sql_parse.cc:8014
          #21 0x5618f6f3aae1 in dispatch_command(enum_server_command, THD*, char*, unsigned int, bool, bool) /data/bld/10.4-asan/sql/sql_parse.cc:1857
          #22 0x5618f6f37650 in do_command(THD*) /data/bld/10.4-asan/sql/sql_parse.cc:1378
          #23 0x5618f733db96 in do_handle_one_connection(CONNECT*) /data/bld/10.4-asan/sql/sql_connect.cc:1419
          #24 0x5618f733d4ad in handle_one_connection /data/bld/10.4-asan/sql/sql_connect.cc:1323
          #25 0x5618f7fa20ed in pfs_spawn_thread /data/bld/10.4-asan/storage/perfschema/pfs.cc:1869
          #26 0x7f8f76ea8043 in start_thread nptl/pthread_create.c:442
          #27 0x7f8f76f2861b in clone3 ../sysdeps/unix/sysv/linux/x86_64/clone3.S:81
       
      0x62b000062bd0 is located 2512 bytes inside of 24608-byte region [0x62b000062200,0x62b000068220)
      allocated by thread T5 here:
          #0 0x7f8f774b89cf in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:69
          #1 0x5618f8adde52 in my_malloc /data/bld/10.4-asan/mysys/my_malloc.c:101
          #2 0x5618f8aba65a in reset_root_defaults /data/bld/10.4-asan/mysys/my_alloc.c:155
          #3 0x5618f6e1ea1c in THD::init_for_queries() /data/bld/10.4-asan/sql/sql_class.cc:1385
          #4 0x5618f733cdc9 in prepare_new_connection_state(THD*) /data/bld/10.4-asan/sql/sql_connect.cc:1253
          #5 0x5618f733d4f3 in thd_prepare_connection(THD*) /data/bld/10.4-asan/sql/sql_connect.cc:1338
          #6 0x5618f733daf5 in do_handle_one_connection(CONNECT*) /data/bld/10.4-asan/sql/sql_connect.cc:1409
          #7 0x5618f733d4ad in handle_one_connection /data/bld/10.4-asan/sql/sql_connect.cc:1323
          #8 0x5618f7fa20ed in pfs_spawn_thread /data/bld/10.4-asan/storage/perfschema/pfs.cc:1869
          #9 0x7f8f76ea8043 in start_thread nptl/pthread_create.c:442
       
      Thread T5 created by T0 here:
          #0 0x7f8f77449726 in __interceptor_pthread_create ../../../../src/libsanitizer/asan/asan_interceptors.cpp:207
          #1 0x5618f7fa24da in spawn_thread_v1 /data/bld/10.4-asan/storage/perfschema/pfs.cc:1919
          #2 0x5618f6c3ef89 in inline_mysql_thread_create /data/bld/10.4-asan/include/mysql/psi/mysql_thread.h:1275
          #3 0x5618f6c56714 in create_thread_to_handle_connection(CONNECT*) /data/bld/10.4-asan/sql/mysqld.cc:6296
          #4 0x5618f6c56e5f in create_new_thread(CONNECT*) /data/bld/10.4-asan/sql/mysqld.cc:6366
          #5 0x5618f6c5732d in handle_accepted_socket(st_mysql_socket, st_mysql_socket) /data/bld/10.4-asan/sql/mysqld.cc:6464
          #6 0x5618f6c581d9 in handle_connections_sockets() /data/bld/10.4-asan/sql/mysqld.cc:6622
          #7 0x5618f6c55e77 in mysqld_main(int, char**) /data/bld/10.4-asan/sql/mysqld.cc:5954
          #8 0x5618f6c3d0b8 in main /data/bld/10.4-asan/sql/main.cc:25
          #9 0x7f8f76e461c9 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
       
      SUMMARY: AddressSanitizer: use-after-poison ../../../../src/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc:799 in __interceptor_memset
      Shadow bytes around the buggy address:
        0x0c5680004520: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
        0x0c5680004530: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
        0x0c5680004540: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
        0x0c5680004550: 00 00 00 00 00 00 00 00 00 00 f7 00 00 00 00 00
        0x0c5680004560: 00 00 00 00 00 00 00 00 00 f7 00 00 00 00 00 00
      =>0x0c5680004570: 00 00 00 00 00 00 00 00 00 00[f7]00 00 00 00 00
        0x0c5680004580: 00 00 00 00 00 00 00 00 00 00 00 f7 00 00 f7 00
        0x0c5680004590: 00 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7
        0x0c56800045a0: f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7
        0x0c56800045b0: f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7
        0x0c56800045c0: f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7
      Shadow byte legend (one shadow byte represents 8 application bytes):
        Addressable:           00
        Partially addressable: 01 02 03 04 05 06 07 
        Heap left redzone:       fa
        Freed heap region:       fd
        Stack left redzone:      f1
        Stack mid redzone:       f2
        Stack right redzone:     f3
        Stack after return:      f5
        Stack use after scope:   f8
        Global redzone:          f9
        Global init order:       f6
        Poisoned by user:        f7
        Container overflow:      fc
        Array cookie:            ac
        Intra object redzone:    bb
        ASan internal:           fe
        Left alloca redzone:     ca
        Right alloca redzone:    cb
      

      The failure started happening after this commit in 10.4:

      commit 93bdb6db4d71f19348a412d065c2d9a89fa9765a
      Author: Dmitry Shulga
      Date:   Fri Nov 10 17:46:19 2023 +0700
       
          MDEV-32733: Two JSON related tests running in PS mode fail on server built with -DWITH_PROTECT_STATEMENT_MEMROOT=YES
       
          The tests main.func_json and json.json_no_table fail on server built with
      

      Attachments

        Issue Links

          Activity

            People

              shulga Dmitry Shulga
              elenst Elena Stepanova
              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.