Bruce Simpson wrote: > Ben Greear wrote: >> The attached patch seems to fix the problem. > > Thanks for the patch, and the analysis. > > This seems to introduce a ref_ptr -- a class I'm not 100% happy about. > Are you sure that this patch does not leak any memory? If it does, then xorp leaks memory everywhere it uses this ref_ptr. It does stop the crash...I haven't run valgrind on it lately, but if ref_ptr was broken, earlier valgrind runs should have seen it. > > Passing a ref_ptr around is bad, because every time it crosses a C++ > scope boundary, the refcount is bumped -- Boost at least has a > weak_ptr and a shared_ptr, which cleanly separates the smart pointer > semantics between 'I am passing this around' and 'I am sharing > ownership of the pointed-to object'. That's why I pass by reference...keeps ref counts from changing needlessly. Either way, a bit of addition and subtraction is cheap..not like we're doing millions of xrls a second! > > Is there a simpler workaround possible for the issue? I'd rather not > get too deep into reviewing a patch which cuts fairly deep into > internals which are probably about to get rewritten. I doubt it...don't know where all the xrls are stored..would have to search all of them and clean out any with pointers to the sender that is to be deleted.
In general, I dislike smart pointers, but in this case, they seem tailor made for the problem. Thanks, Ben -- Ben Greear <[email protected]> Candela Technologies Inc http://www.candelatech.com _______________________________________________ Xorp-hackers mailing list [email protected] http://mailman.ICSI.Berkeley.EDU/mailman/listinfo/xorp-hackers
