Opened 9 years ago

Closed 9 years ago

#9553 closed Bugs (fixed)

destruction of flyweights fails from a module which never creates flyweigths

Reported by: Axel Habermann <haa@…> Owned by: Joaquín M López Muñoz
Milestone: To Be Determined Component: flyweight
Version: Boost 1.55.0 Severity: Showstopper
Keywords: Cc: si@…, mue@…

Description

Using a factory pattern together with shared_ptr, all flyweight instances are created in one dll only. Due to shared ownership, they might be destroyed from a dll which never creates a single flyweight. Because erase does not call core::init(), the module global state for flyweight management is never initialized, even when using intermodule_holder, leading to a crash when accessed.

It is not possible to provide a minimal example, because the example must consist of different modules.

The following patch fixes the problem:

Index: flyweight/detail/flyweight_core.hpp
===================================================================
--- flyweight/detail/flyweight_core.hpp	(revision 462875)
+++ flyweight/detail/flyweight_core.hpp	(revision 462876)
@@ -65,6 +65,7 @@
   template<typename Checker>
   static void erase(const handle_type& h,Checker chk)
   {
+    core::init();
     typedef typename core::lock_type lock_type;
     lock_type lock(core::mutex());
     if(chk(h))core::factory().erase(h);

Change History (1)

comment:1 by Joaquín M López Muñoz, 9 years ago

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.