Modify

Opened 9 years ago

Last modified 9 years ago

#2944 new Bugs

boost::archive::xml_iarchive hangs, if BOOST_SP_USE_PTHREADS used

Reported by: highcatland@… Owned by: Joel de Guzman
Milestone: Boost 1.39.0 Component: serialization
Version: Boost 1.38.0 Severity: Problem
Keywords: shared_ptr serialization xml_iarchive Cc:

Description

I use 'BOOST_SP_USE_PTHREADS' option, with serialization library. When I try to create xml_iarchive, application hangs.

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

Also tried: x32 Gentoo Linux, i686-pc-linux-gnu-4.1.2, glibc: 2.6.1

  • works perfectly, without hangs.

Backtrace while the application hang:

0x00007ffb03bf3414 in lll_lock_wait () from /lib/libpthread.so.0 (gdb) bt #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<char>::init_chset () #5 0x0000000000440ff1 in boost::archive::basic_xml_grammar<char>::basic_xml_grammar () #6 0x0000000000432035 in boost::archive::xml_iarchive_impl<boost::archive::xml_iarchive>::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

Attachments (1)

boost_archive_load_test.cpp (454 bytes) - added by highcatland@… 9 years ago.
testcase

Download all attachments as: .zip

Change History (5)

Changed 9 years ago by highcatland@…

Attachment: boost_archive_load_test.cpp added

testcase

comment:1 Changed 9 years ago by highcatland@…

Sorry for formatting.

Bactrace is:

#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<char>::init_chset ()
#5  0x0000000000440ff1 in boost::archive::basic_xml_grammar<char>::basic_xml_grammar ()
#6  0x0000000000432035 in boost::archive::xml_iarchive_impl<boost::archive::xml_iarchive>::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

comment:2 Changed 9 years ago by Robert Ramey

Owner: changed from Robert Ramey to No-Maintainer

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.

FYI, here is the code from xml_grammar.cpp

ypedef basic_xml_grammar<char> xml_grammar;

/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// specific definitions for char based XML

template<>
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 ;
}

This is the last the serialization library sees of it before it tanks.

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.

Robert Ramey

comment:3 Changed 9 years ago by highcatland@…

I investigated boost sources a bit, and the issue seems weird for me.

  1. As I guess, xml_grammar.cpp has no relations with any smart pointers and synchronization.


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.

How release() member function was called, while the only constructor wasn't? (Some sort of control flow corruption?)

When I removed mutex locking from the release() method - during the test release() repeated several times, and then program continues correctly.

And again, this reproduced for me only at x86_64 and ARM platforms.
On x32 - all is ok. I've traced the sp_counted_base, and none of it's methods was called.

comment:4 Changed 9 years ago by Robert Ramey

Owner: changed from No-Maintainer to Joel de Guzman

Modify Ticket

Change Properties
Set your email in Preferences
Action
as new The owner will remain Joel de Guzman.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.