A few weeks ago, I submitted a change proposal to include/osgViewer/ViewerBase, 
wherein I recommended removing a redundant call to _currentContext.valid(), in 
releaseContext(). That was wrong. The line in question (line 254) reads:

    if (_currentContext.valid() && _currentContext->valid())

note that the two calls to valid() are prefixed with the "." operator first, 
and then the "->" operator... turns out, _currentContext is actually an 
observer_ptr<osg::GraphicsContext>, and not a osg::GraphicsContext... oops. In 
my defense, that is phenomenally unclear code. Perhaps renaming one of those 
valid() calls would make it more clear? I don't know, but that line, at the 
very least, needs a comment explaining that it is, in fact, correct.

Next, I ran across a couple of segfaults while running with three separate GC's 
and three cameras (one master, two slaves), all rendering from the same scene. 
I traced the problem to include/osg/buffered_value, in both 
buffered_value<T>::operator[], and in buffered_object<T>::operator[]. Both 
dynamically resize _array any time pos exceeds _array.size(). In a threaded 
environment, if one thread tries to access _array while another thread is 
resizing it, the result is a segfault. 

I don't know if I'm doing something wrong or not, but I added an 
OpenThreads::Mutex to both classes and that seems to solve the problem for me 
(updated buffered_value file attached).

Kyle


Attachment: buffered_value
Description: buffered_value

_______________________________________________
osg-submissions mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org

Reply via email to