Bug #83251 Cond. jump depends on uninitialised values at check_ulonglong by get_ev_num_info
Submitted: 4 Oct 2016 10:01 Modified: 2 Jan 2020 22:50
Reporter: Tomislav Plavcic Email Updates:
Status: Can't repeat Impact on me:
None 
Category:MySQL Server: DML Severity:S3 (Non-critical)
Version:5.7.15, 5.5.52, 5.6.33 OS:Any
Assigned to: CPU Architecture:Any

[4 Oct 2016 10:01] Tomislav Plavcic
Description:
Observed this valgrind issue with 5.7.15:
2016-10-04T09:39:02.177077Z 0 [Note] /home/tomislav.plavcic/workdir/mysql-5.7.15-linux-x86_64-debug-valgrind-71f48ab/bin/mysqld: ready for connections.
Version: '5.7.15-debug-valgrind'  socket: '/home/tomislav.plavcic/workdir/mysql-5.7.15-linux-x86_64-debug-valgrind-71f48ab/socket.sock'  port: 16692  MySQL Community Server (GPL)
==23339== Thread 28:
==23339== Conditional jump or move depends on uninitialised value(s)
==23339==    at 0x1720FA2: check_ulonglong(char const*, unsigned int) (sql_analyse.cc:1192)
==23339==    by 0x171C655: get_ev_num_info(st_extreme_value_number_info*, st_number_info*, char const*) (sql_analyse.cc:232)
==23339==    by 0x171C92A: field_str::add() (sql_analyse.cc:281)
==23339==    by 0x171DF03: Query_result_analyse::send_data(List<Item>&) (sql_analyse.cc:614)
==23339==    by 0x14BB836: end_send(JOIN*, QEP_TAB*, bool) (sql_executor.cc:2907)
==23339==    by 0x14B84A8: evaluate_join_record(JOIN*, QEP_TAB*) (sql_executor.cc:1639)
==23339==    by 0x14B78E8: sub_select(JOIN*, QEP_TAB*, bool) (sql_executor.cc:1291)
==23339==    by 0x14B7169: do_select(JOIN*) (sql_executor.cc:944)
==23339==    by 0x14B50EA: JOIN::exec() (sql_executor.cc:199)
==23339==    by 0x1551BD9: handle_query(THD*, LEX*, Query_result*, unsigned long long, unsigned long long) (sql_select.cc:184)
==23339==    by 0x1506285: execute_sqlcom_select(THD*, TABLE_LIST*) (sql_parse.cc:5143)
==23339==    by 0x14FF89F: mysql_execute_command(THD*, bool) (sql_parse.cc:2756)
==23339==    by 0x1507194: mysql_parse(THD*, Parser_state*) (sql_parse.cc:5559)
==23339==    by 0x14FC730: dispatch_command(THD*, COM_DATA const*, enum_server_command) (sql_parse.cc:1427)
==23339==    by 0x14FB5FA: do_command(THD*) (sql_parse.cc:995)
==23339==    by 0x1631FBF: handle_connection (connection_handler_per_thread.cc:300)
==23339==    by 0x1CD5E4B: pfs_spawn_thread (pfs.cc:2188)
==23339==    by 0x5075DC4: start_thread (pthread_create.c:308)
==23339==    by 0x6E5CCEC: clone (clone.S:113)
==23339== 

How to repeat:
Build server with valgrind instrumentation and run under valgrind.

TEST CASES:
===========
DROP DATABASE test;CREATE DATABASE test;USE test;
CREATE TABLE t (a varchar(2));
INSERT INTO t values ('00');
select * from t procedure analyse();

DROP DATABASE test;CREATE DATABASE test;USE test;
CREATE TABLE t0 AS SELECT HEX(0x0) AS c;
select * from t0 procedure analyse();

DROP DATABASE test;CREATE DATABASE test;USE test;
CREATE TABLE t (a varchar(3));
INSERT INTO t values ('000');
select * from t procedure analyse();

INVALID CASES:
==============
DROP DATABASE test;CREATE DATABASE test;USE test;
CREATE TABLE t (a varchar(1));
INSERT INTO t values ('0');
select * from t procedure analyse();

