mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
Fixed memory leak introduces by a fix for MDEV-29932
The leaks are all 40 bytes and happens in this call stack when running mtr vcol.vcol_syntax: alloc_root() ... Virtual_column_info::fix_and_check_exp() ... Delayed_insert::get_local_table() The problem was that one copied a MEM_ROOT from THD to a TABLE without taking into account that new blocks would be allocated through the TABLE memroot (and would thus be leaked). In general, one should NEVER copy MEM_ROOT from one object to another without clearing the copied memroot! Fixed by, at end of get_local_table(), copy all new allocated objects to client_thd->mem_root. Other things: - Removed references to MEM_ROOT::total_alloc that was wrongly left after a previous commit
This commit is contained in:
@ -2635,7 +2635,9 @@ TABLE *Delayed_insert::get_local_table(THD* client_thd)
|
||||
copy= new (copy_tmp) TABLE;
|
||||
*copy= *table;
|
||||
copy->vcol_refix_list.empty();
|
||||
copy->mem_root= *client_thd->mem_root;
|
||||
init_alloc_root(©->mem_root, client_thd->mem_root->name,
|
||||
client_thd->mem_root->block_size,
|
||||
0, MY_THREAD_SPECIFIC);
|
||||
|
||||
/* We don't need to change the file handler here */
|
||||
/* Assign the pointers for the field pointers array and the record. */
|
||||
@ -2729,11 +2731,14 @@ TABLE *Delayed_insert::get_local_table(THD* client_thd)
|
||||
bzero((char*) bitmap, share->column_bitmap_size * bitmaps_used);
|
||||
copy->read_set= ©->def_read_set;
|
||||
copy->write_set= ©->def_write_set;
|
||||
move_root(client_thd->mem_root, ©->mem_root);
|
||||
free_root(©->mem_root, 0);
|
||||
|
||||
DBUG_RETURN(copy);
|
||||
|
||||
/* Got fatal error */
|
||||
error:
|
||||
free_root(©->mem_root, 0);
|
||||
tables_in_use--;
|
||||
mysql_cond_signal(&cond); // Inform thread about abort
|
||||
DBUG_RETURN(0);
|
||||
|
Reference in New Issue
Block a user