
On Wed, Jan 30, 2008 at 01:41:15PM +0000, Martin Fisher wrote:
Using the boost_1_35_0 svn library download and Visual C++ 2008 Express edition. Originally compiled as a CLR program. Recompiling using native Win32 still gives a crash during program termination - in atomic_count_win32.hpp in operator-- (BOOST_INTERLOCKED_DECREMENT) Unhandled exception at 0x010752b9 in fly2.exe: 0xC0000005: Access violation writing location 0x00779040.
There is indeed a bug somewhere. I could reproduce it on Linux which doesn't suffer from CLR/libc/... mess. I just compiled it (code from trunk) and it crashes. valgrind reports: ==25155== Invalid read of size 4 ==25155== at 0x8049678: boost::detail::atomic_count::atomic_exchange_and_add(int*, int) (atomic_count_gcc_x86.hpp:74) ==25155== by 0x80496A2: boost::detail::atomic_count::operator--() (atomic_count_gcc_x86.hpp:42) ==25155== by 0x8049835: boost::flyweights::detail::refcounted_value<std::string>::release() const (refcounted.hpp:61) ==25155== by 0x804BEF6: boost::flyweights::detail::refcounted_handle<boost::flyweights::detail::refcounted_value<std::string> const*, boost::flyweights::detail::flyweight_core_tracking_helper<std::string, mpl_::na, boost::flyweights::refcounted, boost::flyweights::hashed_factory<mpl_::na, mpl_::na, mpl_::na, 0>, boost::flyweights::simple_locking, boost::flyweights::static_holder> >::~refcounted_handle() (refcounted.hpp:91) ==25155== by 0x804BF20: boost::flyweights::flyweight<std::string, boost::parameter::void_, boost::parameter::void_, boost::parameter::void_, boost::parameter::void_, boost::parameter::void_>::~flyweight() (flyweight.hpp:64) ==25155== by 0x804BF34: void std::_Destroy<boost::flyweights::flyweight<std::string, boost::parameter::void_, boost::parameter::void_, boost::parameter::void_, boost::parameter::void_, boost::parameter::void_> >(boost::flyweights::flyweight<std::string, boost::parameter::void_, boost::parameter::void_, boost::parameter::void_, boost::parameter::void_, boost::parameter::void_>*) (stl_construct.h:107) ==25155== by 0x804BF4A: void std::__destroy_aux<boost::flyweights::flyweight<std::string, boost::parameter::void_, boost::parameter::void_, boost::parameter::void_, boost::parameter::void_, boost::parameter::void_>*>(boost::flyweights::flyweight<std::string, boost::parameter::void_, boost::parameter::void_, boost::parameter::void_, boost::parameter::void_, boost::parameter::void_>*, boost::flyweights::flyweight<std::string, boost::parameter::void_, boost::parameter::void_, boost::parameter::void_, boost::parameter::void_, boost::parameter::void_>*, std::__false_type) (stl_construct.h:122) ==25155== by 0x804BF79: void std::_Destroy<boost::flyweights::flyweight<std::string, boost::parameter::void_, boost::parameter::void_, boost::parameter::void_, boost::parameter::void_, boost::parameter::void_>*>(boost::flyweights::flyweight<std::string, boost::parameter::void_, boost::parameter::void_, boost::parameter::void_, boost::parameter::void_, boost::parameter::void_>*, boost::flyweights::flyweight<std::string, boost::parameter::void_, boost::parameter::void_, boost::parameter::void_, boost::parameter::void_, boost::parameter::void_>*) (stl_construct.h:155) ==25155== by 0x804BF93: void std::_Destroy<boost::flyweights::flyweight<std::string, boost::parameter::void_, boost::parameter::void_, boost::parameter::void_, boost::parameter::void_, boost::parameter::void_>*, boost::flyweights::flyweight<std::string, boost::parameter::void_, boost::parameter::void_, boost::parameter::void_, boost::parameter::void_, boost::parameter::void_> >(boost::flyweights::flyweight<std::string, boost::parameter::void_, boost::parameter::void_, boost::parameter::void_, boost::parameter::void_, boost::parameter::void_>*, boost::flyweights::flyweight<std::string, boost::parameter::void_, boost::parameter::void_, boost::parameter::void_, boost::parameter::void_, boost::parameter::void_>*, std::allocator<boost::flyweights::flyweight<std::string, boost::parameter::void_, boost::parameter::void_, boost::parameter::void_, boost::parameter::void_, boost::parameter::void_> >) (stl_construct.h:182) ==25155== by 0x804BFD4: std::vector<boost::flyweights::flyweight<std::string, boost::parameter::void_, boost::parameter::void_, boost::parameter::void_, boost::parameter::void_, boost::parameter::void_>, std::allocator<boost::flyweights::flyweight<std::string, boost::parameter::void_, boost::parameter::void_, boost::parameter::void_, boost::parameter::void_, boost::parameter::void_> > >::~vector() (stl_vector.h:268) ==25155== by 0x80492B1: __tcf_2 (test.cpp:12) ==25155== by 0x4870F13: exit (in /lib/i686/cmov/libc-2.7.so) ==25155== Address 0x6fd1374 is not stack'd, malloc'd or (recently) free'd ==25155== ==25155== Invalid read of size 4 ==25155== at 0x8049678: boost::detail::atomic_count::atomic_exchange_and_add(int*, int) (atomic_count_gcc_x86.hpp:74) ==25155== by 0x80496C0: boost::detail::atomic_count::operator long() const (atomic_count_gcc_x86.hpp:47) ==25155== by 0x8049BD3: boost::flyweights::detail::refcounted_value<std::string>::count() const (refcounted.hpp:59) ==25155== by 0x804BABA: boost::flyweights::detail::refcounted_handle<boost::flyweights::detail::refcounted_value<std::string> const*, [snip] Jens