Boost C++ Libraries: Ticket #2944: boost::archive::xml_iarchive hangs, if BOOST_SP_USE_PTHREADS used https://svn.boost.org/trac10/ticket/2944 <p> I use 'BOOST_SP_USE_PTHREADS' option, with serialization library. When I try to create xml_iarchive, application hangs. </p> <p> Reproduced on: x86_64 Gentoo Linux, x86_64-pc-linux-gnu-4.3.3, glibc: 2.9_p20081201 ARM (Openmoko toolchain): gcc 4.1.2, glibc: 2.6.1 </p> <p> Also tried: x32 Gentoo Linux, i686-pc-linux-gnu-4.1.2, glibc: 2.6.1 </p> <ul><li>works perfectly, without hangs. </li></ul><p> Backtrace while the application hang: </p> <p> 0x00007ffb03bf3414 in <span class="underline">lll_lock_wait () from /lib/libpthread.so.0 (gdb) bt <a class="missing ticket">#0</a> 0x00007ffb03bf3414 in </span>lll_lock_wait () from /lib/libpthread.so.0 <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/1" title="#1: Bugs: boost.build causes ftjam to segfault (closed: Wont Fix)">#1</a> 0x00007ffb03beec50 in _L_lock_55 () from /lib/libpthread.so.0 <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/2" title="#2: Bugs: list::size should be const (closed: fixed)">#2</a> 0x00007ffb03bee53e in pthread_mutex_lock () from /lib/libpthread.so.0 <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/3" title="#3: Bugs: automatic conversion and overload proble (closed: fixed)">#3</a> 0x0000000000427c43 in boost::detail::sp_counted_base::release (this=0x672140) at /home/distr/boost/x86_64_boost_1_38_0/include/boost-1_38/boost/detail/sp_counted_base_pt.hpp:91 <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/4" title="#4: Bugs: any_ptr in any library documentation? (closed: Fixed)">#4</a> 0x0000000000433189 in boost::archive::basic_xml_grammar&lt;char&gt;::init_chset () <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/5" title="#5: Bugs: shared_ptr and self-owning objects (closed: Fixed)">#5</a> 0x0000000000440ff1 in boost::archive::basic_xml_grammar&lt;char&gt;::basic_xml_grammar () <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/6" title="#6: Bugs: tie in utility.hpp and tuple.hpp clash. (closed: Duplicate)">#6</a> 0x0000000000432035 in boost::archive::xml_iarchive_impl&lt;boost::archive::xml_iarchive&gt;::xml_iarchive_impl () <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/7" title="#7: Bugs: g++ 2.96 requires NO_STRINGSTREAM (closed: Fixed)">#7</a> 0x0000000000427b81 in xml_iarchive (this=0x7fff0d07b840, is=@0x7fff0d07b630, flags=0) at /home/distr/boost/x86_64_boost_1_38_0/include/boost-1_38/boost/archive/xml_iarchive.hpp:119 <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/8" title="#8: Bugs: prop in undirected graph + out_edges (closed: Works For Me)">#8</a> 0x00000000004272fb in test_xmlArchive () at /home/remote_projects/fl-dict/src/test/boost_archive_load_test.cpp:43 <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/9" title="#9: Bugs: config_info ambiguity error (closed: Invalid)">#9</a> 0x00000000004273fb in main (argc=1, argv=0x7fff0d07b9c8) at /home/remote_projects/fl-dict/src/test/boost_archive_load_test.cpp:15 </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/2944 Trac 1.4.3 highcatland@… Mon, 13 Apr 2009 21:54:34 GMT attachment set https://svn.boost.org/trac10/ticket/2944 https://svn.boost.org/trac10/ticket/2944 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">boost_archive_load_test.cpp</span> </li> </ul> <p> testcase </p> Ticket highcatland@… Mon, 13 Apr 2009 22:01:33 GMT <link>https://svn.boost.org/trac10/ticket/2944#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/2944#comment:1</guid> <description> <p> Sorry for formatting. </p> <p> Bactrace is: </p> <pre class="wiki">#0 0x00007ffb03bf3414 in __lll_lock_wait () from /lib/libpthread.so.0 #1 0x00007ffb03beec50 in _L_lock_55 () from /lib/libpthread.so.0 #2 0x00007ffb03bee53e in pthread_mutex_lock () from /lib/libpthread.so.0 #3 0x0000000000427c43 in boost::detail::sp_counted_base::release (this=0x672140) at /home/distr/boost/x86_64_boost_1_38_0/include/boost-1_38/boost/detail/sp_counted_base_pt.hpp:91 #4 0x0000000000433189 in boost::archive::basic_xml_grammar&lt;char&gt;::init_chset () #5 0x0000000000440ff1 in boost::archive::basic_xml_grammar&lt;char&gt;::basic_xml_grammar () #6 0x0000000000432035 in boost::archive::xml_iarchive_impl&lt;boost::archive::xml_iarchive&gt;::xml_iarchive_impl () #7 0x0000000000427b81 in xml_iarchive (this=0x7fff0d07b840, is=@0x7fff0d07b630, flags=0) at /home/distr/boost/x86_64_boost_1_38_0/include/boost-1_38/boost/archive/xml_iarchive.hpp:119 #8 0x00000000004272fb in test_xmlArchive () at /home/remote_projects/fl-dict/src/test/boost_archive_load_test.cpp:43 #9 0x00000000004273fb in main (argc=1, argv=0x7fff0d07b9c8) at /home/remote_projects/fl-dict/src/test/boost_archive_load_test.cpp:15 </pre> </description> <category>Ticket</category> </item> <item> <dc:creator>Robert Ramey</dc:creator> <pubDate>Tue, 14 Apr 2009 03:59:09 GMT</pubDate> <title>owner changed https://svn.boost.org/trac10/ticket/2944#comment:2 https://svn.boost.org/trac10/ticket/2944#comment:2 <ul> <li><strong>owner</strong> changed from <span class="trac-author">Robert Ramey</span> to <span class="trac-author">No-Maintainer</span> </li> </ul> <p> The stack trace indicates that the issue resides in either spirit or shared_ptr libraries which are used for loading xml files. There is information related to using BOOST_USE_PTHREADS in the shared_ptr library. Other than that, I don't know much about it. Note that the serialization library (as far as I know) is thread safe without the need for doing any locking. </p> <p> FYI, here is the code from xml_grammar.cpp </p> <pre class="wiki">ypedef basic_xml_grammar&lt;char&gt; xml_grammar; /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 // specific definitions for char based XML template&lt;&gt; void xml_grammar::init_chset(){ Char = chset_t("\x9\xA\xD\x20-\x7f\x80\x81-\xFF"); Letter = chset_t("\x41-\x5A\x61-\x7A\xC0-\xD6\xD8-\xF6\xF8-\xFF"); Digit = chset_t("0-9"); Extender = chset_t('\xB7'); Sch = chset_t("\x20\x9\xD\xA"); NameChar = Letter | Digit | chset_p("._:-") | Extender ; } </pre><p> This is the last the serialization library sees of it before it tanks. </p> <p> I've tried to pass this on to Joel Guzman the inventor of spirit library but I've been unable to find his name here. So for now, I'm forwarding this to no_maintainer. Sorry I couldn't be of more help. </p> <p> Robert Ramey </p> Ticket highcatland@… Tue, 14 Apr 2009 21:03:52 GMT <link>https://svn.boost.org/trac10/ticket/2944#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/2944#comment:3</guid> <description> <p> I investigated boost sources a bit, and the issue seems weird for me. </p> <ol><li>As I guess, xml_grammar.cpp has no relations with any smart pointers and synchronization. </li></ol><p> <br />2. The hang happens in boost/detail/sp_counted_base_pt.hpp source code, when trying to acquire pthread's mutex lock. I've traced the calls of sp_counted_base class. The only member function was called is sp_counted_base::release(). Constructor of sp_counted_base wasn't called at all! So, the 'm_' pthread mutex wasn't initialized, which caused the hang. </p> <p> How release() member function was called, while the only constructor wasn't? (Some sort of control flow corruption?) </p> <p> When I removed mutex locking from the release() method - during the test release() repeated several times, and then program continues correctly. </p> <p> And again, this reproduced for me only at x86_64 and ARM platforms. <br />On x32 - all is ok. I've traced the sp_counted_base, and none of it's methods was called. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Robert Ramey</dc:creator> <pubDate>Mon, 20 Apr 2009 19:36:29 GMT</pubDate> <title>owner changed https://svn.boost.org/trac10/ticket/2944#comment:4 https://svn.boost.org/trac10/ticket/2944#comment:4 <ul> <li><strong>owner</strong> changed from <span class="trac-author">No-Maintainer</span> to <span class="trac-author">Joel de Guzman</span> </li> </ul> Ticket