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

UBSAN: runtime error: call to function FT_STOPWORD_cmp through pointer to incorrect function

Details

    Description

      export UBSAN_OPTIONS=print_stacktrace=1:report_error_type=1
      rm -Rf data tmp 
      mkdir tmp 
      ./scripts/mariadb-install-db --no-defaults --force --auth-root-authentication-method=normal --basedir=${PWD} --tmpdir=${PWD}/tmp --datadir=${PWD}/data
      

      Leads to:

      CS 10.6.21 2255be03952e0be7db764613956c5c66a6c1ab75 (Debug, UBASAN)

      /test/10.6_dbg_san/mysys/tree.c:249:9: runtime error: call to function FT_STOPWORD_cmp through pointer to incorrect function type 'int (*)(void *, const void *, const void *)'
      /test/10.6_dbg_san/storage/myisam/ft_stopwords.c:35: note: FT_STOPWORD_cmp defined here
          #0 0x560383995267 in tree_insert /test/10.6_dbg_san/mysys/tree.c:249:9
          #1 0x56038358458a in ft_add_stopword /test/10.6_dbg_san/storage/myisam/ft_stopwords.c:54:12
          #2 0x560383583f54 in ft_init_stopwords /test/10.6_dbg_san/storage/myisam/ft_stopwords.c:118:11
          #3 0x56037ce15b7f in init_server_components() /test/10.6_dbg_san/sql/mysqld.cc:5501:3
          #4 0x56037ce07ab0 in mysqld_main(int, char**) /test/10.6_dbg_san/sql/mysqld.cc:5806:7
          #5 0x56037cdf2863 in main /test/10.6_dbg_san/sql/main.cc:34:10
          #6 0x14dcc422a1c9 in __libc_start_call_main csu/../sysdeps/nptl/libc_start_call_main.h:58:16
          #7 0x14dcc422a28a in __libc_start_main csu/../csu/libc-start.c:360:3
          #8 0x56037cd17034 in _start (/test/UBASAN_MD271124-mariadb-10.6.21-linux-x86_64-dbg/bin/mariadbd+0x3eb8034) (BuildId: 3cd87cd3953ac9cf3a930328b34dbd55d44c8146)
       
      SUMMARY: UndefinedBehaviorSanitizer: function-type-mismatch /test/10.6_dbg_san/mysys/tree.c:249:9 
      

      Observed using UBSAN with Clang and LLMV 18.1.3:

      sudo apt install clang llvm-18 llvm-18-linker-tools llvm-18-runtime llvm-18-tools llvm-18-dev libstdc++-14-dev llvm-dev llvm-17-linker-tools  # llvm-17-linker-tools installs /usr/lib/llvm-17/lib/LLVMgold.so, which is needed for compilation, and LLVMgold.so is no longer included in LLVM 18
      sudo ln -s /usr/lib/llvm-17/lib/LLVMgold.so /usr/lib/llvm-18/lib/LLVMgold.so
      ...
      export UBSAN_OPTIONS=print_stacktrace=1:report_error_type=1
      

      Related helpful comment on 'function-type-mismatch' errors here. Affects debug builds only.

      Attachments

        Issue Links

          Activity

            Roel Roel Van de Paar created issue -
            Roel Roel Van de Paar made changes -
            Field Original Value New Value
            Labels UBSAN affects-tests not-10.5 regression-10.6 UBSAN affects-tests function-type-mismatch not-10.5 regression-10.6
            Roel Roel Van de Paar made changes -
            Description {code:bash}
            export UBSAN_OPTIONS=print_stacktrace=1:report_error_type=1
            rm -Rf data tmp
            mkdir tmp
            ./scripts/mariadb-install-db --no-defaults --force --auth-root-authentication-method=normal --basedir=${PWD} --tmpdir=${PWD}/tmp --datadir=${PWD}/data
            {code}
            Leads to:
            {noformat:title=CS 10.6.21 2255be03952e0be7db764613956c5c66a6c1ab75 (Debug, UBASAN)}
            /test/10.6_dbg_san/mysys/tree.c:249:9: runtime error: call to function FT_STOPWORD_cmp through pointer to incorrect function type 'int (*)(void *, const void *, const void *)'
            /test/10.6_dbg_san/storage/myisam/ft_stopwords.c:35: note: FT_STOPWORD_cmp defined here
                #0 0x560383995267 in tree_insert /test/10.6_dbg_san/mysys/tree.c:249:9
                #1 0x56038358458a in ft_add_stopword /test/10.6_dbg_san/storage/myisam/ft_stopwords.c:54:12
                #2 0x560383583f54 in ft_init_stopwords /test/10.6_dbg_san/storage/myisam/ft_stopwords.c:118:11
                #3 0x56037ce15b7f in init_server_components() /test/10.6_dbg_san/sql/mysqld.cc:5501:3
                #4 0x56037ce07ab0 in mysqld_main(int, char**) /test/10.6_dbg_san/sql/mysqld.cc:5806:7
                #5 0x56037cdf2863 in main /test/10.6_dbg_san/sql/main.cc:34:10
                #6 0x14dcc422a1c9 in __libc_start_call_main csu/../sysdeps/nptl/libc_start_call_main.h:58:16
                #7 0x14dcc422a28a in __libc_start_main csu/../csu/libc-start.c:360:3
                #8 0x56037cd17034 in _start (/test/UBASAN_MD271124-mariadb-10.6.21-linux-x86_64-dbg/bin/mariadbd+0x3eb8034) (BuildId: 3cd87cd3953ac9cf3a930328b34dbd55d44c8146)

            SUMMARY: UndefinedBehaviorSanitizer: function-type-mismatch /test/10.6_dbg_san/mysys/tree.c:249:9
            {noformat}
            Observed using UBSAN with Clang and LLMV 18.1.3:
            {code:bash}
            sudo apt install clang llvm-18 llvm-18-linker-tools llvm-18-runtime llvm-18-tools llvm-18-dev libstdc++-14-dev llvm-dev llvm-17-linker-tools # llvm-17-linker-tools installs /usr/lib/llvm-17/lib/LLVMgold.so, which is needed for compilation, and LLVMgold.so is no longer included in LLVM 18
            sudo ln -s /usr/lib/llvm-17/lib/LLVMgold.so /usr/lib/llvm-18/lib/LLVMgold.so
            ...
            export UBSAN_OPTIONS=print_stacktrace=1:report_error_type=1
            {code}
            Related helpful comment on '{{function-type-mismatch}}' errors [here|https://jira.mariadb.org/browse/CONC-711?focusedCommentId=295054&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-295054].
            {code:bash}
            export UBSAN_OPTIONS=print_stacktrace=1:report_error_type=1
            rm -Rf data tmp
            mkdir tmp
            ./scripts/mariadb-install-db --no-defaults --force --auth-root-authentication-method=normal --basedir=${PWD} --tmpdir=${PWD}/tmp --datadir=${PWD}/data
            {code}
            Leads to:
            {noformat:title=CS 10.6.21 2255be03952e0be7db764613956c5c66a6c1ab75 (Debug, UBASAN)}
            /test/10.6_dbg_san/mysys/tree.c:249:9: runtime error: call to function FT_STOPWORD_cmp through pointer to incorrect function type 'int (*)(void *, const void *, const void *)'
            /test/10.6_dbg_san/storage/myisam/ft_stopwords.c:35: note: FT_STOPWORD_cmp defined here
                #0 0x560383995267 in tree_insert /test/10.6_dbg_san/mysys/tree.c:249:9
                #1 0x56038358458a in ft_add_stopword /test/10.6_dbg_san/storage/myisam/ft_stopwords.c:54:12
                #2 0x560383583f54 in ft_init_stopwords /test/10.6_dbg_san/storage/myisam/ft_stopwords.c:118:11
                #3 0x56037ce15b7f in init_server_components() /test/10.6_dbg_san/sql/mysqld.cc:5501:3
                #4 0x56037ce07ab0 in mysqld_main(int, char**) /test/10.6_dbg_san/sql/mysqld.cc:5806:7
                #5 0x56037cdf2863 in main /test/10.6_dbg_san/sql/main.cc:34:10
                #6 0x14dcc422a1c9 in __libc_start_call_main csu/../sysdeps/nptl/libc_start_call_main.h:58:16
                #7 0x14dcc422a28a in __libc_start_main csu/../csu/libc-start.c:360:3
                #8 0x56037cd17034 in _start (/test/UBASAN_MD271124-mariadb-10.6.21-linux-x86_64-dbg/bin/mariadbd+0x3eb8034) (BuildId: 3cd87cd3953ac9cf3a930328b34dbd55d44c8146)

            SUMMARY: UndefinedBehaviorSanitizer: function-type-mismatch /test/10.6_dbg_san/mysys/tree.c:249:9
            {noformat}
            Observed using UBSAN with Clang and LLMV 18.1.3:
            {code:bash}
            sudo apt install clang llvm-18 llvm-18-linker-tools llvm-18-runtime llvm-18-tools llvm-18-dev libstdc++-14-dev llvm-dev llvm-17-linker-tools # llvm-17-linker-tools installs /usr/lib/llvm-17/lib/LLVMgold.so, which is needed for compilation, and LLVMgold.so is no longer included in LLVM 18
            sudo ln -s /usr/lib/llvm-17/lib/LLVMgold.so /usr/lib/llvm-18/lib/LLVMgold.so
            ...
            export UBSAN_OPTIONS=print_stacktrace=1:report_error_type=1
            {code}
            Related helpful comment on '{{function-type-mismatch}}' errors [here|https://jira.mariadb.org/browse/CONC-711?focusedCommentId=295054&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-295054]. Affects debug builds only.
            Roel Roel Van de Paar made changes -
            Comment [ This issue requires a global UBSAN supression filter on {{function:tree_insert}} and thus significantly affects testing as all other bugs which use this function anywhere in their stack will be masked. ]
            Roel Roel Van de Paar made changes -
            Comment [ This issue requires a global UBSAN supression filter on function:tree_insert and thus significantly affects testing as all other bugs which use this function anywhere in their stack will be masked. ]
            Roel Roel Van de Paar made changes -
            Affects Version/s 11.8 [ 29921 ]
            Roel Roel Van de Paar made changes -
            Roel Roel Van de Paar made changes -
            Fix Version/s 10.6.21 [ 29953 ]
            Fix Version/s 10.6 [ 24028 ]
            Assignee Oleksandr Byelkin [ sanja ]
            Resolution Fixed [ 1 ]
            Status Open [ 1 ] Closed [ 6 ]
            Roel Roel Van de Paar made changes -
            Fix Version/s 10.11.11 [ 29954 ]
            Fix Version/s 11.4.5 [ 29956 ]
            Fix Version/s 11.7.2 [ 29914 ]
            Fix Version/s 11.8.1 [ 29961 ]

            People

              Unassigned Unassigned
              Roel Roel Van de Paar
              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.