DROP DATABASE test;CREATE DATABASE test;USE test;
CREATE TABLE t (a varchar(2));
INSERT INTO t values ('11');
select * from t procedure analyse();

Suggested fix:
Fix visible valgrind issue.
[4 Oct 2016 10:40] Tomislav Plavcic
The issue is visible in 5.5.52 and 5.6.33.
[4 Oct 2016 10:47] MySQL Verification Team
Hello Tomislav,

Thank you for the report.
Observed this with 5.7.15.

Thanks,
Umesh
[4 Oct 2016 10:47] MySQL Verification Team
--
cmake .  -DWITH_VALGRIND=1  -DWITH_DEBUG=1 -DWITH_BOOST=./boost/
make -j32

./mtr --valgrind bug83251
Logging: ./mtr  --valgrind bug83251
MySQL Version 5.7.15
Turning on valgrind for all executables
Running valgrind with options " --show-reachable=yes "
Turning off --check-testcases to save time when valgrinding
Checking supported features...
 - SSL connections supported
 - binaries are debug compiled
Collecting tests...
Checking leftover processes...
Removing old var directory...
Creating var directory '/export/umesh/server/source/bugs/mysql-5.7.15/mysql-test/var'...
Installing system database...
Using parallel: 1

==============================================================================

TEST                                      RESULT   TIME (ms) or COMMENT
--------------------------------------------------------------------------

worker[1] Using MTR_BUILD_THREAD 300, with reserved ports 13000..13009
.
.
main.bug83251                            [ fail ]  Found warnings/errors in server log file!
        Test ended at 2016-10-04 12:44:47
line
==14839== Thread 24:
==14839== Conditional jump or move depends on uninitialised value(s)
==14839==    at 0x17484EE: check_ulonglong(char const*, unsigned int) (sql_analyse.cc:1192)
==14839==    by 0x1743BA1: get_ev_num_info(st_extreme_value_number_info*, st_number_info*, char const*) (sql_analyse.cc:232)
==14839==    by 0x1743E76: field_str::add() (sql_analyse.cc:281)
==14839==    by 0x174544F: Query_result_analyse::send_data(List<Item>&) (sql_analyse.cc:614)
==14839==    by 0x14E35C6: end_send(JOIN*, QEP_TAB*, bool) (sql_executor.cc:2907)
==14839==    by 0x14E0238: evaluate_join_record(JOIN*, QEP_TAB*) (sql_executor.cc:1639)
==14839==    by 0x14DF678: sub_select(JOIN*, QEP_TAB*, bool) (sql_executor.cc:1291)
==14839==    by 0x14DEEF9: do_select(JOIN*) (sql_executor.cc:944)
==14839==    by 0x14DCE7A: JOIN::exec() (sql_executor.cc:199)
==14839==    by 0x1579969: handle_query(THD*, LEX*, Query_result*, unsigned long long, unsigned long long) (sql_select.cc:184)
==14839==    by 0x152E015: execute_sqlcom_select(THD*, TABLE_LIST*) (sql_parse.cc:5143)
==14839==    by 0x152762F: mysql_execute_command(THD*, bool) (sql_parse.cc:2756)
==14839==    by 0x152EF24: mysql_parse(THD*, Parser_state*) (sql_parse.cc:5559)
==14839==    by 0x15244C0: dispatch_command(THD*, COM_DATA const*, enum_server_command) (sql_parse.cc:1427)
==14839==    by 0x152338A: do_command(THD*) (sql_parse.cc:995)
==14839==    by 0x16595CB: handle_connection (connection_handler_per_thread.cc:300)
^ Found warnings in /export/umesh/server/source/bugs/mysql-5.7.15/mysql-test/var/log/mysqld.1.err
ok

 - the logfile can be found in '/export/umesh/server/source/bugs/mysql-5.7.15/mysql-test/var/log/main.bug83251/bug83251.log'
worker[1] Valgrind report from /export/umesh/server/source/bugs/mysql-5.7.15/mysql-test/var/log/mysqld.1.err after tests:
 main.bug83251
[2 Jan 2020 22:50] Roy Lyseng
Posted by developer:
 
Feature PROCEDURE ANALYSE has been removed.