[Xorp-hackers] valgrind: selector.cc: Reading free'd memory

Ben Greear greearb at candelatech.com
Wed Sep 30 08:20:38 PDT 2009


Bruce Simpson wrote:
> Hi Ben,
>
> Thanks for the patch. Yes, this would work around the issue by 
> pre-allocating all the storage for Selectors upfront.
>
> Ben Greear wrote:
>>
>> This one is nasty.  Here's the work-around fix:
>
> I would far rather the problem is fixed at root however. If we're 
> pushed for time then we may check this in as an interim fix, it does 
> waste some memory, but that's better than risking heap corruption in 
> some situations. Ironically, the ref_ptr template is being used to try 
> to avoid premature deletion.
It's not deletion of the refptr or what it points to that is the 
problem..it's deletion of the Node that holds the refptr.

Moving to a linked list storage or something like that for nodes would 
probably fix the problem, but considering non-const access
to elements, it may not be worth the effort.

If we are worried about memory usage, should fix the lex parsing 
code...it leaks memory all over the place
according to valgrind.  But, I couldn't see any easy way to fix that....

I'll add a Trac ticket later today.

Thanks,
Ben

-- 
Ben Greear <greearb at candelatech.com> 
Candela Technologies Inc  http://www.candelatech.com




More information about the Xorp-hackers mailing list