Bug #20791 valgrind errors in InnoDB
Submitted: 30 Jun 2006 13:00 Modified: 19 Jun 2010 17:58
Reporter: Marc Alff Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: InnoDB storage engine Severity:S2 (Serious)
Version:5.1-12 (BK) OS:Linux (Gentoo Linux AMD64)
Assigned to: Heikki Tuuri CPU Architecture:Any

[30 Jun 2006 13:00] Marc Alff
Description:
Valgrind reports the following errors in InnoDB :

1)

==10545== Conditional jump or move depends on uninitialised value(s)
==10545==    at 0x8AADD7: trx_sys_create_doublewrite_buf (trx0sys.c:197)
==10545==    by 0x8A1579: innobase_start_or_create_for_mysql (srv0start.c:1550)
==10545==    by 0x6CBF02: innobase_init() (ha_innodb.cc:1588)
==10545==    by 0x78523F: plugin_initialize(st_plugin_int*) (sql_plugin.cc:528)
==10545==    by 0x785717: plugin_init() (sql_plugin.cc:685)
==10545==    by 0x5E9933: init_server_components() (mysqld.cc:3190)
==10545==    by 0x5E9F61: main (mysqld.cc:3576)
InnoDB: Doublewrite buffer not found: creating new

2)

==10545== Syscall param pwrite64(buf) points to uninitialised byte(s)
==10545==    at 0x4D41D3C: (within /lib64/tls/libpthread.so)
==10545==    by 0x87F91B: os_file_pwrite (os0file.c:1975)
==10545==    by 0x87FB06: os_file_write (os0file.c:2420)
==10545==    by 0x880D43: os_aio_simulated_handle (os0file.c:3960)
==10545==    by 0x8644C6: fil_aio_wait (fil0fil.c:4132)
==10545==    by 0x8A0117: io_handler_thread (srv0start.c:431)
==10545==    by 0x4D3C0F9: start_thread (in /lib64/tls/libpthread.so)
==10545==    by 0x52A5CA2: clone (in /lib64/tls/libc.so)
==10545==  Address 0x7444000 is 1,832 bytes inside a block of size 753,696 alloc'd
==10545==    at 0x4A1AAC7: malloc (in /usr/lib64/valgrind/amd64-linux/vgpreload_memcheck.so)
==10545==    by 0x8B15D8: ut_malloc_low (ut0mem.c:82)
==10545==    by 0x8B1744: ut_malloc (ut0mem.c:178)
==10545==    by 0x880BE5: os_aio_simulated_handle (os0file.c:3910)
==10545==    by 0x8644C6: fil_aio_wait (fil0fil.c:4132)
==10545==    by 0x8A0117: io_handler_thread (srv0start.c:431)
==10545==    by 0x4D3C0F9: start_thread (in /lib64/tls/libpthread.so)
==10545==    by 0x52A5CA2: clone (in /lib64/tls/libc.so)
InnoDB: Doublewrite buffer created
InnoDB: Creating foreign key constraint system tables
InnoDB: Foreign key constraint system tables created
060630 16:24:58  InnoDB: Started; log sequence number 0 0

See the full valgrind log in attachments.

How to repeat:
cd mysql-5.1/mysql-test
./mysql-test-run.pl --valgrind --valgrind-all alias

Suggested fix:
Use a memset(0) after malloc, or after returning memory allocated internally.
[30 Jun 2006 13:02] Marc Alff
Valgrind error log

Attachment: master.err (application/octet-stream, text), 29.98 KiB.

[30 Jun 2006 13:19] MySQL Verification Team
Thank you for the bug report. There are warnings also on Suse 10 32Bit:

