|
From: SourceForge.net <no...@so...> - 2011-11-24 10:48:59
|
Bugs item #3441748, was opened at 2011-11-24 02:48 Message generated for change (Tracker Item Submitted) made by mortoray You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=112740&aid=3441748&group_id=12740 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None Group: None Status: Open Resolution: None Priority: 5 Private: No Submitted By: edA-qa mort-ora-y (mortoray) Assigned to: Nobody/Anonymous (nobody) Summary: Singleton::instance is not thread-safe Initial Comment: Singleton::instance is not thread-safe in its creation of new Sessions. There is no lock around the access to std::map and thus two threads creating a new session at the same time will conflict. This is a case that actually happens in our code: we manage to get two cores started in their processing at the same time and thus both attempt to create a session at the same time. They do this by having the sessionId return a different key per thread. There is no way for the end-user to make this function thread-safe as any thread can request the session at any time. This actually makes QuantLib as a whole not thread-safe then, simply because you cannot safely obtain a per-thread session. The instance() method needs to have a read-write lock so that it works correctly even when creating new sessions. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=112740&aid=3441748&group_id=12740 |