Opened 7 years ago

Last modified 7 years ago

#11958 new Bugs

boost::gregorian is not thread safe

Reported by: Mathieu Marquis Bolduc <mbolduc@…> Owned by: az_sw_dude
Milestone: To Be Determined Component: date_time
Version: Boost 1.54.0 Severity: Problem
Keywords: Cc:

Description

in greg_month.cpp,

The static method get_month_map_ptr performs a non-thread-safe initialization of the month_map structure on the first access.

If the first access is done concurrently, it is likely to crash with a segmentation fault as such:

Program received signal SIGSEGV, Segmentation fault. #0 0x00007fffef9127d9 in std::_Rb_tree<std::string, std::pair<std::string const, unsigned short>, std::_Select1st<std::pair<std::string const, unsigned short> >, std::less<std::string>, std::allocator<std::pair<std::string const, unsigned short> > >::_M_insert_unique(std::pair<std::string const, unsigned short> const&) ()

from /usr/lib/x86_64-linux-gnu/libboost_date_time.so.1.54.0

#1 0x00007fffef90fc90 in boost::gregorian::greg_month::get_month_map_ptr() () from /usr/lib/x86_64-linux-gnu/libboost_date_time.so.1.54.0 #2 0x00007ffff4d41e07 in boost::date_time::month_str_to_ushort<boost::gregorian::greg_month> (s=...) at /usr/include/boost/date_time/date_parsing.hpp:67 #3 0x00007ffff4d4341a in boost::date_time::parse_date<boost::gregorian::date> (s=..., order_spec=order_spec@entry=0) at /usr/include/boost/date_time/date_parsing.hpp:143 #4 0x00007ffff4d3a720 in from_string (s=...) at /usr/include/boost/date_time/gregorian/parsers.hpp:30

I suggest initializing the map in a safe, lockless manner.

Change History (2)

comment:1 by anonymous, 7 years ago

I encountered this issue in 1.57.0

in reply to:  1 comment:2 by royce@…, 7 years ago

Replying to anonymous:

I encountered this issue in 1.57.0

Adding email to be notified when fixed.

Note: See TracTickets for help on using tickets.