Uploaded image for project: 'MariaDB Connector/C'
  1. MariaDB Connector/C
  2. CONC-814

UndefinedBehaviorSanitizer: float-cast-overflow /source/libmariadb/ma_stmt_codec.c:637:41

    XMLWordPrintable

Details

    • Bug
    • Status: Open (View Workflow)
    • Major
    • Resolution: Unresolved
    • 3.4.7
    • None
    • Build
    • None

    Description

      Testing clang-22's asan/ubsan with C/C using the C/C unit test:

      11: ok 60 - test_bug36004
      11: /source/libmariadb/ma_stmt_codec.c:637:41: runtime error: 1.84467e+19 is outside the range of representable values of type 'unsigned long'
      11:     #0 0x55b855c0f5ee in convert_from_long /source/libmariadb/ma_stmt_codec.c:637:41
      11:     #1 0x55b855c06863 in ps_fetch_int64 /source/libmariadb/ma_stmt_codec.c:799:7
      11:     #2 0x55b855bc52a1 in mthd_stmt_fetch_to_bind /source/libmariadb/mariadb_stmt.c:484:9
      11:     #3 0x55b855be21a3 in mysql_stmt_fetch /source/libmariadb/mariadb_stmt.c:1600:7
      11:     #4 0x55b855b4d914 in test_bug3035 /source/unittest/libmariadb/ps_bugs.c:1611:7
      11:     #5 0x55b855b3a8ce in run_tests /source/unittest/libmariadb/my_test.h:777:11
      11:     #6 0x55b855b5a033 in main /source/unittest/libmariadb/ps_bugs.c:6154:3
      11:     #7 0x7f2fff713ca7  (/usr/lib/x86_64-linux-gnu/libc.so.6+0x29ca7) (BuildId: 58749c528985eab03e6700ebc1469fa50aa41219)
      11:     #8 0x7f2fff713d64 in __libc_start_main (/usr/lib/x86_64-linux-gnu/libc.so.6+0x29d64) (BuildId: 58749c528985eab03e6700ebc1469fa50aa41219)
      11:     #9 0x55b855a4d9f0 in _start (/build/unittest/libmariadb/ps_bugs+0x1759f0) (BuildId: 6441882d00180958f5f6b25026b5ce43e0fe3507)
      11: 
      11: SUMMARY: UndefinedBehaviorSanitizer: float-cast-overflow /source/libmariadb/ma_stmt_codec.c:637:41 
      
      

      test_conc205 test failed for causes in CONC-813.

      + minor test leak -CONC-786 / https://github.com/mariadb-corporation/mariadb-connector-c/pull/293 might have a fix (untested):

      14: ok 50 - test_tls_timeout
      14: # close default
      14: 
      14: =================================================================
      14: ==6683==ERROR: LeakSanitizer: detected memory leaks
      14: 
      14: Direct leak of 1272 byte(s) in 1 object(s) allocated from:
      14:     #0 0x555672e4bcad in calloc (/build/unittest/libmariadb/connection+0x213cad) (BuildId: dc460cbf42f2a4aa25c78177992c44c4844aa7cc)
      14:     #1 0x555672ec6343 in mysql_init /source/libmariadb/mariadb_lib.c:1365:26
      14:     #2 0x555672e928ee in run_tests /source/unittest/libmariadb/my_test.h:777:11
      14:     #3 0x555672ea0163 in main /source/unittest/libmariadb/connection.c:2667:3
      14: 
      14: Indirect leak of 128 byte(s) in 1 object(s) allocated from:
      14:     #0 0x555672e4bcad in calloc (/build/unittest/libmariadb/connection+0x213cad) (BuildId: dc460cbf42f2a4aa25c78177992c44c4844aa7cc)
      14:     #1 0x555672ec6435 in mysql_init /source/libmariadb/mariadb_lib.c:1382:27
      14: 
      14: Indirect leak of 24 byte(s) in 1 object(s) allocated from:
      14:     #0 0x555672e4bcad in calloc (/build/unittest/libmariadb/connection+0x213cad) (BuildId: dc460cbf42f2a4aa25c78177992c44c4844aa7cc)
      14:     #1 0x555672ec63ea in mysql_init /source/libmariadb/mariadb_lib.c:1380:32
      14: 
      14: SUMMARY: AddressSanitizer: 1424 byte(s) leaked in 3 allocation(s).
      14/20 Test #14: connection .......................***Failed   68.99 sec
      

      test setup:

      Needed patch to prevent missing floor with clang linking:

      diff --git a/libmariadb/CMakeLists.txt b/libmariadb/CMakeLists.txt
      index 69e8683c..03645515 100644
      --- a/libmariadb/CMakeLists.txt
      +++ b/libmariadb/CMakeLists.txt
      @@ -287,7 +287,7 @@ SET(MARIADB_NONBLOCK_SYMBOLS
       
       # handle static plugins
       SET(LIBMARIADB_SOURCES ${LIBMARIADB_SOURCES} ${LIBMARIADB_PLUGIN_SOURCES})
      -SET(SYSTEM_LIBS ${SYSTEM_LIBS} ${LIBMARIADB_PLUGIN_LIBS} ${ZSTD_LIBRARY} ${ZLIB_LIBRARY})
      +SET(SYSTEM_LIBS ${SYSTEM_LIBS} ${LIBMARIADB_PLUGIN_LIBS} ${ZSTD_LIBRARY} ${ZLIB_LIBRARY} m)
       MESSAGE(STATUS "SYSTEM_LIBS: ${SYSTEM_LIBS}")
       INCLUDE_DIRECTORIES(${LIBMARIADB_PLUGIN_INCLUDES})
       ADD_DEFINITIONS(${LIBMARIADB_PLUGIN_DEFS})
      
      

       

      $ podman network create cctest
      odbctest
      $ podman run -d --rm --env MARIADB_ALLOW_EMPTY_ROOT_PASSWORD=1 --env MARIADB_DATABASE=test --name mariadb --network cctest mariadb:lts
      $ podman run -v $PWD:/source:z \
      --rm \
      -ti \
      --entrypoint bash \
      --mount=type=tmpfs,tmpfs-size=10G,dst=/build \
      --workdir /build \
      --network cctest quay.io/mariadb-foundation/bb-worker:dev_debian13-msan-clang-22

      $ cmake -DCMAKE_LINKER=clang -DCMAKE_C_FLAGS='-fsanitize=undefined -fsanitize=address -fsanitize-address-use-after-scope' -DCMAKE_MODULE_LINKER_FLAGS='-Wl,-lasan -Wl,-lubsan' /source/
      $ cmake --build . --verbose
      $ cd unittest/libmariadb/
      $ export MARIADB_CC_TEST=1
      $ export MYSQL_TEST_USER=
      $ export MYSQL_TEST_USER=root
      $ export MYSQL_TEST_HOST=mariadb
      $ export MYSQL_TEST_DB=test
      $ ctest . --verbose

       

      Attachments

        Issue Links

          Activity

            People

              georg Georg Richter
              danblack Daniel Black
              Votes:
              0 Vote for this issue
              Watchers:
              1 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.