Bug #27733 Valgrind failures in remove_table_from_cache
Submitted: 10 Apr 2007 14:45 Modified: 24 Apr 2007 1:00
Reporter: Mads Martin Joergensen Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S1 (Critical)
Version:5.1 OS:Any
Assigned to: Konstantin Osipov CPU Architecture:Any

[10 Apr 2007 14:45] Mads Martin Joergensen
Description:
VALGRIND: 'Invalid write of size 1'
    COUNT: 2
    FUNCTION: remove_table_from_cache(THD*,    FILES:    master.err
    TESTS:    events
    STACK: at 0x65FBF9: remove_table_from_cache(THD*, char const*, char const*, unsigned) (sql_base.cc:6613)
             by 0x75838F: wait_while_table_is_used(THD*, st_table*, ha_extra_function) (sql_table.cc:3776)
             by 0x758977: close_cached_table(THD*, st_table*) (sql_table.cc:3801)
             by 0x764B6C: mysql_alter_table(THD*, char*, char*, st_ha_create_information*, st_table_list*, List<create_field>&, List<Key>&, unsigned, st_order*, bool, st_alter_info*, bool) (sql_table.cc:6635)
             by 0x62E883: mysql_execute_command(THD*) (sql_parse.cc:2355)
             by 0x630E40: mysql_parse(THD*, char*, unsigned) (sql_parse.cc:5240)
             by 0x631D91: dispatch_command(enum_server_command, THD*, char*, unsigned) (sql_parse.cc:895)
             by 0x6330DC: do_command(THD*) (sql_parse.cc:661)
             by 0x6235F4: handle_one_connection (sql_connect.cc:1089)
             by 0x4D44192: start_thread (in /lib64/libpthread-2.4.so)
             by 0x52B745C: clone (in /lib64/libc-2.4.so)
           Address 0xB6D8465 is 5,309 bytes inside a block of size 9,352 free'd
             at 0x4A2046E: free (vg_replace_malloc.c:233)
             by 0x9BBC9A: my_no_flags_free (my_malloc.c:59)
             by 0x60924B: THD::~THD() (sql_list.h:427)
             by 0x7DBE1A: deinit_event_thread(THD*) (event_scheduler.cc:155)
             by 0x7DCCE9: Event_scheduler::run(THD*) (event_scheduler.cc:497)
             by 0x7DCE23: event_scheduler_thread (event_scheduler.cc:230)
             by 0x4D44192: start_thread (in /lib64/libpthread-2.4.so)
             by 0x52B745C: clone (in /lib64/libc-2.4.so)

VALGRIND: 'Invalid read of size 8'
    COUNT: 1
    FUNCTION: mysql_lock_abort_for_thread(THD*,    FILES:    master.err
    TESTS:    events
    STACK: at 0x61232B: mysql_lock_abort_for_thread(THD*, st_table*) (lock.cc:487)
             by 0x65FC53: remove_table_from_cache(THD*, char const*, char const*, unsigned) (sql_base.cc:6643)
             by 0x75838F: wait_while_table_is_used(THD*, st_table*, ha_extra_function) (sql_table.cc:3776)
             by 0x758977: close_cached_table(THD*, st_table*) (sql_table.cc:3801)
             by 0x764B6C: mysql_alter_table(THD*, char*, char*, st_ha_create_information*, st_table_list*, List<create_field>&, List<Key>&, unsigned, st_order*, bool, st_alter_info*, bool) (sql_table.cc:6635)
             by 0x62E883: mysql_execute_command(THD*) (sql_parse.cc:2355)
             by 0x630E40: mysql_parse(THD*, char*, unsigned) (sql_parse.cc:5240)
             by 0x631D91: dispatch_command(enum_server_command, THD*, char*, unsigned) (sql_parse.cc:895)
             by 0x6330DC: do_command(THD*) (sql_parse.cc:661)
             by 0x6235F4: handle_one_connection (sql_connect.cc:1089)
             by 0x4D44192: start_thread (in /lib64/libpthread-2.4.so)
             by 0x52B745C: clone (in /lib64/libc-2.4.so)
           Address 0xB6D83F8 is 5,200 bytes inside a block of size 9,352 free'd
             at 0x4A2046E: free (vg_replace_malloc.c:233)
             by 0x9BBC9A: my_no_flags_free (my_malloc.c:59)
             by 0x60924B: THD::~THD() (sql_list.h:427)
             by 0x7DBE1A: deinit_event_thread(THD*) (event_scheduler.cc:155)
             by 0x7DCCE9: Event_scheduler::run(THD*) (event_scheduler.cc:497)
             by 0x7DCE23: event_scheduler_thread (event_scheduler.cc:230)
             by 0x4D44192: start_thread (in /lib64/libpthread-2.4.so)
             by 0x52B745C: clone (in /lib64/libc-2.4.so)

VALGRIND: 'Invalid read of size 8'
    COUNT: 1
    FUNCTION: remove_table_from_cache(THD*,    FILES:    master.err
    TESTS:    events
    STACK: at 0x65FC26: remove_table_from_cache(THD*, char const*, char const*, unsigned) (sql_base.cc:6638)
             by 0x75838F: wait_while_table_is_used(THD*, st_table*, ha_extra_function) (sql_table.cc:3776)
             by 0x758977: close_cached_table(THD*, st_table*) (sql_table.cc:3801)
             by 0x764B6C: mysql_alter_table(THD*, char*, char*, st_ha_create_information*, st_table_list*, List<create_field>&, List<Key>&, unsigned, st_order*, bool, st_alter_info*, bool) (sql_table.cc:6635)
             by 0x62E883: mysql_execute_command(THD*) (sql_parse.cc:2355)
             by 0x630E40: mysql_parse(THD*, char*, unsigned) (sql_parse.cc:5240)
             by 0x631D91: dispatch_command(enum_server_command, THD*, char*, unsigned) (sql_parse.cc:895)
             by 0x6330DC: do_command(THD*) (sql_parse.cc:661)
             by 0x6235F4: handle_one_connection (sql_connect.cc:1089)
             by 0x4D44192: start_thread (in /lib64/libpthread-2.4.so)
             by 0x52B745C: clone (in /lib64/libc-2.4.so)
           Address 0xB6D7020 is 120 bytes inside a block of size 9,352 free'd
             at 0x4A2046E: free (vg_replace_malloc.c:233)
             by 0x9BBC9A: my_no_flags_free (my_malloc.c:59)
             by 0x60924B: THD::~THD() (sql_list.h:427)
             by 0x7DBE1A: deinit_event_thread(THD*) (event_scheduler.cc:155)
             by 0x7DCCE9: Event_scheduler::run(THD*) (event_scheduler.cc:497)
             by 0x7DCE23: event_scheduler_thread (event_scheduler.cc:230)
             by 0x4D44192: start_thread (in /lib64/libpthread-2.4.so)
             by 0x52B745C: clone (in /lib64/libc-2.4.so)

How to repeat:
Pushbuild repeats it
[10 Apr 2007 21:07] 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/24221

ChangeSet@1.2563, 2007-04-11 01:06:16+04:00, kostja@vajra.(none) +8 -0
  An attempt to fix a sporadic valgrind memory leak in Event Scheduler:
  streamline the event worker thread work flow and try to eliminate
  possibilities for memory corruptions that might have been
  lurking in previous (complicated) code.
  This is to maybe fix Bug#27733 "Valgrind failures in 
  remove_table_from_cache"
[13 Apr 2007 20: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/24526

ChangeSet@1.2563, 2007-04-13 16:32:31-04:00, kostja@vajra.(none) +8 -0
  An attempt to fix a sporadic valgrind memory leak in Event Scheduler:
  streamline the event worker thread work flow and try to eliminate
  possibilities for memory corruptions that might have been
  lurking in previous (complicated) code.
  This patch: 
   * removes Event_job_data::compile that is now never used
   * cleans up Event_job_data::execute to minimize juggling with
     thread context and eliminate unneded code paths
   * Implements Security_context::change/restore_security_context
     to be able to re-use these methods in all stored programs
  This is to maybe fix Bug#27733 "Valgrind failures in 
  remove_table_from_cache".
  Review comments applied.
[13 Apr 2007 20:39] Konstantin Osipov
Reviewed by email and irc.
[13 Apr 2007 20:39] Konstantin Osipov
Queued into 5.1-runtime
[23 Apr 2007 7:29] Bugs System
Pushed into 5.1.18-beta
[24 Apr 2007 1:00] Paul DuBois
Noted in 5.1.18 changelog.

A memory leak in the event scheduler that was uncovered by Valgrind
was fixed.