List:Commits« Previous MessageNext Message »
From:Alexey Kopytov Date:September 24 2010 9:20am
Subject:Re: bzr commit into mysql-5.1-bugteam branch (Alexey.Kopytov:3514)
Bug#56709
View as plain text  
Hi Tor,

On 23.09.10 17:58, Tor Didriksen wrote:
>> @@ -1447,8 +1442,8 @@ static void PushState(CODE_STATE *cs)
>>    struct settings *new_malloc;
>>
>>    new_malloc= (struct settings *) DbugMalloc(sizeof(struct settings));
>> +  bzero(new_malloc, sizeof(struct settings));
>>
>
> man bzero:
> This function is deprecated (marked as LEGACY in POSIX.1-2001): use
> memset(3) in new programs.
>

Sure, but on the other hand: 
http://forge.mysql.com/wiki/MySQL_Internals_Coding_Guidelines#Additional_suggestions

"
#  Use libstring functions (in the strings directory) instead of 
standard libc string functions whenever possible. For example, use 
bfill() and bzero() instead of memset().
"

I personally think of bzero() as a convenient alias for the most 
commonly used form of memset(). In other words, even if bzero() did not 
exist, it should have been created. And we actually do something like 
that in m_string.h:

#if !defined(bzero) && !defined(HAVE_BZERO)
# define bzero(A,B)             memset((A),0,(B))
#endif

>> === modified file 'sql/item_timefunc.cc'
>> --- a/sql/item_timefunc.cc      2010-07-09 12:00:17 +0000
>> +++ b/sql/item_timefunc.cc      2010-09-22 19:33:18 +0000
>> @@ -2270,8 +2270,6 @@ void Item_extract::print(String *str, en
>>
>>   void Item_extract::fix_length_and_dec()
>>   {
>> -  value.alloc(32);                             // alloc buffer
>> -
>>    maybe_null=1;                                        // If wrong date
>>    switch (int_type) {
>>    case INTERVAL_YEAR:          max_length=4; date_value=1; break;
>> @@ -2314,6 +2312,8 @@ longlong Item_extract::val_int()
>>    }
>>    else
>>    {
>> +    char buf[40];
>> +    String value(buf, sizeof(buf),&my_charset_bin);;
>>      String *res= args[0]->val_str(&value);
>>      if (!res || str_to_time_with_warn(res->ptr(),
> res->length(),&ltime))
>>      {
>>
>>
> I agree that there is no need for the member field, so this solves the
> immediate problem.
> However, the leak indicates that the Item_extract instance has not been
> destroyed.
> This seems to be a more general solution:
>
> === modified file 'sql/sql_partition.cc'
> --- sql/sql_partition.cc        2010-07-29 03:00:57 +0000
> +++ sql/sql_partition.cc        2010-09-23 13:06:25 +0000
> @@ -1025,6 +1025,7 @@
>       if (is_create_table_ind)
>       {
>         my_error(ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR, MYF(0));
> +      thd->free_items();
>         goto end;
>       }
>       else
>
>
>

Thanks for noticing this. Actually, there is even more general problem: 
_any_ error caused by ALTER TABLE ... PARTITION leads to a memory leak. 
Since I am not sure about the full scope of the problem and the 
correct/elegant ways to fix it, I have reported it as a separate bug, 
#56996.

For now, I would prefer to fix the immediate problem, i.e. valgrind 
errors reported by mtr.

Thanks,
Alexey.
Thread
bzr commit into mysql-5.1-bugteam branch (Alexey.Kopytov:3514)Bug#56709Alexey Kopytov22 Sep
  • Re: bzr commit into mysql-5.1-bugteam branch (Alexey.Kopytov:3514) Bug#56709Tor Didriksen23 Sep
    • Re: bzr commit into mysql-5.1-bugteam branch (Alexey.Kopytov:3514)Bug#56709Alexey Kopytov24 Sep
      • Re: bzr commit into mysql-5.1-bugteam branch (Alexey.Kopytov:3514) Bug#56709Tor Didriksen30 Sep
        • Re: bzr commit into mysql-5.1-bugteam branch (Alexey.Kopytov:3514)Bug#56709Davi Arnaut30 Sep
          • Re: bzr commit into mysql-5.1-bugteam branch (Alexey.Kopytov:3514)Bug#56709Sergei Golubchik30 Sep
            • Re: bzr commit into mysql-5.1-bugteam branch (Alexey.Kopytov:3514)Bug#56709Davi Arnaut30 Sep
              • Re: bzr commit into mysql-5.1-bugteam branch (Alexey.Kopytov:3514)Bug#56709Davi Arnaut30 Sep
            • Re: bzr commit into mysql-5.1-bugteam branch (Alexey.Kopytov:3514) Bug#56709Tor Didriksen1 Oct
              • Re: bzr commit into mysql-5.1-bugteam branch (Alexey.Kopytov:3514)Bug#56709Alexey Kopytov1 Oct
                • Re: bzr commit into mysql-5.1-bugteam branch (Alexey.Kopytov:3514)Bug#56709Davi Arnaut1 Oct
                  • Re: bzr commit into mysql-5.1-bugteam branch (Alexey.Kopytov:3514)Bug#56709Alexey Kopytov2 Oct
                • Re: bzr commit into mysql-5.1-bugteam branch (Alexey.Kopytov:3514) Bug#56709Tor Didriksen1 Oct
                  • Re: bzr commit into mysql-5.1-bugteam branch (Alexey.Kopytov:3514)Bug#56709Alexey Kopytov1 Oct
Re: bzr commit into mysql-5.1-bugteam branch (Alexey.Kopytov:3514)Bug#56709Davi Arnaut1 Oct
  • Re: bzr commit into mysql-5.1-bugteam branch (Alexey.Kopytov:3514)Bug#56709Alexey Kopytov1 Oct
Re: bzr commit into mysql-5.1-bugteam branch (Alexey.Kopytov:3514)Bug#56709Alexey Kopytov1 Oct
  • Re: bzr commit into mysql-5.1-bugteam branch (Alexey.Kopytov:3514)Bug#56709Davi Arnaut1 Oct
    • Re: bzr commit into mysql-5.1-bugteam branch (Alexey.Kopytov:3514)Bug#56709Alexey Kopytov1 Oct
      • Re: bzr commit into mysql-5.1-bugteam branch (Alexey.Kopytov:3514)Bug#56709Davi Arnaut1 Oct
        • Re: bzr commit into mysql-5.1-bugteam branch (Alexey.Kopytov:3514)Bug#56709Alexey Kopytov1 Oct
          • Re: bzr commit into mysql-5.1-bugteam branch (Alexey.Kopytov:3514)Bug#56709Davi Arnaut1 Oct