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: | 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);
Note:
See TracTickets
for help on using tickets.

Fixed at
https://github.com/boostorg/flyweight/commit/7e984210f2f6ac4fed4fcda09cd714b64a5191de