Hi!
On Jul 03, Sergey Vojtovich wrote:
> ChangeSet@stripped, 2007-07-03 22:14:35+05:00, svoj@stripped +1 -0
> BUG#27564 - Valgrind: UDF does not cleanup correctly
>
> Dropping an user defined function may cause server crash in
> case this function is still in use by another thread.
>
> The problem was that our hash implementation didn't update
> hash link list properly when hash_update() was called.
ok to push
with one change as below
> --- 1.44/mysys/hash.c 2007-07-03 22:14:39 +05:00
> +++ 1.45/mysys/hash.c 2007-07-03 22:14:39 +05:00
> @@ -572,6 +572,18 @@ my_bool hash_update(HASH *hash,byte *rec
> previous->next=pos->next; /* unlink pos */
>
> /* Move data to correct position */
> + if (new_index == empty)
Good catch!
Indeed, I see that the old code didn't take into account that new_index
could be equal to empty.
> + {
> + /*
> + Prior to update this record wasn't first in the chain, thus it holds
> + random position. By the chance after update this position is equal to
> + position for the first element in the new chain. That means updated
> + record is the only record in the new chain. Thus we only need to set
> + next link to NO_RECORD.
> + */
> + data[new_index].next= NO_RECORD;
> + DBUG_RETURN(0);
Okay. But I think you're missing a case when empty was moved:
if (pos->next != NO_RECORD)
{
empty=pos->next;
*pos= data[pos->next];
}
and, by coincidence, the new empty position matches new_index.
(a chance on "coincidence" could be very high if the hash is small, you
know :).
In that case your code works, but you also need to copy the hash
element:
if (empty != idx)
data[empty]=org_link;
this should be done before your assignment of NO_RECORD.
(here I used 'empty', but you used 'new_index'. of course they're equal,
but it's a confusing mix of two variables, please change either piece of
code so that one variable is used everywhere in your if().)
> + }
> pos=data+new_index;
> new_pos_index=hash_rec_mask(hash,pos,blength,records);
> if (new_index != new_pos_index)
>
Regards / Mit vielen Grüssen,
Sergei
--
__ ___ ___ ____ __
/ |/ /_ __/ __/ __ \/ / Sergei Golubchik <serg@stripped>
/ /|_/ / // /\ \/ /_/ / /__ Principal Software Developer
/_/ /_/\_, /___/\___\_\___/ MySQL GmbH, Radlkoferstr. 2, D-81373 München
<___/ Geschäftsführer: Kaj Arnö - HRB
München 162140