Bug #24387 Valgrind: my_thread_init (handle_sl sql, handle_one_conn, handle_slave_io)
Submitted: 17 Nov 2006 11:23 Modified: 11 Dec 2006 8:25
Reporter: Lars Thalmann Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:5.0 source OS:
Assigned to: Sergei Golubchik CPU Architecture:Any

[17 Nov 2006 11:23] Lars Thalmann
Description:
Pushbuild for mysql-5.0-rpl on Fri Nov 17 12:18:26 2006

VALGRIND: '256 bytes in 1 blocks are still reachable in loss record 5 of 7'
    COUNT: 1
    FUNCTION: calloc    FILES:    slave.err
    TESTS:    rpl_get_lock
    STACK: at 0x490604E: calloc (vg_replace_malloc.c:279)
             by 0x9B3AB0: my_thread_init (my_thr_init.c:170)
             by 0x5E3354: handle_one_connection (sql_parse.cc:1099)
             by 0x37BB90683B: start_thread (in /lib64/libpthread-2.3.6.so)
             by 0x37BB0CA4ED: clone (in /lib64/libc-2.3.6.so)

How to repeat:
Check Pushbuild

Suggested fix:
Thread handling probably needs to have some
better control on when to stop threads and when 
it actually should be allowed to start releasing
memory.
[17 Nov 2006 11:33] Lars Thalmann
These two failures are probably the same failure.

Pushbuild for mysql-5.0 on Fri Nov 17 12:31:24 2006:

VALGRIND: '256 bytes in 1 blocks are still reachable in loss record 5 of 7'
    COUNT: 1
    FUNCTION: calloc    FILES:    slave.err
    TESTS:    rpl_multi_update2
    STACK: at 0x4A1A122: calloc (vg_replace_malloc.c:279)
             by 0x94A8B9: my_thread_init (my_thr_init.c:170)
             by 0x6DE918: handle_slave_sql (slave.cc:3784)
             by 0x4E54C63: start_thread (in /lib64/tls/libpthread-0.60.so)
             by 0x540D242: clone (in /lib64/tls/libc-2.3.2.so)

VALGRIND: '512 bytes in 2 blocks are still reachable in loss record 5 of 7'
    COUNT: 1
    FUNCTION: calloc    FILES:    slave.err
    TESTS:    rpl000008
    STACK: at 0x4A1A122: calloc (vg_replace_malloc.c:279)
             by 0x94A8B9: my_thread_init (my_thr_init.c:170)
             by 0x6DD8FF: handle_slave_io (slave.cc:3441)
             by 0x4E54C63: start_thread (in /lib64/tls/libpthread-0.60.so)
             by 0x540D242: clone (in /lib64/tls/libc-2.3.2.so)
[17 Nov 2006 16:38] Rafal Somla
One theory is that the problems are caused by the following sequence at the end of functions handle_slave_io() and handle_slave_sql() (slave.cc):

  pthread_exit(0);
  DBUG_RETURN(0);

After calling pthread_exit(), DBUG_RETURN(0) is not called and this may cause problems (the DBUG_ENTER() call is not matched). Also, terminating thread in such a manner can cause other problems. What if some resources were alocated before a call to handle_slave_*() and need to be released? What if this is a mutex lock?
[22 Nov 2006 16:32] 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/15724

ChangeSet@1.2309, 2006-11-22 17:31:42+01:00, rafal@quant.(none) +2 -0
  This is implementation of points 1 and 2 of the temporary solution 
  suggested by Monty. See bug#24387 report.
[24 Nov 2006 15:04] Lars Thalmann
See also BUG#24507.
[28 Nov 2006 21:54] Michael Widenius
Patch approved as first step to solve problem.
I do however expect that Lars team will look at implemeting the full solution (as  described in the bug report) for 5.1 relatively soon.
[29 Nov 2006 12:18] 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/16093

ChangeSet@1.2319, 2006-11-29 11:54:33+01:00, serg@janus.mylan +1 -0
  Bug #24387 Valgrind: my_thread_init
  wait till all threads have executed my_thread_end() before exiting main()
[29 Nov 2006 14:23] 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/16111

ChangeSet@1.2319, 2006-11-29 15:23:31+01:00, serg@janus.mylan +1 -0
  Bug #24387 Valgrind: my_thread_init
  wait till all threads have executed my_thread_end() before exiting main()
[29 Nov 2006 14:27] 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/16113

ChangeSet@1.2319, 2006-11-29 15:27:03+01:00, serg@janus.mylan +1 -0
  Bug #24387 Valgrind: my_thread_init
  wait till all threads have executed my_thread_end() before exiting main()
[29 Nov 2006 20:14] 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/16150

ChangeSet@1.2326, 2006-11-29 22:14:08+02:00, monty@mysql.com +3 -0
  Ignore some generated files
  Don't return from my_thread_global_end() until all threads have called my_thread_end()
  Bug#24387: Valgrind: my_thread_init (handle_sl sql, handle_one_conn, handle_slave_io)
[11 Dec 2006 8:25] Jon Stephens
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 bug fix. More information about accessing the source trees is available at

    http://dev.mysql.com/doc/en/installing-source.html

Closed without further action (no changes visible to users).
[13 Feb 2008 10: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/commits/42200

ChangeSet@1.2559, 2008-02-13 11:21:22+01:00, mkindahl@dl145h.mysql.com +1 -0
  Fixes to try to handle valgrind warnings identical to those in
  BUG#24387, which is closed since long.
[14 Feb 2008 8:53] 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/42260

ChangeSet@1.2552, 2008-02-14 09:53:01+01:00, mkindahl@dl145h.mysql.com +1 -0
  Fixes to try to handle valgrind warnings identical to those in
  BUG#24387, which is closed since long.
[15 Feb 2008 13:40] Bugs System
Pushed into 5.1.24-rc
[15 Feb 2008 13:41] Bugs System
Pushed into 6.0.5-alpha