Bug #20598 Valgrind 'still reachable' due to race in shutdown
Submitted: 21 Jun 2006 10:09 Modified: 26 Jun 2006 9:16
Reporter: Kristian Nielsen Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Replication Severity:S3 (Non-critical)
Version:5.1.12 OS:Linux (Linux)
Assigned to: Kristian Nielsen CPU Architecture:Any

[21 Jun 2006 10:09] Kristian Nielsen
Description:
Setting to P1/Showstopper as per policy, as this is a Valgrind error. There are no user-visible consequences.

This report is occasionally seen in Valgrind runs:

VALGRIND: '1 bytes in 1 blocks are still reachable in loss record 1 of 143'
    COUNT: 45
    FUNCTION: malloc    FILES:    master.err master1.err slave.err
    TESTS:    ndb_autodiscover3 ndb_binlog_discover ndb_binlog_ignore_db ndb_restore_compat ndb_restore_partition ndb_view rpl_ndb_UUID rpl_ndb_bank rpl_ndb_basic rpl_ndb_blob rpl_ndb_blob2 rpl_ndb_charset rpl_ndb_commit_afterflush rpl_ndb_dd_advance rpl_ndb_dd_basic rpl_ndb_delete_nowhere rpl_ndb_func003 rpl_ndb_idempotent rpl_ndb_insert_ignore rpl_ndb_load rpl_ndb_log rpl_ndb_multi rpl_ndb_multi_update2 rpl_ndb_multi_update3 rpl_ndb_relayrotate rpl_ndb_row_001 rpl_ndb_sp003 rpl_ndb_sp006 rpl_ndb_sync rpl_ndb_trig004 rpl_row_basic_7ndb
    STACK: at 0x4A18B63: malloc (vg_replace_malloc.c:149)
             by 0x75394E: injector::instance() (rpl_injector.cc:153)
             by 0x7058F7: ndb_binlog_thread_func (ha_ndbcluster_binlog.cc:3263)
             by 0x4C37C63: start_thread (in /lib64/tls/libpthread-0.60.so)
             by 0x52F3242: clone (in /lib64/tls/libc-2.3.2.so)

I think the problem is in clean_up() in sql/mysqld.cc. It calls logger.cleanup_end() after signalling the main thread that it is done, which according to comments in that code may cause the main thread to kill it before the cleanup can be executed.

How to repeat:
Random Valgrind error in test suite, seen in pushbuild.

Suggested fix:
I will commit shortly a suggested fix.
[21 Jun 2006 10:33] 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/commits/8005
[22 Jun 2006 14:48] Kristian Nielsen
Patch approved by Petr Chardin.
[26 Jun 2006 9:16] Kristian Nielsen
Pushed to 5.1.12.

No enduser-visible changes, so no documentation needed.