[Mesa-dev] [PATCH] r600/sb: Fix memory leak

Marek Olšák maraeo at gmail.com
Wed Feb 8 16:38:56 UTC 2017


Pushed, thanks!

Marek

On Tue, Feb 7, 2017 at 3:19 PM, Bartosz Tomczyk
<bartosz.tomczyk86 at gmail.com> wrote:
> Hi Nicolai,
>
> Will you push it, if I change it as described in last mail ?
>
> On Mon, Jan 30, 2017 at 3:31 PM, Bartosz Tomczyk
> <bartosz.tomczyk86 at gmail.com> wrote:
>>
>> It did not change anything, as we are not dereferencing iterator after
>> delete.
>>
>> I think changing:
>> delete *it;
>> uses.erase(it);
>>
>> to:
>> use_info *ptr = *it;
>> uses.erase(it);
>> delete ptr;
>>
>> don't make it more readable or safer, but I can change it if you want to.
>>
>> On Mon, Jan 30, 2017 at 3:16 PM, Nicolai Hähnle <nhaehnle at gmail.com>
>> wrote:
>>>
>>> Nice find!
>>>
>>> On 29.01.2017 19:10, Bartosz Tomczyk wrote:
>>>>
>>>> ---
>>>>  src/gallium/drivers/r600/sb/sb_valtable.cpp | 8 +++++++-
>>>>  1 file changed, 7 insertions(+), 1 deletion(-)
>>>>
>>>> diff --git a/src/gallium/drivers/r600/sb/sb_valtable.cpp
>>>> b/src/gallium/drivers/r600/sb/sb_valtable.cpp
>>>> index a8b7b49cd4..d31a1b76d5 100644
>>>> --- a/src/gallium/drivers/r600/sb/sb_valtable.cpp
>>>> +++ b/src/gallium/drivers/r600/sb/sb_valtable.cpp
>>>> @@ -241,6 +241,7 @@ void value::remove_use(const node *n) {
>>>>         {
>>>>                 // TODO assert((*it)->kind == kind) ?
>>>>                 // TODO assert((*it)->arg == arg) ?
>>>> +               delete *it;
>>>>                 uses.erase(it);
>>>
>>>
>>> The delete should really be after the erase.
>>>
>>> Cheers,
>>> Nicolai
>>>
>>>
>>>>         }
>>>>  }
>>>> @@ -290,7 +291,12 @@ bool value::is_prealloc() {
>>>>  }
>>>>
>>>>  void value::delete_uses() {
>>>> -       uses.erase(uses.begin(), uses.end());
>>>> +       for (uselist::iterator it = uses.begin(); it != uses.end();
>>>> ++it)
>>>> +       {
>>>> +               delete *it;
>>>> +       }
>>>> +
>>>> +       uses.clear();
>>>>  }
>>>>
>>>>  void ra_constraint::update_values() {
>>>>
>>>
>>
>
>
> _______________________________________________
> 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