Multithreaded static initialization bugs in Inventor plugin
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
openscenegraph (Ubuntu) |
Fix Released
|
Undecided
|
Unassigned |
Bug Description
There are three instances of a classical method-local-static multithreaded initialization bug in the Inventor plugin for OSG that trigger various memory faults when reading multiple VRML files in parallel via osgDB::
static std::map<
static bool once = true;
if(once) { ...fill myHandyMap; once = false }
... use myHandyMap;
To repeat: try loading multiple VRML files from multiple threads. The liklihood of the bug depends on many factors, but my applicaiton, which parallel-loads some dozens of small (<100K) VRML files on startup, triggers this problem 25% of the time or more.
The attached patch (inventor-
1 - Inheriting MyHandyMap from std::map, then
2 - Moving the map initialization into the derived constructor, which
3 - Is intrinsically protected from multithread issues by g++ (and is part of the C++ standard), unless you pass -fno-threadsafe
This patch was made via and may be appended to the quilt series for this package.
A peek at the OSG trunk indicates that this problem persists upstream as well:
http://
Should I also submit this upstream, or will that happen naturally as part of the ubuntu package ecosystem?
Of note, a similar, but more sinister set of multithreading bugs exist in the actual VRML plugin, but this plugin is not built as part of the ubuntu package, as it seems to depend on the no-longer-supported OpenVRML packages. I also have an untested patch that stabs at these problems if it is worth providing.