Bug #14703 Valgrind error when inserting 0 into a BIT column (like in type_bit.test)
Submitted: 7 Nov 2005 13:20 Modified: 7 Nov 2005 14:54
Reporter: Guilhem Bichot Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:5.0 OS:Linux (linux)
Assigned to: Guilhem Bichot CPU Architecture:Any

[7 Nov 2005 13:20] Guilhem Bichot
Description:
seen on several machines.
==26178== Conditional jump or move depends on uninitialised value(s)
==26178==    at 0x55AC04: Field_bit::store(char const*, unsigned, charset_info_st*) (field.cc:7934)
==26178==    by 0x554FFE: Field_bit::store(long, bool) (field.cc:7987)
==26178==    by 0x4FF4B0: Item_int::save_in_field(Field*, bool) (item.cc:3979)
==26178==    by 0x5B0CB5: fill_record(THD*, Field**, List<Item>&, bool) (sql_base.cc:4981)
==26178==    by 0x5B0D2C: fill_record_n_invoke_before_triggers(THD*, Field**, List<Item>&, bool, Table_triggers_list*, trg_event_type) (sql_base.cc:5019)
==26178==    by 0x5E2F43: mysql_insert(THD*, st_table_list*, List<Item>&, List<List<Item> >&, List<Item>&, List<Item>&, enum_duplicates, bool) (sql_insert.cc:498)
==26178==    by 0x58D296: mysql_execute_command(THD*) (sql_parse.cc:3268)
==26178==    by 0x59156B: mysql_parse(THD*, char*, unsigned) (sql_parse.cc:5598)
==26178==    by 0x591C60: dispatch_command(enum_server_command, THD*, char*, unsigned) (sql_parse.cc:1709)
==26178==    by 0x592D14: do_command(THD*) (sql_parse.cc:1510)
==26178==    by 0x593950: handle_one_connection (sql_parse.cc:1155)
==26178==    by 0x122DB97B: start_thread (in /lib64/libpthread-2.3.5.so)

How to repeat:
run this test with mysql-test-run --valgrind:
drop table if exists test.t2;
CREATE TABLE test.t2 (b1 BIT(8));
INSERT INTO test.t2 VALUES(0);
(does not happen if you insert something else than zero).

Suggested fix:
This warning is not about a real problem; when "length" is zero, *from is tested and has it's not initialized memory there is a warning, but as "length" is zero the test will be false anyway. I reported this to the Valgrind authors, in case this is fixable.
I'll fix the MySQL code by swapping the two members of the condition.
[7 Nov 2005 13:24] Guilhem Bichot
or just run the type_bit test under Valgrind
(FC4 x86-64, Valgrind 3.0.1, gcc 4.0.0)
[7 Nov 2005 14:21] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/internals/32041
[7 Nov 2005 14:54] Guilhem Bichot
Thank you for your bug report. This issue has been committed to our
source repository of that product and will be incorporated into the
next release.

If necessary, you can access the source repository and build the latest
available version, including the bugfix, yourself. More information 
about accessing the source trees is available at
    http://www.mysql.com/doc/en/Installing_source_tree.html

Additional info:

fixed in 5.0.16, nothing to document (just a harmless valgrind warning).