==30146== by 0x6C763C: handle_select(THD*, LEX*, select_result*, unsigned long) (sql_select.cc:373)
==30146== by 0x65683D: execute_sqlcom_select(THD*, TABLE_LIST*) (sql_parse.cc:5261)
==30146== by 0x658C65: mysql_execute_command(THD*) (sql_parse.cc:2545)
==30146== by 0x6607E7: mysql_parse(THD*, char*, unsigned int, Parser_state*) (sql_parse.cc:6407)
==30146== by 0x661351: dispatch_command(enum_server_command, THD*, char*, unsigned int) (sql_parse.cc:1299)
==30146== by 0x662BF9: do_command(THD*) (sql_parse.cc:996)
==30146== by 0x76E5DA: do_handle_one_connection(THD*) (sql_connect.cc:1379)
==30146== by 0x76E6CB: handle_one_connection (sql_connect.cc:1293)
==30146== by 0xA2DB2D: pfs_spawn_thread (pfs.cc:1860)
==30146== by 0x4E3506F: start_thread (in /lib64/libpthread-2.9.so)
==30146== by 0x62F913C: clone (in /lib64/libc-2.9.so)
^ Found warnings in /home/psergey/dev2/10.0-vg/mysql-test/var/log/mysqld.1.err
ok
Sergei Petrunia
added a comment - When I run the test on its own, I get a different failure:
worker[1] Using MTR_BUILD_THREAD 306, with reserved ports 16120..16139
main.ctype_cp932 [ fail ] Found warnings/errors in server log file!
Test ended at 2014-11-12 15:52:54
line
==30146== Thread 4:
==30146== Source and destination overlap in memcpy(0xc8742f8, 0xc8742f8, 20)
==30146== at 0x4C2810E: memcpy (mc_replace_strmem.c:878)
==30146== by 0x6C6658: JOIN::exec_inner() (sql_select.cc:2892)
==30146== by 0x6C3A42: JOIN::exec() (sql_select.cc:2370)
==30146== by 0x6C3F08: mysql_select(THD*, Item***, TABLE_LIST*, unsigned int, List<Item>&, Item*, unsigned int, st_order*, st_order*, Item*, st_order*, unsigned long long, select_result*, st_select_lex_unit*, st_select_lex*) (sql_select.cc:3308)
==30146== by 0x6C763C: handle_select(THD*, LEX*, select_result*, unsigned long) (sql_select.cc:373)
==30146== by 0x65683D: execute_sqlcom_select(THD*, TABLE_LIST*) (sql_parse.cc:5261)
==30146== by 0x658C65: mysql_execute_command(THD*) (sql_parse.cc:2545)
==30146== by 0x6607E7: mysql_parse(THD*, char*, unsigned int, Parser_state*) (sql_parse.cc:6407)
==30146== by 0x661351: dispatch_command(enum_server_command, THD*, char*, unsigned int) (sql_parse.cc:1299)
==30146== by 0x662BF9: do_command(THD*) (sql_parse.cc:996)
==30146== by 0x76E5DA: do_handle_one_connection(THD*) (sql_connect.cc:1379)
==30146== by 0x76E6CB: handle_one_connection (sql_connect.cc:1293)
==30146== by 0xA2DB2D: pfs_spawn_thread (pfs.cc:1860)
==30146== by 0x4E3506F: start_thread (in /lib64/libpthread-2.9.so)
==30146== by 0x62F913C: clone (in /lib64/libc-2.9.so)
==30146== Source and destination overlap in memcpy(0xc874340, 0xc874340, 20)
==30146== at 0x4C2810E: memcpy (mc_replace_strmem.c:878)
==30146== by 0x6C667E: JOIN::exec_inner() (sql_select.cc:2893)
==30146== by 0x6C3A42: JOIN::exec() (sql_select.cc:2370)
==30146== by 0x6C3F08: mysql_select(THD*, Item***, TABLE_LIST*, unsigned int, List<Item>&, Item*, unsigned int, st_order*, st_order*, Item*, st_order*, unsigned long long, select_result*, st_select_lex_unit*, st_select_lex*) (sql_select.cc:3308)
==30146== by 0x6C763C: handle_select(THD*, LEX*, select_result*, unsigned long) (sql_select.cc:373)
==30146== by 0x65683D: execute_sqlcom_select(THD*, TABLE_LIST*) (sql_parse.cc:5261)
==30146== by 0x658C65: mysql_execute_command(THD*) (sql_parse.cc:2545)
==30146== by 0x6607E7: mysql_parse(THD*, char*, unsigned int, Parser_state*) (sql_parse.cc:6407)
==30146== by 0x661351: dispatch_command(enum_server_command, THD*, char*, unsigned int) (sql_parse.cc:1299)
==30146== by 0x662BF9: do_command(THD*) (sql_parse.cc:996)
==30146== by 0x76E5DA: do_handle_one_connection(THD*) (sql_connect.cc:1379)
==30146== by 0x76E6CB: handle_one_connection (sql_connect.cc:1293)
==30146== by 0xA2DB2D: pfs_spawn_thread (pfs.cc:1860)
==30146== by 0x4E3506F: start_thread (in /lib64/libpthread-2.9.so)
==30146== by 0x62F913C: clone (in /lib64/libc-2.9.so)
^ Found warnings in /home/psergey/dev2/10.0-vg/mysql-test/var/log/mysqld.1.err
ok
Hmm.. after re-compling the tree exactly like the buildbot does, this new failure is gone, and I get a failure just like in the report.
Sergei Petrunia
added a comment - Hmm.. after re-compling the tree exactly like the buildbot does, this new failure is gone, and I get a failure just like in the report.
Sergei Petrunia
added a comment - The testcase that fails was added by this cset:
revno: 4443 [merge]
committer: Sergei Golubchik <sergii@pisem.net>
branch nick: 10.0
timestamp: Sat 2014-10-11 12:52:55 +0200
message:
merge
on the last line we have wildstr == wildend, but we still access wildstr[0], the byte beyond the end of the patter. In MariaDB-10.0 this causes a valgrind failure.
In mysql-5.5, the code inside my_wildcmp_mb_bin_impl executes in exactly the same way. However, the pattern string is zero-terminated and we dont get the valgrind failure.
I guess this could be fixed by either
1. Changing the calling convention of my_wildcmp_mb_bin_impl() to imply that the pattern string is null-terminated (let Item_func_like::val_int() call c_ptr_safe() on the pattern)
2. Changing the condition
} while (str != str_end && wildstr[0] != w_many);
to not access wildstr[0] when wildstr==wildstr_end.
I am not sure which is better.
Sergei Petrunia
added a comment - Ok, so we are running this query:
SELECT * FROM t1 WHERE a LIKE '%カ'
and in my_wildcmp_mb_bin_impl we reach this code:
{
int tmp=my_wildcmp_mb_bin_impl(cs,str,str_end,
wildstr,wildend,escape,
w_one,w_many, recurse_level+1);
if (tmp <= 0)
return (tmp);
}
} while (str != str_end && wildstr[0] != w_many);
on the last line we have wildstr == wildend, but we still access wildstr [0] , the byte beyond the end of the patter. In MariaDB-10.0 this causes a valgrind failure.
In mysql-5.5, the code inside my_wildcmp_mb_bin_impl executes in exactly the same way. However, the pattern string is zero-terminated and we dont get the valgrind failure.
I guess this could be fixed by either
1. Changing the calling convention of my_wildcmp_mb_bin_impl() to imply that the pattern string is null-terminated (let Item_func_like::val_int() call c_ptr_safe() on the pattern)
2. Changing the condition
} while (str != str_end && wildstr[0] != w_many);
to not access wildstr [0] when wildstr==wildstr_end.
I am not sure which is better.
The problem is also repeatable with ascii characters in a cp932_bin column:
SET names utf8;
DROPTABLEIF EXISTS t1;
CREATETABLE t1 (a VARCHAR(10) COLLATE cp932_bin);
INSERTINTO t1 VALUES('aa');
SELECT * FROM t1 WHERE a LIKE'%a';
and with the default collation for cp932:
SET names utf8;
DROPTABLEIF EXISTS t1;
CREATETABLE t1 (a VARCHAR(10) CHARACTERSET cp932);
INSERTINTO t1 VALUES('aa');
SELECT * FROM t1 WHERE a LIKE'%a';
Alexander Barkov
added a comment - The problem is also repeatable with ascii characters in a cp932_bin column:
SET names utf8;
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (a VARCHAR (10) COLLATE cp932_bin);
INSERT INTO t1 VALUES ( 'aa' );
SELECT * FROM t1 WHERE a LIKE '%a' ;
and with the default collation for cp932:
SET names utf8;
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (a VARCHAR (10) CHARACTER SET cp932);
INSERT INTO t1 VALUES ( 'aa' );
SELECT * FROM t1 WHERE a LIKE '%a' ;
CREATETABLE t1 (a VARCHAR(10) CHARACTERSET latin1);
INSERTINTO t1 VALUES('aa');
SELECT * FROM t1 WHERE a LIKE'%a';
Alexander Barkov
added a comment - Also repeatable with latin1 character set:
SET names utf8;
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (a VARCHAR (10) CHARACTER SET latin1);
INSERT INTO t1 VALUES ( 'aa' );
SELECT * FROM t1 WHERE a LIKE '%a' ;
When I run the test on its own, I get a different failure:
worker[1] Using MTR_BUILD_THREAD 306, with reserved ports 16120..16139
main.ctype_cp932 [ fail ] Found warnings/errors in server log file!
Test ended at 2014-11-12 15:52:54
line
==30146== Thread 4:
==30146== Source and destination overlap in memcpy(0xc8742f8, 0xc8742f8, 20)
==30146== at 0x4C2810E: memcpy (mc_replace_strmem.c:878)
==30146== by 0x6C6658: JOIN::exec_inner() (sql_select.cc:2892)
==30146== by 0x6C3A42: JOIN::exec() (sql_select.cc:2370)
==30146== by 0x6C3F08: mysql_select(THD*, Item***, TABLE_LIST*, unsigned int, List<Item>&, Item*, unsigned int, st_order*, st_order*, Item*, st_order*, unsigned long long, select_result*, st_select_lex_unit*, st_select_lex*) (sql_select.cc:3308)
==30146== by 0x6C763C: handle_select(THD*, LEX*, select_result*, unsigned long) (sql_select.cc:373)
==30146== by 0x65683D: execute_sqlcom_select(THD*, TABLE_LIST*) (sql_parse.cc:5261)
==30146== by 0x658C65: mysql_execute_command(THD*) (sql_parse.cc:2545)
==30146== by 0x6607E7: mysql_parse(THD*, char*, unsigned int, Parser_state*) (sql_parse.cc:6407)
==30146== by 0x661351: dispatch_command(enum_server_command, THD*, char*, unsigned int) (sql_parse.cc:1299)
==30146== by 0x662BF9: do_command(THD*) (sql_parse.cc:996)
==30146== by 0x76E5DA: do_handle_one_connection(THD*) (sql_connect.cc:1379)
==30146== by 0x76E6CB: handle_one_connection (sql_connect.cc:1293)
==30146== by 0xA2DB2D: pfs_spawn_thread (pfs.cc:1860)
==30146== by 0x4E3506F: start_thread (in /lib64/libpthread-2.9.so)
==30146== by 0x62F913C: clone (in /lib64/libc-2.9.so)
==30146== Source and destination overlap in memcpy(0xc874340, 0xc874340, 20)
==30146== at 0x4C2810E: memcpy (mc_replace_strmem.c:878)
==30146== by 0x6C667E: JOIN::exec_inner() (sql_select.cc:2893)
==30146== by 0x6C3A42: JOIN::exec() (sql_select.cc:2370)
==30146== by 0x6C3F08: mysql_select(THD*, Item***, TABLE_LIST*, unsigned int, List<Item>&, Item*, unsigned int, st_order*, st_order*, Item*, st_order*, unsigned long long, select_result*, st_select_lex_unit*, st_select_lex*) (sql_select.cc:3308)
==30146== by 0x6C763C: handle_select(THD*, LEX*, select_result*, unsigned long) (sql_select.cc:373)
==30146== by 0x65683D: execute_sqlcom_select(THD*, TABLE_LIST*) (sql_parse.cc:5261)
==30146== by 0x658C65: mysql_execute_command(THD*) (sql_parse.cc:2545)
==30146== by 0x6607E7: mysql_parse(THD*, char*, unsigned int, Parser_state*) (sql_parse.cc:6407)
==30146== by 0x661351: dispatch_command(enum_server_command, THD*, char*, unsigned int) (sql_parse.cc:1299)
==30146== by 0x662BF9: do_command(THD*) (sql_parse.cc:996)
==30146== by 0x76E5DA: do_handle_one_connection(THD*) (sql_connect.cc:1379)
==30146== by 0x76E6CB: handle_one_connection (sql_connect.cc:1293)
==30146== by 0xA2DB2D: pfs_spawn_thread (pfs.cc:1860)
==30146== by 0x4E3506F: start_thread (in /lib64/libpthread-2.9.so)
==30146== by 0x62F913C: clone (in /lib64/libc-2.9.so)
^ Found warnings in /home/psergey/dev2/10.0-vg/mysql-test/var/log/mysqld.1.err
ok