On Wed, 3 Apr 2013, Roy Stogner wrote:
This is actually not too hard to fix. We just use the "Construct on
First Use" idiom for the containers. I'll demonstrate with a patch
shortly.
Try the attached. It fixes the problem for me, but since static
initialization order problems are pseudorandom it's possible that
there's some other bug that I'm just not managing to trigger or not
managing to trigger anymore.
---
Roy
diff --git a/src/base/libmesh_singleton.C b/src/base/libmesh_singleton.C
index 977c743..f7ea7e4 100644
--- a/src/base/libmesh_singleton.C
+++ b/src/base/libmesh_singleton.C
@@ -38,10 +38,19 @@ namespace
// global list of runtime Singleton objects - created dynamically,
// cleaned up in reverse order.
typedef std::vector<Singleton*> SingletonList;
- SingletonList singleton_cache;
+
+ SingletonList& get_singleton_cache()
+ {
+ static SingletonList singleton_cache;
+ return singleton_cache;
+ }
typedef std::vector<Singleton::Setup*> SetupList;
- SetupList setup_cache;
+ SetupList& get_setup_cache()
+ {
+ static SetupList setup_cache;
+ return setup_cache;
+ }
} // end anonymous namespace
@@ -56,7 +65,7 @@ namespace libMesh
{
SingletonMutex::scoped_lock lock(singleton_mtx);
- singleton_cache.push_back (this);
+ get_singleton_cache().push_back (this);
}
@@ -65,7 +74,7 @@ namespace libMesh
{
SingletonMutex::scoped_lock lock(setup_mtx);
- setup_cache.push_back (this);
+ get_setup_cache().push_back (this);
}
@@ -74,8 +83,8 @@ namespace libMesh
{
SingletonMutex::scoped_lock lock(setup_mtx);
- for (SetupList::iterator it = setup_cache.begin();
- it!=setup_cache.end(); ++it)
+ for (SetupList::iterator it = get_setup_cache().begin();
+ it!=get_setup_cache().end(); ++it)
{
libmesh_assert (*it != NULL);
(*it)->setup();
@@ -88,15 +97,15 @@ namespace libMesh
{
SingletonMutex::scoped_lock lock(singleton_mtx);
- for (SingletonList::reverse_iterator it = singleton_cache.rbegin();
- it!=singleton_cache.rend(); ++it)
+ for (SingletonList::reverse_iterator it = get_singleton_cache().rbegin();
+ it!=get_singleton_cache().rend(); ++it)
{
libmesh_assert (*it != NULL);
delete *it;
*it = NULL;
}
- singleton_cache.clear();
+ get_singleton_cache().clear();
}
------------------------------------------------------------------------------
Minimize network downtime and maximize team effectiveness.
Reduce network management and security costs.Learn how to hire
the most talented Cisco Certified professionals. Visit the
Employer Resources Portal
http://www.cisco.com/web/learning/employer_resources/index.html
_______________________________________________
Libmesh-devel mailing list
Libmesh-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libmesh-devel