server
server copied to clipboard
draft on checking a bit more strictness
- [x] The Jira issue number for this PR is: MDEV-______ (not yet)
Description
Hiding over uninitialised variable seems to be from detection bugs in old compilers. More imporant, its leading to current undefined behaviour. Lets see if that's still the case.
e.g.:
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /home/dan/repos/mariadb-server-11.8/mysys/mf_iocache.c:1793:39
=================================================================
==2772984==ERROR: AddressSanitizer: use-after-poison on address 0x52d0003370b0 at pc 0x000000d6cc9c bp 0x7fff321294f0 sp 0x7fff321294e8
READ of size 8 at 0x52d0003370b0 thread T0
#0 0x000000d6cc9b in multi_update::num_found() const /home/dan/repos/mariadb-server-11.8/sql/sql_class.h:7665:45
#1 0x000000d6cc9b in MYSQL_DML_DONE(THD*, int) /home/dan/repos/mariadb-server-11.8/sql/sql_select.cc:34329:5
#2 0x000000d6af0d in Sql_cmd_dml::execute(THD*) /home/dan/repos/mariadb-server-11.8/sql/sql_select.cc:34504:3
#3 0x000000b0f5ef in mysql_execute_command(THD*, bool) /home/dan/repos/mariadb-server-11.8/sql/sql_parse.cc:4428:27
#4 0x000000af38fc in mysql_parse(THD*, char*, unsigned int, Parser_state*) /home/dan/repos/mariadb-server-11.8/sql/sql_parse.cc:7915:18
#5 0x000000af15d7 in bootstrap(st_mysql_file*) /home/dan/repos/mariadb-server-11.8/sql/sql_parse.cc:1090:5
#6 0x000000603dd5 in mysqld_main(int, char**) /home/dan/repos/mariadb-server-11.8/sql/mysqld.cc:6091:26
#7 0x7f3142a10247 in __libc_start_call_main (/lib64/libc.so.6+0x3247) (BuildId: f83d43b9b4b0ed5c2bd0a1613bf33e08ee054c93)
#8 0x7f3142a1030a in __libc_start_main@GLIBC_2.2.5 (/lib64/libc.so.6+0x330a) (BuildId: f83d43b9b4b0ed5c2bd0a1613bf33e08ee054c93)
#9 0x00000051a7b4 in _start (/home/dan/repos/build-mariadb-server-11.8/sql/mariadbd+0x51a7b4) (BuildId: 365124ed2d3a4abc252a508657b91cd007b3c1d6)
Put nonnull on the character set as its rather pointless to to do comparisons with null pointers and the approprate logic to take was undoubtedly at a higher level.
/home/dan/repos/mariadb-server-11.8/include/m_ctype.h:1949:33: runtime error: null pointer passed as argument 1, which is declared to never be null
/home/dan/repos/mariadb-server-11.8/include/m_ctype.h:1035:65: note: nonnull attribute specified here
#0 0x000000700974 in Well_formed_prefix_status::Well_formed_prefix_status(charset_info_st const*, char const*, char const*, unsigned long) /home/dan/repos/mariadb-server-11.8/include/m_ctype.h:1949:9
#1 0x000000b476dc in Well_formed_prefix::Well_formed_prefix(charset_info_st const*, char const*, unsigned long, unsigned long) /home/dan/repos/mariadb-server-11.8/include/m_ctype.h:1963:5
#2 0x000000b476dc in check_string_char_length(st_mysql_const_lex_string const*, unsigned int, unsigned long, charset_info_st const*, bool) /home/dan/repos/mariadb-server-11.8/sql/sql_parse.cc:10118:22
#3 0x000000b34aea in check_ident_length(st_mysql_const_lex_string const*) /home/dan/repos/mariadb-server-11.8/sql/sql_parse.cc:10136:7
#4 0x000000e927e4 in mysql_prepare_create_table_finalize(THD*, HA_CREATE_INFO*, Alter_info*, unsigned int*, handler*, st_key**, unsigned int*, int) /home/dan/repos/mariadb-server-11.8/sql/sql_table.cc:3452:9
#5 0x000000e8e121 in mysql_create_frm_image(THD*, HA_CREATE_INFO*, Alter_info*, int, st_key**, unsigned int*, st_mysql_const_unsigned_lex_string*) /home/dan/repos/mariadb-server-11.8/sql/sql_table.cc:4544:7
#6 0x000000e9d154 in create_table_impl(THD*, st_ddl_log_state*, st_ddl_log_state*, Lex_ident_db const&, Lex_ident_table const&, st_mysql_const_lex_string const&, st_mysql_const_lex_string const&, st_mysql_const_lex_string const&, DDL_options_st, HA_CREATE_INFO*, Alter_info*, int, bool*, st_key**, unsigned int*, st_mysql_const_unsigned_lex_string*) /home/dan/repos/mariadb-server-11.8/sql/sql_table.cc:4866:11
#7 0x000000e9b4b0 in mysql_create_table_no_lock(THD*, st_ddl_log_state*, st_ddl_log_state*, Table_specification_st*, Alter_info*, bool*, int, TABLE_LIST*) /home/dan/repos/mariadb-server-11.8/sql/sql_table.cc:4991:8
#8 0x000000ef2c3a in mysql_create_table(THD*, TABLE_LIST*, Table_specification_st*, Alter_info*) /home/dan/repos/mariadb-server-11.8/sql/sql_table.cc:5233:7
#9 0x000000eed278 in Sql_cmd_create_table_like::execute(THD*) /home/dan/repos/mariadb-server-11.8/sql/sql_table.cc:13624:12
#10 0x000000b0efea in mysql_execute_command(THD*, bool) /home/dan/repos/mariadb-server-11.8/sql/sql_parse.cc:5886:26
#11 0x000000af38fc in mysql_parse(THD*, char*, unsigned int, Parser_state*) /home/dan/repos/mariadb-server-11.8/sql/sql_parse.cc:7915:18
#12 0x000000af15d7 in bootstrap(st_mysql_file*) /home/dan/repos/mariadb-server-11.8/sql/sql_parse.cc:1090:5
#13 0x000000603dd5 in mysqld_main(int, char**) /home/dan/repos/mariadb-server-11.8/sql/mysqld.cc:6091:26
#14 0x7f3142a10247 in __libc_start_call_main (/lib64/libc.so.6+0x3247) (BuildId: f83d43b9b4b0ed5c2bd0a1613bf33e08ee054c93)
#15 0x7f3142a1030a in __libc_start_main@GLIBC_2.2.5 (/lib64/libc.so.6+0x330a) (BuildId: f83d43b9b4b0ed5c2bd0a1613bf33e08ee054c93)
#16 0x00000051a7b4 in _start (/home/dan/repos/build-mariadb-server-11.8/sql/mariadbd+0x51a7b4) (BuildId: 365124ed2d3a4abc252a508657b91cd007b3c1d6)
Where are the errors?
mysql-test/mtr --mem --boot-gdb='b __asan_report_error;b __ubsan::ScopedReport::~ScopedReport;r' main.select
And remove boot- one those are found/ignored.
Release Notes
draft only - not for release
How can this PR be tested?
existing mtr tests.
Though -DWITH_ASAN=ON -DWITH_UBSAN=ON -DWITH_ASAN_SCOPE=ON -DPLUGIN_PERFSCHEMA=NO -DPLUGIN_MROONGA=NO -DCMAKE_BUILD_TYPE=Debug -DWITH_DBUG_TRACE=OFF under modern clang highlight calls.
TODO: modify the automated test suite to verify that the PR causes MariaDB to behave as intended. Consult the documentation on "Writing good test cases".
If the changes are not amenable to automated testing, please explain why not and carefully describe how to test manually.
Basing the PR against the correct MariaDB version
- [ ] This is a new feature or a refactoring, and the PR is based against the
mainbranch. - [ ] This is a bug fix, and the PR is based against the earliest maintained branch in which the bug can be reproduced.
PR quality check
- [ ] I checked the CODING_STANDARDS.md file and my PR conforms to this where appropriate.
- [ ] For any trivial modifications to the PR, I am ok with the reviewer making the changes themselves.