[Mesa-dev] [PATCH] nir/clone: Free clone_state after use (to fix memory leak)

Tapani Pälli tapani.palli at intel.com
Mon Nov 20 09:28:57 UTC 2017



On 11/20/2017 10:35 AM, Eduardo Lima Mitev wrote:
> Ping? This patch fixes an active memory leak.
> 
> Any comments? Thanks.

How to reproduce this leak?

> Eduardo
> 
> 
> On 11/14/2017 11:18 PM, Eduardo Lima Mitev wrote:
>> In nir_cf_list_clone(), a state_clone object is initialized but never
>> freed, causing a memory leak. If the remap_table argument is NULL,
>> init_state will create a hash table for it, and that's what
>> free_clone_state is supposed to free.
>> ---
>>   src/compiler/nir/nir_clone.c | 3 +++
>>   1 file changed, 3 insertions(+)
>>
>> diff --git a/src/compiler/nir/nir_clone.c b/src/compiler/nir/nir_clone.c
>> index bcfdaa7594..c823acb6ee 100644
>> --- a/src/compiler/nir/nir_clone.c
>> +++ b/src/compiler/nir/nir_clone.c
>> @@ -660,6 +660,9 @@ nir_cf_list_clone(nir_cf_list *dst, nir_cf_list 
>> *src, nir_cf_node *parent,
>>      clone_cf_list(&state, &dst->list, &src->list);
>>      fixup_phi_srcs(&state);
>> +
>> +   if (!remap_table)
>> +      free_clone_state(&state);
>>   }
>>   static nir_function_impl *
> 
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list