[date_time] SIGSEGV in multithreaded code on Solaris Sparc

The following multithreaded code causes SIGSEGV in Solaris Sparc 10: #include <boost/thread.hpp> #include <sstream> #include <boost/date_time/posix_time/posix_time.hpp> using namespace std; using namespace boost; void fun(); int main(int argc, char** argv) { thread t1(fun); thread t2(fun); pause(); return (EXIT_SUCCESS); } void fun() { while(true) { stringstream str; str << posix_time::microsec_clock::local_time().time_of_day(); } } The stackstrace from the core dump is the following: ----------------- lwp# 1 / thread# 1 -------------------- ffffffff7ead3c50 _pause (ffffffff7ffff4e0, ffffffff7ee00200, 0, ffffffff7ef08ba4, ffffffff7e300140, 0) + 8 0000000100015ea0 main (1, ffffffff7ffff5f8, ffffffff7ffff608, ffffffff7ea4aedc, ffffffff7e3000c0, ffffffff7ee00200) + 58 000000010001589c _start (0, 0, 0, 0, 0, 0) + 17c ----------------- lwp# 2 / thread# 2 -------------------- ffffffff7ea3b670 strlen (ffffffff7e0fba38, 1001377c0, 1, ffffffff7f510d00, c, ffffffff7f51d608) + 50 0000000100017c60 std::locale::locale<boost::date_time::time_facet<boost::posix_time::ptime,char, std::ostreambuf_iterator<char,std::char_traits<char>> > >#Nvariant 1(const std::locale&,__type_0*) (ffffffff7e0fba38, ffffffff7e0fba30, 1001362a0, 1061b4, ffffffff7f00ef70, 1) + 68 000000010001728c std::basic_ostream<__type_0,__type_1>&boost::posix_time::operator<<< char,std::char_traits<char>>(std::basic_ostream<__type_0,__type_1>&,const boost::posix_time::time_duration&) (ffffffff7e0fbbb0, ffffffff7e0fbb90, ffffffff7e0fbbb8, ffffffff7e0fbd08, ffffffff7f51a160, ffffffff7f510d00) + 22c 0000000100015f84 void fun() (ffffffff7f915528, 10012f920, 3, ffffffff7ee00b58, 18, 3) + 5c 0000000100020940 void boost::detail::thread_data<void(*)()>::run() (10012f920, 0, 158, 10af4c, 0, 0) + 10 ffffffff7f8095b4 thread_proxy (10012f920, 2, 10012de88, 10012f920, 3, 48) + 94 ffffffff7ead2e7c _lwp_start (0, 0, 0, 0, 0, 0) ----------------- lwp# 3 / thread# 3 -------------------- ffffffff7f3d3130 std::locale::~locale #Nvariant 1() (ffffffff7f915528, 1001311f0, 3, ffffffff7ee01358, 18, 3) + 8 0000000100020940 void boost::detail::thread_data<void(*)()>::run() (1001311f0, 0, 158, 10af4c, 0, 0) + 10 ffffffff7f8095b4 thread_proxy (1001311f0, 2, 10012df30, 1001311f0, 3, 5d) + 94 ffffffff7ead2e7c _lwp_start (0, 0, 0, 0, 0, 0) When running with just one thread, it works fine. So it's a race condition aparently. The stacktrace varies. This is another one: ----------------- lwp# 1 / thread# 1 -------------------- ffffffff7ead3c50 _pause (ffffffff7ffff4e0, ffffffff7ee00200, 0, ffffffff7ef08ba4, ffffffff7e300140, 0) + 8 0000000100015ea0 main (1, ffffffff7ffff5f8, ffffffff7ffff608, ffffffff7ea4aedc, ffffffff7e3000c0, ffffffff7ee00200) + 58 000000010001589c _start (0, 0, 0, 0, 0, 0) + 17c ----------------- lwp# 2 / thread# 2 -------------------- ffffffff7f3d3130 std::locale::~locale #Nvariant 1() (ffffffff7f915528, 10012f920, 3, ffffffff7ee00b58, 18, 3) + 8 0000000100020940 void boost::detail::thread_data<void(*)()>::run() (10012f920, 0, 158, 10af4c, 0, 0) + 10 ffffffff7f8095b4 thread_proxy (10012f920, 2, 10012de88, 10012f920, 3, 48) + 94 ffffffff7ead2e7c _lwp_start (0, 0, 0, 0, 0, 0) ----------------- lwp# 3 / thread# 3 -------------------- 000000010001e090 unsigned long boost::date_time::gregorian_calendar_base< boost::date_time::year_month_day_base<boost::gregorian::greg_year, boost::gregorian::greg_month,boost::gregorian::greg_day>, unsigned long>::day_number(const boost::date_time:: year_month_day_base<boost::gregorian::greg_year,boost::gregorian:: greg_month,boost::gregorian::greg_day>&) (ffffffff7defb7c4, 7d9000000000000, 1000000000000, 5000000000000, 4, 7d9) + 1b8 000000010001b078 boost::date_time::date<boost::gregorian::date, boost::gregorian::gregorian_calendar,boost::date_time::date_duration< boost::date_time::duration_traits_adapted> >::date #Nvariant 1( boost::gregorian::greg_year,boost::gregorian::greg_month, boost::gregorian::greg_day) (ffffffff7defb9b0, 7d9000000000000, 1000000000000, 5000000000000, ffffffff7ebf6c38, ffffffff7defb9c0) + 98 000000010001a3a0 boost::gregorian::date::date #Nvariant 1(boost::gregorian:: greg_year,boost::gregorian::greg_month,boost::gregorian::greg_day) (ffffffff7defb9b0, 7d9000000000000, 1000000000000, 5000000000000, 400, ffffffff7defb9f0) + 90 0000000100017a20 boost::posix_time::ptime boost::date_time::microsec_clock< boost::posix_time::ptime>::create_time(boost::date_time:: microsec_clock<boost::posix_time::ptime>::TZ_FOR_CREATE) (0, 1000, 6, 0, 198704, 18) + 128 000000010001749c boost::posix_time::ptime boost::date_time::microsec_clock< boost::posix_time::ptime>::local_time() (ffffffff7defbba0, 18, ffffffff7defbbb8, ffffffff7defbd08, ffffffff7f51a160, ffffffff7f510d00) + c 0000000100015f40 void fun() (ffffffff7f915528, 1001311f0, 3, ffffffff7ee01358, 18, 3) + 18 0000000100020940 void boost::detail::thread_data<void(*)()>::run() (1001311f0, 0, 158, 10af4c, 0, 0) + 10 ffffffff7f8095b4 thread_proxy (1001311f0, 2, 10012df30, 1001311f0, 3, 5d) + 94 ffffffff7ead2e7c _lwp_start (0, 0, 0, 0, 0, 0) The only constant thing is the deletion of the locale: std::locale::~locale Compiler is: CC: Sun C++ 5.9 SunOS_sparc Patch 124863-07 2008/08/22 Any clues?
participants (1)
-
Roberto Gimenez