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

UBSAN function-type-mismatch's errors in MDEV-9826 feature branch

    XMLWordPrintable

Details

    • Can result in unexpected behaviour

    Description

      I am seeing a long list of UniqueID's for what is essentially a similar UBSAN issue:

      UBSAN|call to function my_hasher_base31 through pointer to incorrect function type 'my_hasher_st (*)()'|sql/ha_partition.cc|ha_partition::calculate_key_hash_value|get_part_id_key|get_partition_id_key_nosub|find_used_partitions
      UBSAN|call to function my_hasher_base31 through pointer to incorrect function type 'my_hasher_st (*)()'|sql/ha_partition.cc|ha_partition::calculate_key_hash_value|get_part_id_key|get_partition_id_key_nosub|get_full_part_id_from_key
      UBSAN|call to function my_hasher_base31 through pointer to incorrect function type 'my_hasher_st (*)()'|sql/ha_partition.cc|ha_partition::calculate_key_hash_value|get_part_id_key|get_partition_id_key_nosub|get_next_partition_via_walking
      UBSAN|call to function my_hasher_base31 through pointer to incorrect function type 'my_hasher_st (*)()'|sql/ha_partition.cc|ha_partition::calculate_key_hash_value|get_part_id_key|get_partition_id_key_nosub|ha_partition::write_row
      UBSAN|call to function my_hasher_crc32c through pointer to incorrect function type 'my_hasher_st (*)()'|sql/ha_partition.cc|ha_partition::calculate_key_hash_value|get_part_id_key|get_partition_id_key_nosub|find_used_partitions
      UBSAN|call to function my_hasher_crc32c through pointer to incorrect function type 'my_hasher_st (*)()'|sql/ha_partition.cc|ha_partition::calculate_key_hash_value|get_part_id_key|get_partition_id_key_nosub|get_next_partition_via_walking
      UBSAN|call to function my_hasher_crc32c through pointer to incorrect function type 'my_hasher_st (*)()'|sql/ha_partition.cc|ha_partition::calculate_key_hash_value|get_part_id_key|get_partition_id_key_nosub|get_part_for_buf
      UBSAN|call to function my_hasher_crc32c through pointer to incorrect function type 'my_hasher_st (*)()'|sql/ha_partition.cc|ha_partition::calculate_key_hash_value|get_part_id_key|get_partition_id_key_nosub|ha_partition::write_row
      UBSAN|call to function my_hasher_crc32c through pointer to incorrect function type 'my_hasher_st (*)()'|sql/ha_partition.cc|ha_partition::calculate_key_hash_value|get_part_id_key|get_partition_id_key_sub|get_next_subpartition_via_walking
      UBSAN|call to function my_hasher_crc32c through pointer to incorrect function type 'my_hasher_st (*)()'|sql/ha_partition.cc|ha_partition::calculate_key_hash_value|get_part_id_key|get_partition_id_key_sub|get_partition_id_with_sub
      UBSAN|call to function my_hasher_mysql5x through pointer to incorrect function type 'my_hasher_st (*)()'|sql/ha_partition.cc|ha_partition::calculate_key_hash_value|get_part_id_key|get_partition_id_key_nosub|find_used_partitions
      UBSAN|call to function my_hasher_mysql5x through pointer to incorrect function type 'my_hasher_st (*)()'|sql/ha_partition.cc|ha_partition::calculate_key_hash_value|get_part_id_key|get_partition_id_key_nosub|get_full_part_id_from_key
      UBSAN|call to function my_hasher_mysql5x through pointer to incorrect function type 'my_hasher_st (*)()'|sql/ha_partition.cc|ha_partition::calculate_key_hash_value|get_part_id_key|get_partition_id_key_nosub|get_next_partition_via_walking
      UBSAN|call to function my_hasher_mysql5x through pointer to incorrect function type 'my_hasher_st (*)()'|sql/ha_partition.cc|ha_partition::calculate_key_hash_value|get_part_id_key|get_partition_id_key_nosub|get_part_iter_for_interval_via_walking
      UBSAN|call to function my_hasher_mysql5x through pointer to incorrect function type 'my_hasher_st (*)()'|sql/ha_partition.cc|ha_partition::calculate_key_hash_value|get_part_id_key|get_partition_id_key_nosub|ha_partition::write_row
      UBSAN|call to function my_hasher_mysql5x through pointer to incorrect function type 'my_hasher_st (*)()'|sql/ha_partition.cc|ha_partition::calculate_key_hash_value|get_part_id_key|get_partition_id_key_sub|find_used_partitions
      UBSAN|call to function my_hasher_mysql5x through pointer to incorrect function type 'my_hasher_st (*)()'|sql/ha_partition.cc|ha_partition::calculate_key_hash_value|get_part_id_key|get_partition_id_key_sub|get_next_subpartition_via_walking
      UBSAN|call to function my_hasher_mysql5x through pointer to incorrect function type 'my_hasher_st (*)()'|sql/ha_partition.cc|ha_partition::calculate_key_hash_value|get_part_id_key|get_partition_id_key_sub|get_partition_id_with_sub
      UBSAN|call to function my_hasher_mysql5x through pointer to incorrect function type 'my_hasher_st (*)()'|sql/ha_partition.cc|ha_partition::calculate_key_hash_value|get_part_id_linear_key|get_partition_id_linear_key_nosub|find_used_partitions
      UBSAN|call to function my_hasher_mysql5x through pointer to incorrect function type 'my_hasher_st (*)()'|sql/ha_partition.cc|ha_partition::calculate_key_hash_value|get_part_id_linear_key|get_partition_id_linear_key_nosub|get_full_part_id_from_key
      UBSAN|call to function my_hasher_mysql5x through pointer to incorrect function type 'my_hasher_st (*)()'|sql/ha_partition.cc|ha_partition::calculate_key_hash_value|get_part_id_linear_key|get_partition_id_linear_key_nosub|get_next_partition_via_walking
      UBSAN|call to function my_hasher_mysql5x through pointer to incorrect function type 'my_hasher_st (*)()'|sql/ha_partition.cc|ha_partition::calculate_key_hash_value|get_part_id_linear_key|get_partition_id_linear_key_nosub|get_part_iter_for_interval_via_walking
      UBSAN|call to function my_hasher_mysql5x through pointer to incorrect function type 'my_hasher_st (*)()'|sql/ha_partition.cc|ha_partition::calculate_key_hash_value|get_part_id_linear_key|get_partition_id_linear_key_nosub|ha_partition::write_row
      UBSAN|call to function my_hasher_mysql5x through pointer to incorrect function type 'my_hasher_st (*)()'|sql/ha_partition.cc|ha_partition::calculate_key_hash_value|get_part_id_linear_key|get_partition_id_linear_key_sub|get_next_subpartition_via_walking
      UBSAN|call to function my_hasher_mysql5x through pointer to incorrect function type 'my_hasher_st (*)()'|sql/ha_partition.cc|ha_partition::calculate_key_hash_value|get_part_id_linear_key|get_partition_id_linear_key_sub|get_partition_id_with_sub
      UBSAN|call to function my_hasher_xxh3 through pointer to incorrect function type 'my_hasher_st (*)()'|sql/ha_partition.cc|ha_partition::calculate_key_hash_value|get_part_id_key|get_partition_id_key_nosub|find_used_partitions
      UBSAN|call to function my_hasher_xxh3 through pointer to incorrect function type 'my_hasher_st (*)()'|sql/ha_partition.cc|ha_partition::calculate_key_hash_value|get_part_id_key|get_partition_id_key_nosub|get_full_part_id_from_key
      UBSAN|call to function my_hasher_xxh3 through pointer to incorrect function type 'my_hasher_st (*)()'|sql/ha_partition.cc|ha_partition::calculate_key_hash_value|get_part_id_key|get_partition_id_key_nosub|get_next_partition_via_walking
      UBSAN|call to function my_hasher_xxh3 through pointer to incorrect function type 'my_hasher_st (*)()'|sql/ha_partition.cc|ha_partition::calculate_key_hash_value|get_part_id_key|get_partition_id_key_nosub|ha_partition::write_row
      UBSAN|call to function my_hasher_xxh3 through pointer to incorrect function type 'my_hasher_st (*)()'|sql/ha_partition.cc|ha_partition::calculate_key_hash_value|get_part_id_key|get_partition_id_key_sub|find_used_partitions
      UBSAN|call to function my_hasher_xxh3 through pointer to incorrect function type 'my_hasher_st (*)()'|sql/ha_partition.cc|ha_partition::calculate_key_hash_value|get_part_id_key|get_partition_id_key_sub|get_next_subpartition_via_walking
      UBSAN|call to function my_hasher_xxh3 through pointer to incorrect function type 'my_hasher_st (*)()'|sql/ha_partition.cc|ha_partition::calculate_key_hash_value|get_part_id_key|get_partition_id_key_sub|get_partition_id_with_sub
      UBSAN|call to function my_hasher_xxh32 through pointer to incorrect function type 'my_hasher_st (*)()'|sql/ha_partition.cc|ha_partition::calculate_key_hash_value|get_part_id_key|get_partition_id_key_nosub|find_used_partitions
      UBSAN|call to function my_hasher_xxh32 through pointer to incorrect function type 'my_hasher_st (*)()'|sql/ha_partition.cc|ha_partition::calculate_key_hash_value|get_part_id_key|get_partition_id_key_nosub|get_full_part_id_from_key
      UBSAN|call to function my_hasher_xxh32 through pointer to incorrect function type 'my_hasher_st (*)()'|sql/ha_partition.cc|ha_partition::calculate_key_hash_value|get_part_id_key|get_partition_id_key_nosub|get_next_partition_via_walking
      UBSAN|call to function my_hasher_xxh32 through pointer to incorrect function type 'my_hasher_st (*)()'|sql/ha_partition.cc|ha_partition::calculate_key_hash_value|get_part_id_key|get_partition_id_key_nosub|ha_partition::write_row
      

      I've reduced a number of these and the testcaes are as follows:

      CREATE TABLE t (c INT,c2 DATE,c3 CHAR,PRIMARY KEY(c2)) PARTITION BY KEY() PARTITIONS 8;
      SELECT * FROM t WHERE c=''AND c2='';
      

      Leads to:

      MDEV-9826 CS 12.3.0 775ad15a80bf26ce5d29b237110477547631289b (Optimized, UBASAN, Clang 21.1.3-20250923) Build 20/12/2025

      UBSAN|call to function my_hasher_mysql5x through pointer to incorrect function type 'my_hasher_st (*)()'|sql/ha_partition.cc|ha_partition::calculate_key_hash_value|get_part_id_key|get_partition_id_key_nosub|find_used_partitions
      

      CREATE TABLE t (c INT KEY) PARTITION BY LINEAR KEY(c) PARTITIONS 6;
      INSERT INTO t (c) VALUES (1);
      

      Leads to:

      MDEV-9826 CS 12.3.0 775ad15a80bf26ce5d29b237110477547631289b (Optimized, UBASAN, Clang 21.1.3-20250923) Build 20/12/2025

      UBSAN|call to function my_hasher_mysql5x through pointer to incorrect function type 'my_hasher_st (*)()'|sql/ha_partition.cc|ha_partition::calculate_key_hash_value|get_part_id_linear_key|get_partition_id_linear_key_nosub|ha_partition::write_row
      

      CREATE TABLE t (c INT,c2 INT,c3 INT,KEY(c,c2),UNIQUE (c,c3)) PARTITION BY KEY(c) PARTITIONS 4;
      SELECT * FROM t WHERE c>='1998-12-31 11:30:45' AND c<'2008-01-06 00:00:00' AND c2='1998-12-28 00:00:00';
      

      Leads to:

      MDEV-9826 CS 12.3.0 775ad15a80bf26ce5d29b237110477547631289b (Optimized, UBASAN, Clang 21.1.3-20250923) Build 20/12/2025

      UBSAN|call to function my_hasher_mysql5x through pointer to incorrect function type 'my_hasher_st (*)()'|sql/ha_partition.cc|ha_partition::calculate_key_hash_value|get_part_id_key|get_partition_id_key_nosub|get_next_partition_via_walking
      

      CREATE TABLE t (c INT,c2 INT,KEY(c2)) PARTITION BY RANGE (c) SUBPARTITION BY KEY(c2) SUBPARTITIONS 2 (PARTITION p VALUES LESS THAN (100));
      INSERT INTO t VALUES (1,0);
      

      Leads to:

      MDEV-9826 CS 12.3.0 775ad15a80bf26ce5d29b237110477547631289b (Optimized, UBASAN, Clang 21.1.3-20250923) Build 20/12/2025

      UBSAN|call to function my_hasher_mysql5x through pointer to incorrect function type 'my_hasher_st (*)()'|sql/ha_partition.cc|ha_partition::calculate_key_hash_value|get_part_id_key|get_partition_id_key_sub|get_partition_id_with_sub
      

      A full stack example for one of them (the last example above):

      MDEV-9826 CS 12.3.0 775ad15a80bf26ce5d29b237110477547631289b (Optimized, UBASAN, Clang 21.1.3-20250923) Build 20/12/2025

      /test/bb-main-mdev-9826-v4_opt_san/sql/ha_partition.cc:10339:17: runtime error: call to function my_hasher_mysql5x through pointer to incorrect function type 'my_hasher_st (*)()'
      /test/bb-main-mdev-9826-v4_opt_san/strings/hasher-mysql5x.c:11: note: my_hasher_mysql5x defined here
          #0 0x64ffd57c9584 in ha_partition::calculate_key_hash_value(Field**) /test/bb-main-mdev-9826-v4_opt_san/sql/ha_partition.cc:10339:17
          #1 0x64ffd462f943 in get_part_id_key(handler*, Field**, unsigned int, long long*) /test/bb-main-mdev-9826-v4_opt_san/sql/sql_partition.cc:2979:16
          #2 0x64ffd462f943 in get_partition_id_key_sub(partition_info*, unsigned int*) /test/bb-main-mdev-9826-v4_opt_san/sql/sql_partition.cc:3861:13
          #3 0x64ffd462e48a in get_partition_id_with_sub(partition_info*, unsigned int*, long long*) /test/bb-main-mdev-9826-v4_opt_san/sql/sql_partition.cc:3804:7
          #4 0x64ffd579bb7d in ha_partition::write_row(unsigned char const*) /test/bb-main-mdev-9826-v4_opt_san/sql/ha_partition.cc:4697:10
          #5 0x64ffd3655fab in handler::ha_write_row(unsigned char const*) /test/bb-main-mdev-9826-v4_opt_san/sql/handler.cc:8249:3
          #6 0x64ffd4447c9f in Write_record::single_insert(unsigned long long*) /test/bb-main-mdev-9826-v4_opt_san/sql/sql_insert.cc:2390:27
          #7 0x64ffd443a616 in Write_record::write_record() /test/bb-main-mdev-9826-v4_opt_san/sql/sql_insert.cc:2432:10
          #8 0x64ffd442b4cd in mysql_insert(THD*, TABLE_LIST*, List<Item>&, List<List<Item>>&, List<Item>&, List<Item>&, enum_duplicates, bool, select_result*) /test/bb-main-mdev-9826-v4_opt_san/sql/sql_insert.cc:1232:22
          #9 0x64ffd45956d3 in mysql_execute_command(THD*, bool) /test/bb-main-mdev-9826-v4_opt_san/sql/sql_parse.cc:4456:10
          #10 0x64ffd4571155 in mysql_parse(THD*, char*, unsigned int, Parser_state*) /test/bb-main-mdev-9826-v4_opt_san/sql/sql_parse.cc:7895:18
          #11 0x64ffd4569320 in dispatch_command(enum_server_command, THD*, char*, unsigned int, bool) /test/bb-main-mdev-9826-v4_opt_san/sql/sql_parse.cc:1878:7
          #12 0x64ffd45730b0 in do_command(THD*, bool) /test/bb-main-mdev-9826-v4_opt_san/sql/sql_parse.cc:1417:17
          #13 0x64ffd4da499c in do_handle_one_connection(CONNECT*, bool) /test/bb-main-mdev-9826-v4_opt_san/sql/sql_connect.cc:1503:11
          #14 0x64ffd4da44b6 in handle_one_connection /test/bb-main-mdev-9826-v4_opt_san/sql/sql_connect.cc:1415:5
          #15 0x64ffd35066ba in asan_thread_start(void*) crtstuff.c
          #16 0x79d90129ca93 in start_thread nptl/pthread_create.c:447:8
          #17 0x79d901329c3b in clone3 misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:78
       
      SUMMARY: UndefinedBehaviorSanitizer: function-type-mismatch /test/bb-main-mdev-9826-v4_opt_san/sql/ha_partition.cc:10339:17 
      

      All tables InnoDB.

      Attachments

        Issue Links

          Activity

            People

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