Boost logo

Boost Users :

From: Manges, Ross G (Ross.G.Manges_at_[hidden])
Date: 2005-04-14 18:30:10


Joaquin M Lopez Munoz wrote:
> Two (main) possibilities: the shared_ptr is invalid or
> my code has a bug. Could you test the pointer for validity before
> making the insertion?
>
> m.check_invariant_();
> // check ptr before insertion
> m.insert(ptr);
OK, so I print out the members of the object that the shared_ptr
encapsulates, and it appears that the shared_ptr object is OK before
insertion.

> If still the error is detected inside insert(), we can try to produce
> some sort of poorman dump of the container: define
> BOOST_MULTI_INDEX_INVARIANT_ASSERT to throw an exception on failure
> and wrap the call to insert() as follows:
OK, I tried to use the following code, and recompiled, but I don't catch
the exception, and in turn I see rather unpredictable behavior before my
program dies violently. Is my macro definition incorrect?

//************* begin ****************
struct invariant_exception
{
    invariant_exception() {}
};

#define BOOST_MULTI_INDEX_INVARIANT_ASSERT(expr) \
if(!(expr)){throw invariant_exception();}
//************* end *****************

> try{
> m.insert(...);
> }
> catch(/* exception thrown by the assert */){
> // dump the contents of m
> }
>
> Can you do that? Notice something weird in the dump?
> Can you post the dump?
I will post the dump if I can get it to create one.

Thanks for your perseverance!
--Ross


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net