[MDEV-19351] statistics_for_command_is_needed: Conditional jump or move depends on uninitialised value Created: 2019-04-27  Updated: 2019-04-30  Resolved: 2019-04-30

Status: Closed
Project: MariaDB Server
Component/s: Optimizer
Affects Version/s: 10.1, 10.2, 10.3, 10.4
Fix Version/s: 10.1.39

Type: Bug Priority: Major
Reporter: Elena Stepanova Assignee: Igor Babaev
Resolution: Fixed Votes: 0
Labels: None


 Description   

Run on a valgrind build:

perl ./mtr main.1st --valgrind-mysqld --mysqld=--use-stat-tables=PREFERABLY

10.1 3fe38574 Valgrind

==10062== Conditional jump or move depends on uninitialised value(s)
==10062==    at 0x686D14: statistics_for_command_is_needed(THD*) (sql_statistics.cc:2181)
==10062==    by 0x686E1D: alloc_statistics_for_table_share(THD*, TABLE_SHARE*, bool) (sql_statistics.cc:2260)
==10062==    by 0x576431: open_and_process_table(THD*, TABLE_LIST*, unsigned int*, unsigned int, Prelocking_strategy*, bool, Open_table_context*) (sql_base.cc:4249)
==10062==    by 0x577048: open_tables(THD*, DDL_options_st const&, TABLE_LIST**, unsigned int*, Sroutine_hash_entry**, unsigned int, Prelocking_strategy*) (sql_base.cc:4649)
==10062==    by 0x56E7FA: open_tables(THD*, DDL_options_st const&, TABLE_LIST**, unsigned int*, unsigned int, Prelocking_strategy*) (sql_base.h:264)
==10062==    by 0x578743: open_and_lock_tables(THD*, DDL_options_st const&, TABLE_LIST*, bool, unsigned int, Prelocking_strategy*) (sql_base.cc:5395)
==10062==    by 0x56B750: open_and_lock_tables(THD*, TABLE_LIST*, bool, unsigned int) (sql_base.h:555)
==10062==    by 0x5F639C: plugin_load(st_mem_root*) (sql_plugin.cc:1784)
==10062==    by 0x5F5D9D: plugin_init(int*, char**, int) (sql_plugin.cc:1662)
==10062==    by 0x50F6F1: init_server_components() (mysqld.cc:5183)
==10062==    by 0x5107AD: mysqld_main(int, char**) (mysqld.cc:5774)
==10062==    by 0x50592F: main (main.cc:25)
==10062== Conditional jump or move depends on uninitialised value(s)
==10062==    at 0x686D14: statistics_for_command_is_needed(THD*) (sql_statistics.cc:2181)
==10062==    by 0x6888E3: statistics_for_tables_is_needed(THD*, TABLE_LIST*) (sql_statistics.cc:3120)
==10062==    by 0x688DA2: read_statistics_for_tables_if_needed(THD*, TABLE_LIST*) (sql_statistics.cc:3261)
==10062==    by 0x5787D4: open_and_lock_tables(THD*, DDL_options_st const&, TABLE_LIST*, bool, unsigned int, Prelocking_strategy*) (sql_base.cc:5407)
==10062==    by 0x56B750: open_and_lock_tables(THD*, TABLE_LIST*, bool, unsigned int) (sql_base.h:555)
==10062==    by 0x5F639C: plugin_load(st_mem_root*) (sql_plugin.cc:1784)
==10062==    by 0x5F5D9D: plugin_init(int*, char**, int) (sql_plugin.cc:1662)
==10062==    by 0x50F6F1: init_server_components() (mysqld.cc:5183)
==10062==    by 0x5107AD: mysqld_main(int, char**) (mysqld.cc:5774)
==10062==    by 0x50592F: main (main.cc:25)
^ Found warnings in /data/bld/10.1-valgrind/mysql-test/var/log/mysqld.1.err
ok
 
 - saving '/data/bld/10.1-valgrind/mysql-test/var/log/main.1st/' to '/data/bld/10.1-valgrind/mysql-test/var/log/main.1st/'
