[patch] tcache double free check

Carlos O'Donell carlos@redhat.com
Thu Nov 8 20:27:00 GMT 2018


On 11/8/18 3:09 PM, Florian Weimer wrote:
> * DJ Delorie:
> 
>> +  /* This test succeeds on double free.  However, we don't 100% trust
>> +     it, so verify it's not an unlikely coincidence before
>> +     aborting.  */
>> +  if (__glibc_unlikely (e->key == tcache))
>> +    {
>> +      tcache_entry *tmp;
>> +      for (tmp = tcache->entries[tc_idx];
>> +	   tmp;
>> +	   tmp = tmp->next)
>> +	{
>> +	if (tmp == e)
>> +	  malloc_printerr ("free(): double free detected in tcache");
>> +	}
>> +      /* If we get here, it was a coincidence.  We've wasted a few
>> +	 cycles, but don't abort.  */
>> +    }
> 
> One more thing:
> 
> I think you should put an Systemtap probe here, perhaps counting the
> length of the chain and logging the index, so that we can debug
> performance issues here.

... and please document the probe in the manual.

-- 
Cheers,
Carlos.



More information about the Libc-alpha mailing list