boost flyweight panics

446 views Asked by At

I am using Boost 1.39. I've implemented my class using boost::flyweight<no_locking, hashed_factory<> > (my application is single-threaded). Test program for my class passes fine, but when I use in in the application, I panic in

#9  0x08de7c3e in boost::flyweights::detail::refcounted_value<boost::flyweights::detail::default_value_policy<SharedFileAttr>::rep_type, SharedFileAttr>::release (this=0x0) at /usr/include/boost/flyweight/refcounted.hpp:89
#10 0x08de7517 in boost::flyweights::detail::refcounted_handle<boost::flyweights::detail::refcounted_value<boost::flyweights::detail::default_value_policy<SharedFileAttr>::rep_type, SharedFileAttr> const*, boost::flyweights::detail::flyweight_core_tracking_helper<boost::flyweights::detail::default_value_policy<SharedFileAttr>, mpl_::na, boost::flyweights::refcounted, boost::flyweights::hashed_factory<mpl_::na, mpl_::na, mpl_::na, 0>, boost::flyweights::no_locking, boost::flyweights::static_holder> >::~refcounted_handle (this=0xf32fe61c, 
    __in_chrg=<value optimized out>) at /usr/include/boost/flyweight/refcounted.hpp:131
#11 0x08e2edfe in boost::flyweights::flyweight<SharedFileAttr, boost::flyweights::no_locking, boost::flyweights::hashed_factory<mpl_::na, mpl_::na, mpl_::na, 0>, boost::parameter::void_, boost::parameter::void_, boost::parameter::void_>::operator= (this=0xf32fe7e4, x=...)
    at /usr/include/boost/flyweight/flyweight.hpp:196

Notice that in frame #9 this is 0x0

I'm not sure how is it possible from my code that uses the boost::flyweight to cause reference counting issues. After all, my interface only includes methods to add flyweight objects, and destroy them.

I have no idea how to go about figuring out the problem. Any ideas?

1

There are 1 answers

0
dbbd On

Well, embarrassing, but the problem was trying to assign an uninitialized flyweight object to another. Must remember to initialize all class members ...