Uploaded image for project: 'MariaDB Connector/ODBC'
  1. MariaDB Connector/ODBC
  2. ODBC-489

UndefinedBehaviorSanitizer: nullptr-with-nonzero-offset /source/driver/ma_statement.cpp:2295:5

    XMLWordPrintable

Details

    • Bug
    • Status: Open (View Workflow)
    • Major
    • Resolution: Unresolved
    • 3.2.8
    • None
    • General
    • None

    Description

      clang-22 resulted in this UBSAN error.

      master-fc15162aa22a3b3849152458b03c8f3821ad4b9b

      $ env | grep -E '(TEST|ODBC)'
      TEST_SCHEMA=test
      TEST_DRIVER=maodbc_test
      ODBCINI=./
      TEST_UID=root
      TEST_SERVER=mariadb
      TEST_VERBOSE=true
      ODBCSYSINI=./
      TEST_DSN=maodbc_test
      TEST_SKIP_UNSTABLE_TEST=1
       
      buildbot@e8ee074c88b8:/build/test$ ./odbc_basic 
      # DSN=maodbc_test;UID=root;PWD={********};PORT=3306;DATABASE=test;OPTION=67108866;SERVER=mariadb;
      /source/driver/ma_statement.cpp:2295:5: runtime error: applying non-zero offset 1216 to null pointer
          #0 0x7be568e8d1fb in MADB_StmtFetch(MADB_Stmt*) /source/driver/ma_statement.cpp:2295:5
          #1 0x7be568e9e1ad in MADB_StmtFetchScroll(MADB_Stmt*, short, long) /source/driver/ma_statement.cpp:4052:10
          #2 0x7be568e23c55 in MA_SQLFetch(void*) /source/driver/ma_api_internal.cpp:1229:38
          #3 0x7fe56c39d063 in SQLFetch (/lib/x86_64-linux-gnu/libodbc.so.2+0x19063) (BuildId: 19983c89f9a45564f023032b8a863bae99c742fa)
          #4 0x55878079e763 in ReadInfoOneTime /source/test/tap.h:1144:23
          #5 0x5587807a0641 in run_tests_ex /source/test/tap.h:1321:7
          #6 0x7fe56be22ca7  (/lib/x86_64-linux-gnu/libc.so.6+0x29ca7) (BuildId: 58749c528985eab03e6700ebc1469fa50aa41219)
          #7 0x7fe56be22d64 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29d64) (BuildId: 58749c528985eab03e6700ebc1469fa50aa41219)
          #8 0x5587806ac780 in _start (/build/test/odbc_basic+0x43780) (BuildId: 744efcc82c32d3b065af18818bf579bac3eacfe5)
       
      SUMMARY: UndefinedBehaviorSanitizer: nullptr-with-nonzero-offset /source/driver/ma_statement.cpp:2295:5 
      

      Test:

      $ podman network create odbctest
      odbctest
      $ podman run -d --rm --env MARIADB_ALLOW_EMPTY_ROOT_PASSWORD=1 --env MARIADB_DATABASE=test --name mariadb  --network odbctest  mariadb:lts
      $ podman run -v $PWD:/source:z \
        --rm \
        -ti \
        --entrypoint bash \
        --mount=type=tmpfs,tmpfs-size=10G,dst=/build \
        --workdir /build \
        --network odbctest  quay.io/mariadb-foundation/bb-worker:dev_debian13-msan-clang-22
       
      cmake -DWITH_ASAN=ON -DWITH_UBSAN=ON /source/
       cmake --build .
      cd test
      export SIDECAR_HOST=mariadb
      sed -i "s/localhost/$SIDECAR_HOST/" odbc.ini && export TEST_SERVER=$SIDECAR_HOST
      export TEST_SKIP_UNSTABLE_TEST=1
      export ODBCINI=odbc.ini
      export ODBCINI=./
      export TEST_UID=root
      export TEST_SCHEMA=test
      export TEST_VERBOSE=true
      export TEST_DRIVER=maodbc_test
      export TEST_DSN=maodbc_test
       export ODBCSYSINI=./
      ./odbc_basic 
      

      Addition to this UBSAN error:

      Even under UBSAN_OPTIONS=abort_on_error=1, the ./odbc_basic test completed with a successful return code.

      and in other tests

      ctest . --verbose
            Start  5: odbc_info
       
      5: Test command: /build/test/odbc_info
      5: Working Directory: /build/test
      5: Test timeout computed to be: 600
      5: /source/driver/ma_statement.cpp:2295:5: runtime error: applying non-zero offset 1216 to null pointer
      5:     #0 0x7b1f0028d1fb in MADB_StmtFetch(MADB_Stmt*) /source/driver/ma_statement.cpp:2295:5
      5:     #1 0x7b1f0029e1ad in MADB_StmtFetchScroll(MADB_Stmt*, short, long) /source/driver/ma_statement.cpp:4052:10
      5:     #2 0x7b1f00223c55 in MA_SQLFetch(void*) /source/driver/ma_api_internal.cpp:1229:38
      5:     #3 0x7f1f039aa063 in SQLFetch (/lib/x86_64-linux-gnu/libodbc.so.2+0x19063) (BuildId: 19983c89f9a45564f023032b8a863bae99c742fa)
      5:     #4 0x55a13e5f16b3 in ReadInfoOneTime /source/test/tap.h:1144:23
      5:     #5 0x55a13e5f3591 in run_tests_ex /source/test/tap.h:1321:7
      5:     #6 0x7f1f0342fca7  (/lib/x86_64-linux-gnu/libc.so.6+0x29ca7) (BuildId: 58749c528985eab03e6700ebc1469fa50aa41219)
      5:     #7 0x7f1f0342fd64 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29d64) (BuildId: 58749c528985eab03e6700ebc1469fa50aa41219)
      5:     #8 0x55a13e4ff6c0 in _start (/build/test/odbc_info+0x3b6c0) (BuildId: b659238eb24a4247407a2689b61df0207511293c)
      5: 
      5: SUMMARY: UndefinedBehaviorSanitizer: nullptr-with-nonzero-offset /source/driver/ma_statement.cpp:2295:5 
      5: # DSN=maodbc_test;UID=root;PWD={********};PORT=3306;DATABASE=test;OPTION=67108866;SERVER=mariadb;
      5: # DSN=maodbc_test;UID=root;PWD={********};PORT=3306;DATABASE=test;OPTION=67108866;SERVER=mariadb;
      5: 1..26
      5: ok 1 - t_gettypeinfo
      5: # 03.80 03.80
      5: ok 2 - sqlgetinfo
      5: ok 3 - t_stmt_attr_status
      5: # test test
      5: # test test
      5: ok 4 - t_msdev_bug
      5: # DSN=maodbc_test;UID=root;PWD={********};PORT=3306;DATABASE=test;OPTION=67108866;SERVER=mariadb;
      5: ok 5 - t_bug14639
      5: ok 6 - t_bug31055
      5: # DRIVER=maodbc_test;SERVER=mariadb;UID=root;PASSWORD=;PORT=3306;
      5: # null null
      5: # null null
      5: ok 7 - t_bug3780
      5: ok 8 - t_bug16653
      5: ok 9 - t_bug30626
      5: ok 10 - t_bug43855
      5: /source/driver/ma_result.cpp:33:10: runtime error: null pointer passed as argument 1, which is declared to never be null
      5: /usr/include/string.h:61:62: note: nonnull attribute specified here
      5:     #0 0x7b1f002b3f95 in MADB_StmtResetResultStructures(MADB_Stmt*) /source/driver/ma_result.cpp:33:3
      5:     #1 0x7b1f002b592f in MADB_StmtMoreResults(void*) /source/driver/ma_result.cpp:205:3
      5:     #2 0x7f1f039b25b7 in SQLMoreResults (/lib/x86_64-linux-gnu/libodbc.so.2+0x215b7) (BuildId: 19983c89f9a45564f023032b8a863bae99c742fa)
      5:     #3 0x55a13e5fce1f in t_bug46910 /source/test/info.c:422:10
      5:     #4 0x55a13e5f36fc in run_tests_ex /source/test/tap.h:1338:11
      5:     #5 0x7f1f0342fca7  (/lib/x86_64-linux-gnu/libc.so.6+0x29ca7) (BuildId: 58749c528985eab03e6700ebc1469fa50aa41219)
      5:     #6 0x7f1f0342fd64 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29d64) (BuildId: 58749c528985eab03e6700ebc1469fa50aa41219)
      5:     #7 0x55a13e4ff6c0 in _start (/build/test/odbc_info+0x3b6c0) (BuildId: b659238eb24a4247407a2689b61df0207511293c)
      5: 
      5: SUMMARY: UndefinedBehaviorSanitizer: invalid-null-argument /source/driver/ma_result.cpp:33:10 
      5: /source/driver/ma_result.cpp:36:10: runtime error: null pointer passed as argument 1, which is declared to never be null
      5: /usr/include/string.h:61:62: note: nonnull attribute specified here
      5:     #0 0x7b1f002b4011 in MADB_StmtResetResultStructures(MADB_Stmt*) /source/driver/ma_result.cpp:36:3
      5:     #1 0x7b1f002b592f in MADB_StmtMoreResults(void*) /source/driver/ma_result.cpp:205:3
      5:     #2 0x7f1f039b25b7 in SQLMoreResults (/lib/x86_64-linux-gnu/libodbc.so.2+0x215b7) (BuildId: 19983c89f9a45564f023032b8a863bae99c742fa)
      5:     #3 0x55a13e5fce1f in t_bug46910 /source/test/info.c:422:10
      5:     #4 0x55a13e5f36fc in run_tests_ex /source/test/tap.h:1338:11
      5:     #5 0x7f1f0342fca7  (/lib/x86_64-linux-gnu/libc.so.6+0x29ca7) (BuildId: 58749c528985eab03e6700ebc1469fa50aa41219)
      5:     #6 0x7f1f0342fd64 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29d64) (BuildId: 58749c528985eab03e6700ebc1469fa50aa41219)
      5:     #7 0x55a13e4ff6c0 in _start (/build/test/odbc_info+0x3b6c0) (BuildId: b659238eb24a4247407a2689b61df0207511293c)
      5: 
      5: SUMMARY: UndefinedBehaviorSanitizer: invalid-null-argument /source/driver/ma_result.cpp:36:10 
      

      And

      test 11
            Start 11: odbc_bulk
       
      11: ok 8 - t_bulk_delete
      11: /source/driver/ma_desc.h:95:87: runtime error: applying non-zero offset 8 to null pointer
      11:     #0 0x7ba3f5ecc266 in DescArrayIterator::move(unsigned long) /source/driver/ma_desc.h:95:87
      11:     #1 0x7ba3f5ec7895 in mariadb::FixedSizeCopyCodec::operator()(void*, st_mysql_bind*, unsigned int, unsigned int) /source/driver/ma_codec.cpp:80:8
      11:     #2 0x7ba3f5ef22bc in defaultParamCallback /source/driver/cppmini/class/ServerSidePreparedStatement.cpp:359:15
      11:     #3 0x7ba3f5ef1f75 in withRowCheckCallback /source/driver/cppmini/class/ServerSidePreparedStatement.cpp:385:14
      11:     #4 0x7ba3f5b7ed3e in ma_stmt_execute_generate_bulk_request /source/libmariadb/libmariadb/mariadb_stmt.c:1043:13
      11:     #5 0x7ba3f5b801a8 in ma_stmt_execute_generate_request /source/libmariadb/libmariadb/mariadb_stmt.c:1163:10
      11:     #6 0x7ba3f5b94495 in mysql_stmt_execute /source/libmariadb/libmariadb/mariadb_stmt.c:2217:20
      11:     #7 0x7ba3f5ef0bc5 in mariadb::ServerSidePreparedStatement::executeBatchInternal(unsigned int) /source/driver/cppmini/class/ServerSidePreparedStatement.cpp:183:17
      11:     #8 0x7ba3f5f32c6f in mariadb::PreparedStatement::executeBatch() /source/driver/cppmini/interface/PreparedStatement.cpp:172:5
      11:     #9 0x7ba3f5e7dd38 in MADB_Stmt::DoExecuteBatch() /source/driver/ma_statement.cpp:991:34
      11:     #10 0x7ba3f5ec56d5 in MADB_ExecuteBulk(MADB_Stmt*, unsigned int) /source/driver/ma_bulk.cpp:538:16
      11:     #11 0x7ba3f5e803e0 in MADB_StmtExecute(MADB_Stmt*, bool) /source/driver/ma_statement.cpp:1182:24
      11:     #12 0x7ba3f5e2204a in MA_SQLExecute(void*) /source/driver/ma_api_internal.cpp:1143:12
      11:     #13 0x7fa3f970d884 in SQLExecute (/lib/x86_64-linux-gnu/libodbc.so.2+0x18884) (BuildId: 19983c89f9a45564f023032b8a863bae99c742fa)
      11:     #14 0x55f2e4789730 in t_odbc149 /source/test/bulk.c:640:23
      11:     #15 0x55f2e477870c in run_tests_ex /source/test/tap.h:1338:11
      11:     #16 0x55f2e478fa7f in run_tests /source/test/tap.h:1395:10
      11:     #17 0x55f2e478fa7f in main /source/test/bulk.c:830:10
      11:     #18 0x7fa3f9193ca7  (/lib/x86_64-linux-gnu/libc.so.6+0x29ca7) (BuildId: 58749c528985eab03e6700ebc1469fa50aa41219)
      11:     #19 0x7fa3f9193d64 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29d64) (BuildId: 58749c528985eab03e6700ebc1469fa50aa41219)
      11:     #20 0x55f2e46846d0 in _start (/build/test/odbc_bulk+0x3b6d0) (BuildId: 7aef374936e5d416d2f5fc821be8fe9a58cfb23e)
      11: 
      11: SUMMARY: UndefinedBehaviorSanitizer: nullptr-with-nonzero-offset /source/driver/ma_desc.h:95:87 
      11: /source/driver/ma_desc.h:93:85: runtime error: applying non-zero offset 8 to null pointer
      11:     #0 0x7ba3f5ecc2db in DescArrayIterator::move(unsigned long) /source/driver/ma_desc.h:93:85
      11:     #1 0x7ba3f5ec7895 in mariadb::FixedSizeCopyCodec::operator()(void*, st_mysql_bind*, unsigned int, unsigned int) /source/driver/ma_codec.cpp:80:8
      11:     #2 0x7ba3f5ef22bc in defaultParamCallback /source/driver/cppmini/class/ServerSidePreparedStatement.cpp:359:15
      11:     #3 0x7ba3f5ef1f75 in withRowCheckCallback /source/driver/cppmini/class/ServerSidePreparedStatement.cpp:385:14
      11:     #4 0x7ba3f5b7ed3e in ma_stmt_execute_generate_bulk_request /source/libmariadb/libmariadb/mariadb_stmt.c:1043:13
      11:     #5 0x7ba3f5b801a8 in ma_stmt_execute_generate_request /source/libmariadb/libmariadb/mariadb_stmt.c:1163:10
      11:     #6 0x7ba3f5b94495 in mysql_stmt_execute /source/libmariadb/libmariadb/mariadb_stmt.c:2217:20
      11:     #7 0x7ba3f5ef0bc5 in mariadb::ServerSidePreparedStatement::executeBatchInternal(unsigned int) /source/driver/cppmini/class/ServerSidePreparedStatement.cpp:183:17
      11:     #8 0x7ba3f5f32c6f in mariadb::PreparedStatement::executeBatch() /source/driver/cppmini/interface/PreparedStatement.cpp:172:5
      11:     #9 0x7ba3f5e7dd38 in MADB_Stmt::DoExecuteBatch() /source/driver/ma_statement.cpp:991:34
      11:     #10 0x7ba3f5ec56d5 in MADB_ExecuteBulk(MADB_Stmt*, unsigned int) /source/driver/ma_bulk.cpp:538:16
      11:     #11 0x7ba3f5e803e0 in MADB_StmtExecute(MADB_Stmt*, bool) /source/driver/ma_statement.cpp:1182:24
      11:     #12 0x7ba3f5e2204a in MA_SQLExecute(void*) /source/driver/ma_api_internal.cpp:1143:12
      11:     #13 0x7fa3f970d884 in SQLExecute (/lib/x86_64-linux-gnu/libodbc.so.2+0x18884) (BuildId: 19983c89f9a45564f023032b8a863bae99c742fa)
      11:     #14 0x55f2e4789730 in t_odbc149 /source/test/bulk.c:640:23
      11:     #15 0x55f2e477870c in run_tests_ex /source/test/tap.h:1338:11
      11:     #16 0x55f2e478fa7f in run_tests /source/test/tap.h:1395:10
      11:     #17 0x55f2e478fa7f in main /source/test/bulk.c:830:10
      11:     #18 0x7fa3f9193ca7  (/lib/x86_64-linux-gnu/libc.so.6+0x29ca7) (BuildId: 58749c528985eab03e6700ebc1469fa50aa41219)
      11:     #19 0x7fa3f9193d64 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29d64) (BuildId: 58749c528985eab03e6700ebc1469fa50aa41219)
      11:     #20 0x55f2e46846d0 in _start (/build/test/odbc_bulk+0x3b6d0) (BuildId: 7aef374936e5d416d2f5fc821be8fe9a58cfb23e)
      11: 
      11: SUMMARY: UndefinedBehaviorSanitizer: nullptr-with-nonzero-offset /source/driver/ma_desc.h:93:85 
      

      libmariadb UndefinedBehaviourSanitizer errors from ODBC tests are in CONC-813.

      Attachments

        Issue Links

          Activity

            People

              Lawrin Lawrin Novitsky
              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.