[Insight-developers] Thread safety and STL containers
Lorensen, William E (CRD)
lorensen@crd.ge.com
Wed, 28 Nov 2001 08:44:01 -0500
Folks,
I've been trying to track down intermittent crashes in some itk tests. The crashes occurred on both
solaris and sgi.
itkCurvatureFlowTest would crash occasionally on multi processors. I tracked the problem dowm to the
ThreadedCalculateChange method in Common/itkDenseFiniteDifferenceImageFilter. It seemed that the
faceList (implemented with the STL list container) was geeting corrupted.
To make a long story (and long day) short, I searched google with
gnu stl thread safe
which led me to:
http://www.sgi.com/tech/stl/thread_safety.html <http://www.sgi.com/tech/stl/thread_safety.html>
I fixed "the problem" by putting a lock around the push_back method on the list.
So... beware of STL usage in threaded code.
Bill