HI David,

I have compiled your test code with the attached CmakeLists.txt and can
confirm I get the crash on my Kubuntu 13.04 + 64bit system.

With running gdb:

(gdb) run 48 1000000 2 2

The stack track I'm getting is:

*** Error in `/home/robert/Contributors/DavidFries/threadednotify': double
free or corruption (top): 0x00007fffd8000b40 ***
*** Error in `/home/robert/Contributors/DavidFries/threadednotify[New
Thread 0x7fffe0ff9700 (LWP 6024)]

Program received signal SIGABRT, Aborted.
[Switching to Thread 0x7ffff0ee7700 (LWP 6017)]
0x00007ffff6dee037 in raise () from /lib/x86_64-linux-gnu/libc.so.6
(gdb) where
#0  0x00007ffff6dee037 in raise () from /lib/x86_64-linux-gnu/libc.so.6
#1  0x00007ffff6df1698 in abort () from /lib/x86_64-linux-gnu/libc.so.6
#2  0x00007ffff6e2b5ab in ?? () from /lib/x86_64-linux-gnu/libc.so.6
#3  0x00007ffff6e37a46 in ?? () from /lib/x86_64-linux-gnu/libc.so.6
#4  0x00007ffff742f2a9 in std::basic_stringbuf<char,
std::char_traits<char>, std::allocator<char> >::overflow(int) ()
   from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#5  0x00007ffff7433976 in std::basic_streambuf<char, std::char_traits<char>
>::xsputn(char const*, long) () from
/usr/lib/x86_64-linux-gnu/libstdc++.so.6
#6  0x00007ffff7426b83 in ?? () from
/usr/lib/x86_64-linux-gnu/libstdc++.so.6
#7  0x00007ffff7427dc4 in std::ostreambuf_iterator<char,
std::char_traits<char> > std::num_put<char, std::ostreambuf_iterator<char,
std::char_traits<char> >
>::_M_insert_int<long>(std::ostreambuf_iterator<char,
std::char_traits<char> >, std::ios_base&, char, long) const ()
   from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#8  0x00007ffff7427f2d in std::num_put<char, std::ostreambuf_iterator<char,
std::char_traits<char> > >::do_put(std::ostreambuf_iterator<char,
std::char_traits<char> >, std::ios_base&, char, long) const () from
/usr/lib/x86_64-linux-gnu/libstdc++.so.6
#9  0x00007ffff742adf6 in std::ostream& std::ostream::_M_insert<long>(long)
() from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#10 0x000000000040299a in Spam::run (this=0x60d9b8) at
/home/robert/Contributors/DavidFries/ThreadedNotify.cpp:88
#11 0x00007ffff769c7d0 in
OpenThreads::ThreadPrivateActions::StartThread(void*) () from
/home/robert/OpenSceneGraph/lib/libOpenThreads.so.14
#12 0x00007ffff6ba1f8e in start_thread () from
/lib/x86_64-linux-gnu/libpthread.so.0
#13 0x00007ffff6eb0e1d in clone () from /lib/x86_64-linux-gnu/libc.so.6

This suggests the ostream being shared between threads is not thread safe.

I don't believe it's the Notify.cpp code itself that is directly causing
the problem, rather it looks to be that ostream implementation is the
problem.  Solving may not be easy without having a ostream per thread.

Thoughts?
Robert.
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to