***Warnings generated in error logs during shutdown after running tests: main.1st
 
==10062== Thread 6:
==10062== Conditional jump or move depends on uninitialised value(s)
==10062==    at 0x686D14: statistics_for_command_is_needed(THD*) (sql_statistics.cc:2181)
==10062==    by 0x6888E3: statistics_for_tables_is_needed(THD*, TABLE_LIST*) (sql_statistics.cc:3120)
==10062==    by 0x688DA2: read_statistics_for_tables_if_needed(THD*, TABLE_LIST*) (sql_statistics.cc:3261)
==10062==    by 0x6C16A7: mysql_multi_update_prepare(THD*) (sql_update.cc:1569)
==10062==    by 0x5E03ED: mysql_execute_command(THD*) (sql_parse.cc:3803)
==10062==    by 0x985A57: sp_instr_stmt::exec_core(THD*, unsigned int*) (sp_head.cc:3220)
==10062==    by 0x985149: sp_lex_keeper::reset_lex_and_exec_core(THD*, unsigned int*, bool, sp_instr*) (sp_head.cc:2986)
==10062==    by 0x98571D: sp_instr_stmt::execute(THD*, unsigned int*) (sp_head.cc:3136)
==10062==    by 0x980F7E: sp_head::execute(THD*, bool) (sp_head.cc:1317)
==10062==    by 0x982E1A: sp_head::execute_procedure(THD*, List<Item>*) (sp_head.cc:2104)
==10062==    by 0x5DC791: do_execute_sp(THD*, sp_head*) (sql_parse.cc:2464)
==10062==    by 0x5E57BC: mysql_execute_command(THD*) (sql_parse.cc:5293)
==10062==    by 0x5EB79C: mysql_parse(THD*, char*, unsigned int, Parser_state*) (sql_parse.cc:7459)
==10062==    by 0x5DA1A2: dispatch_command(enum_server_command, THD*, char*, unsigned int) (sql_parse.cc:1499)
==10062==    by 0x5D8F2D: do_command(THD*) (sql_parse.cc:1131)
==10062==    by 0x71A1B6: do_handle_one_connection(THD*) (sql_connect.cc:1330)

Also reproducible on 10.4, I didn't try 10.2 and 10.3, just assume it's there as well.

The problem appeared in 10.1 tree with this commit:

commit 279a907fd0dea30be6d11fc4a5d63b1b98d0b329
Commit:     Igor Babaev
CommitDate: Mon Apr 22 17:11:07 2019 -0700
 
    MDEV-17605 Statistics for InnoDB table is wrong if persistent statistics is used



 Comments   
Comment by Varun Gupta (Inactive) [ 2019-04-29 ]

I checked on commit

commit 3fe38574fbddd0594ac8ad8da10049a47cca6879 (HEAD -> 10.1, origin/10.1)
Author: Sergei Golubchik <serg@mariadb.org>
Date: Sat Apr 27 04:49:04 2019 +0200

gis2 fails in embedded

move privilege specific part of gis2.test to gis_notembedded.test
and the rest to gis.test

and when I run main.stat_tables then I see the same valgrind warnings

Now running after the fix was pushed

==============================================================================
 
TEST                                      RESULT   TIME (ms) or COMMENT
--------------------------------------------------------------------------
 
worker[1] Using MTR_BUILD_THREAD 300, with reserved ports 16000..16019
main.stat_tables                         [ pass ]  176872
valgrind_report                          [ pass ]       
--------------------------------------------------------------------------
The servers were restarted 0 times
Spent 176.872 of 200 seconds executing testcases
 
Completed: All 2 tests were successful.

Comment by Vladislav Vaintroub [ 2019-04-29 ]

If I cherry-pick the commit into 10.4, it fixes failing audit_null test on Windows.

Comment by Igor Babaev [ 2019-04-30 ]

A fix for this bug was pushed into 10.1 and cherry-picked into 10.4.
The patch should be merged into 10.2, 10.3 as it is.

Generated at Thu Feb 08 08:51:01 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.