miguel@hegel:~/dbs/mysql-5.1/mysql-test> cat /home/miguel/dbs/mysql-5.1/mysql-test/var/log/warnings 
==5986==    at 0x8581608: trx_sys_create_doublewrite_buf (trx0sys.c:197)
==5986==    at 0x1B93716B: do_pwrite64 (in /lib/tls/libpthread-2.3.5.so)
==5986==    at 0x1B8FF8A6: malloc (in /usr/lib/valgrind/vgpreload_memcheck.so)
==5986==    at 0x1B93716B: do_pwrite64 (in /lib/tls/libpthread-2.3.5.so)
==5986==    at 0x1B8FF8A6: malloc (in /usr/lib/valgrind/vgpreload_memcheck.so)
==5986==    at 0x1B93716B: do_pwrite64 (in /lib/tls/libpthread-2.3.5.so)
==5986==    at 0x1B8FF8A6: malloc (in /usr/lib/valgrind/vgpreload_memcheck.so)
==5986==    at 0x8581608: trx_sys_create_doublewrite_buf (trx0sys.c:197)
==5986==    at 0x1B93716B: do_pwrite64 (in /lib/tls/libpthread-2.3.5.so)
==5986==    at 0x1B8FF8A6: malloc (in /usr/lib/valgrind/vgpreload_memcheck.so)
==5986==    at 0x1B93716B: do_pwrite64 (in /lib/tls/libpthread-2.3.5.so)
==5986==    at 0x1B8FF8A6: malloc (in /usr/lib/valgrind/vgpreload_memcheck.so)
==5986==    at 0x1B93716B: do_pwrite64 (in /lib/tls/libpthread-2.3.5.so)
==5986==    at 0x1B8FF8A6: malloc (in /usr/lib/valgrind/vgpreload_memcheck.so)
miguel@hegel:~/dbs/mysql-5.1/mysql-test>
[27 Jul 2006 16:33] Heikki Tuuri
Hi!

Valgrind errors in the doublewrite buffer creation and os_file_pwrite() are generally not dangerous. InnoDB does not init all buffers that it writes to disk. We could suppress the warnings by zeroing the associated memory, but then we would also make Valgrind less sensitive to detect genuine bugs!

Regards,

Heikki
[25 Aug 2006 20:54] Heikki Tuuri
Lowering the priority to P4 because there probably is no bug here.
[31 Aug 2006 20:49] Heikki Tuuri
I have made a patch to suppress the warning about in the doublewrite function. It was a genuine bug: with very bad luck uninitialized memory could have contained the magic number.

The warnings about pwrite() are harmless. They can be ignored.
[13 Sep 2006 8:26] Timothy Smith
Pushed to 5.1.12
[14 Sep 2006 3:28] Paul DuBois
Noted in 5.1.12 changelog.
[3 Oct 2006 20:16] Chad MILLER
Available in 5.1.12-beta.
[5 May 2010 15:22] Bugs System
Pushed into 5.1.47 (revid:joro@sun.com-20100505145753-ivlt4hclbrjy8eye) (version source revid:vasil.dimov@oracle.com-20100331130613-8ja7n0vh36a80457) (merge vers: 5.1.46) (pib:16)
[6 May 2010 2:16] Paul DuBois
Push resulted from incorporation of InnoDB tree. No changes pertinent to this bug. Re-closing.
[28 May 2010 6:04] Bugs System
Pushed into mysql-next-mr (revid:alik@sun.com-20100524190136-egaq7e8zgkwb9aqi) (version source revid:vasil.dimov@oracle.com-20100331130613-8ja7n0vh36a80457) (pib:16)
[28 May 2010 6:32] Bugs System
Pushed into 6.0.14-alpha (revid:alik@sun.com-20100524190941-nuudpx60if25wsvx) (version source revid:vasil.dimov@oracle.com-20100331130613-8ja7n0vh36a80457) (merge vers: 5.1.46) (pib:16)
[28 May 2010 7:00] Bugs System
Pushed into 5.5.5-m3 (revid:alik@sun.com-20100524185725-c8k5q7v60i5nix3t) (version source revid:vasil.dimov@oracle.com-20100331130613-8ja7n0vh36a80457) (merge vers: 5.1.46) (pib:16)
[29 May 2010 22:43] Paul DuBois
Push resulted from incorporation of InnoDB tree. No changes pertinent to this bug.
Re-closing.
[17 Jun 2010 12:08] Bugs System
Pushed into 5.1.47-ndb-7.0.16 (revid:martin.skold@mysql.com-20100617114014-bva0dy24yyd67697) (version source revid:vasil.dimov@oracle.com-20100331130613-8ja7n0vh36a80457) (merge vers: 5.1.46) (pib:16)
[17 Jun 2010 12:54] Bugs System
Pushed into 5.1.47-ndb-6.2.19 (revid:martin.skold@mysql.com-20100617115448-idrbic6gbki37h1c) (version source revid:vasil.dimov@oracle.com-20100331130613-8ja7n0vh36a80457) (merge vers: 5.1.46) (pib:16)
[17 Jun 2010 13:35] Bugs System
Pushed into 5.1.47-ndb-6.3.35 (revid:martin.skold@mysql.com-20100617114611-61aqbb52j752y116) (version source revid:vasil.dimov@oracle.com-20100331130613-8ja7n0vh36a80457) (merge vers: 5.1.46) (pib:16)