Re: [Boost-users] boost::exception - leaking error_info
Date: Fri, 20 Feb 2009 19:17:55 -0800 From: Emil Dotchevski
Subject: Re: [Boost-users] boost::exception - leaking error_info
On Fri, Feb 20, 2009 at 3:00 PM, Bruce Laing
wrote: This program seems to be leaking boost::exception::error_info objects. Is there something missing here?
- Bruce
What platform? Do you have a complete program that shows the problem?
This test seems to work as expected:
#include "boost/exception.hpp"
class counter
....
int main() { c=0; try { throw_func(); } catch( an_exception & ) { assert(c>0); } assert(!c); }
Emil Dotchevski Reverge Studios, Inc. http://www.revergestudios.com/reblog/index.php?n=ReCode
Emil, The platform is vc++ 8, boost 1.37. Since submitting my inquiry to the list, I cut my boost.exception code out into a separate test program that is very similar to the test code you gave in your reply (thanks for that) , but my test program does not leak, so the problem seems to involve some aspect of context from the original surrounding code that I'm not yet able to identify. I'll write back with an update if I can isolate the interaction that triggers the leakage. - Bruce
On Mon, Feb 23, 2009 at 9:31 AM, Bruce Laing
Emil,
The platform is vc++ 8, boost 1.37.
Since submitting my inquiry to the list, I cut my boost.exception code out into a separate test program that is very similar to the test code you gave in your reply (thanks for that) , but my test program does not leak, so the problem seems to involve some aspect of context from the original surrounding code that I'm not yet able to identify. I'll write back with an update if I can isolate the interaction that triggers the leakage.
Please do keep us posted, it's kind of important for exception objects not to leak memory. :) A couple of things to consider, assuming this isn't a compiler bug (I'm sure these are unlikely but I'm running out of ideas): - Do your exceptions cross DLL boundary by any chance? If a DLL links to the static runtime, you might not be tracking the memory correctly - Do you use multiple threads? It is *not* safe to access the same exception object from multiple threads. If you use boost::exception_ptr to transport exceptions between threads, keep in mind that that only makes it OK to *refer* to the same exception object from multiple threads, accessing the exception object itself requires additional synchronization. Emil Dotchevski Reverge Studios, Inc. http://www.revergestudios.com/reblog/index.php?n=ReCode
participants (2)
-
Bruce Laing
-
Emil Dotchevski