Opened 12 years ago
Last modified 7 years ago
#5446 new Bugs
Exception thrown by tz_database::load_from_file() on linux 2.6.37, boost1.46.1,gcc4.5.2
Reported by: | Owned by: | az_sw_dude | |
---|---|---|---|
Milestone: | To Be Determined | Component: | date_time |
Version: | Boost 1.46.1 | Severity: | Problem |
Keywords: | Cc: |
Description
Hi, I tried to run the Flight Time Example in boost_1_46_1/doc/html/date_time/examples.html#date_time.examples.simple_time_zone, and an exception was thrown with error message: terminate called after throwing an instance of 'boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<boost::bad_lexical_cast> >'
what(): bad lexical cast: source type value could not be interpreted as target
When I debug with step into, I found it happened on line "Africa/Cairo" of the date_time_zonespec.csv, because this is the first timezone which needs to call dst_adjustment_offsets(), and there was a '\r' at the end of the line, then when str_from_delimited_time_duration() called boost::lexical_cast<unsigned short>(*beg) the '\r' made the exception being raised. On linux, std::getline(ifs, buff) in load_from_file() will leave the '\r' in buff, which caused the exception. On win32 this would not happen. So the line ends '\r' needs to be removed in load_from_file() or at the beginning of parse_string().
Attachments (1)
Change History (5)
comment:1 by , 11 years ago
comment:2 by , 11 years ago
Digging further, the cause of this problem is that the date_time_zonespec.csv file is shipped with DOS newlines.
If you run: dos2unix date_time_zonespec.csv
The file works properly.
I have attached a diff vs. trunk which allows DOS newlines.
comment:3 by , 11 years ago
I've checked the 1.47.0 release, and the svn repo. The svn:eol-style is 'native' (in both trunk and release), and the file in the release tarball has unix line endings. The same is true in the 1.46.1 .tar.bz2 file - so I'm not sure how you got DOS line endings.
comment:4 by , 7 years ago
For the Internet searchers. The load_from_file
method differs from load_from_stream
, as the former ignores one line from the input and the latter does not. I've learnt it the hard way.
Please raise the severity of this bug, I have encountered it as well.
The fallout from this is that tz_database is completely broken on linux, causing your application to crash, this is a very serious bug.
The explanation above is 100% accurate, boost::lexical_cast is being called with an extra '\r' on lines which need DST adjustments.
Here is a GDB snapshot from my application: