[MDEV-21297] storage/connect/reldef.cpp compilation fails in debug mode Created: 2019-12-12  Updated: 2021-05-06  Resolved: 2021-05-06

Status: Closed
Project: MariaDB Server
Component/s: Compiling
Affects Version/s: 10.2, 10.3
Fix Version/s: 10.2.39, 10.3.30

Type: Bug Priority: Major
Reporter: Alexey Bychko (Inactive) Assignee: Timofey Turenko
Resolution: Fixed Votes: 0
Labels: Werror
Environment:

ubuntu-1604 docker


Attachments: Text File console.log    

 Description   

In file included from /usr/include/string.h:635:0,
                 from /tmp/es-build/include/m_string.h:35,
                 from /tmp/es-build/include/my_sys.h:22,
                 from /tmp/es-build/sql/sql_bitmap.h:26,
                 from /tmp/es-build/sql/mysqld.h:23,
                 from /tmp/es-build/sql/handler.h:31,
                 from /tmp/es-build/storage/connect/reldef.cpp:27:
In function 'char* strncat(char*, const char*, size_t)',
    inlined from 'TABDEF* OEMDEF::GetXdef(PGLOBAL)' at /tmp/es-build/storage/connect/reldef.cpp:503:63:
/usr/include/x86_64-linux-gnu/bits/string3.h:156:71: error: call to char* __builtin___strncat_chk(char*, const char*, long unsigned int, long unsigned int) might overflow destination buffer [-Werror]
   return __builtin___strncat_chk (__dest, __src, __len, __bos (__dest));
                                                                       ^
[ 58%] Building CXX object storage/rocksdb/CMakeFiles/rocksdblib.dir/rocksdb/env/env_posix.cc.o
cd /tmp/es-build/build/storage/rocksdb && /usr/bin/c++   -DHAVE_CONFIG_H -DHAVE_SCHED_GETCPU=1 -DHAVE_TIMER_DELETE -DOS_LINUX -DROCKSDB_FALLOCATE_PRESENT -DROCKSDB_LIB_IO_POSIX -DROCKSDB_MALLOC_USABLE_SIZE -DROCKSDB_PLATFORM_POSIX -DROCKSDB_SCHED_GETCPU_PRESENT -DROCKSDB_SUPPORT_THREAD_LOCAL -DSNAPPY -DZLIB -DZSTD -D_FILE_OFFSET_BITS=64 -I/tmp/es-build/build/include -I/tmp/es-build/include -I/tmp/es-build/sql -I/tmp/es-build/build/pcre -I/tmp/es-build/pcre -I/tmp/es-build/zlib -I/tmp/es-build/build/zlib -I/tmp/es-build/build/storage/rocksdb -I/tmp/es-build/storage/rocksdb/rocksdb -I/tmp/es-build/storage/rocksdb/rocksdb/include -isystem /tmp/es-build/storage/rocksdb/rocksdb/third-party/gtest-1.7.0/fused-src -I/tmp/es-build/storage/rocksdb/rocksdb/util  -pie -fPIC -Wl,-z,relro,-z,now -fstack-protector --param=ssp-buffer-size=4 -fPIC -fno-rtti -O -g -static-libgcc -fno-omit-frame-pointer -fno-strict-aliasing -Wno-uninitialized -DENABLED_DEBUG_SYNC -ggdb3 -DSAFE_MUTEX -DSAFEMALLOC -Wall -Wextra -Wformat-security -Wno-init-self -Wno-unused-parameter -Woverloaded-virtual -Wvla -Wwrite-strings -Werror -Wno-error=maybe-uninitialized   -fPIC -fno-builtin-memcmp -frtti -std=gnu++11 -o CMakeFiles/rocksdblib.dir/rocksdb/env/env_posix.cc.o -c /tmp/es-build/storage/rocksdb/rocksdb/env/env_posix.cc
cc1plus: all warnings being treated as errors
storage/connect/CMakeFiles/connect.dir/build.make:638: recipe for target 'storage/connect/CMakeFiles/connect.dir/reldef.cpp.o' failed
make[2]: *** [storage/connect/CMakeFiles/connect.dir/reldef.cpp.o] Error 1
make[2]: Leaving directory '/tmp/es-build/build'
CMakeFiles/Makefile2:3472: recipe for target 'storage/connect/CMakeFiles/connect.dir/all' failed
make[1]: *** [storage/connect/CMakeFiles/connect.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....



 Comments   
Comment by Alexander Barkov [ 2019-12-12 ]

Hi bertrandop,
Can you please fix this?

In the MariaDB code we avoid using strcat()/strncat(), as they are slow and unsafe.

Please use strxnmov() or my_snprintf() instead.
Some examples:

    strxnmov(path, FN_REFLEN-1, mysql_real_data_home, thd->db ? thd->db : "",
             NullS)

  my_snprintf(p, bufflen - (p - buff), "/%s%lx_%llx_%x",
              tmp_file_prefix, current_pid,
              thd->thread_id, thd->tmp_table++);

Comment by Olivier Bertrand [ 2019-12-12 ]

Apparently the compilation only failed in this particular example because all warnings were treated as errors. Nowhere else did this occured, for instance on buildbot.

I 'd be glad to get rid of strcat, strncat, especially strncat that is cumbersome to use. The problem is that the CONNECT code contains about three hundred use of these functions. To fix all these without the risk of making potential errors that would make CONNECT unstable will require more than just doing manually these changes. Any idea?

Comment by Alexey Bychko (Inactive) [ 2019-12-12 ]

Nowhere else did this occured, for instance on buildbot.

yes, it may be disabled with -DMYSQL_MAINTAINER_MODE=OFF, which is current workaround

Comment by Julien Fritsch [ 2020-01-02 ]

What is the status of this one, please?

Comment by Olivier Bertrand [ 2020-01-02 ]

Will be progressively done in long term. Don't expect miracles.

Generated at Thu Feb 08 09:06:04 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.