Opened 12 years ago
Closed 12 years ago
#4798 closed Patches (fixed)
date_time: valgrind warnings via strings_from_facet.hpp
Reported by: | Owned by: | az_sw_dude | |
---|---|---|---|
Milestone: | To Be Determined | Component: | date_time |
Version: | Boost Development Trunk | Severity: | Cosmetic |
Keywords: | valgrind | Cc: |
Description
On Ubuntu, with GNU libc6 (2.7-10ubuntu7), and a program that uses boost::date_time::time_input_facet< boost::posix_time::ptime,char>
valgrind generates a warning:
==11026== Conditional jump or move depends on uninitialised value(s) ==11026== at 0x467C04B: __strftime_internal (strftime_l.c:574) ==11026== by 0x467DD4F: strftime_l (strftime_l.c:490) ==11026== by 0x456B420: std::__timepunct<char>::_M_put(char*, unsigned int, char const*, tm const*) const (in /usr/lib/libstdc++.so.6.0.13) ==11026== by 0x452BB4C: std::time_put<char, std::ostreambuf_iterator<char, std::char_traits<char> > >::do_put(std::ostreambuf_iterator<char, std::char_traits<char> >, std::ios_base&, char, tm const*, char, char) const (in /usr/lib/libstdc++.so.6.0.13) ==11026== by 0x452B0CF: std::time_put<char, std::ostreambuf_iterator<char, std::char_traits<char> > >::put(std::ostreambuf_iterator<char, std::char_traits<char> >, std::ios_base&, char, tm const*, char const*, char const*) const (in /usr/lib/libstdc++.so.6.0.13) ==11026== by 0x8430C83: std::vector<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > > boost::date_time::gather_month_strings<char>(std::locale const&, bool) (strings_from_facet.hpp:58) ==11026== by 0x84310D9: boost::date_time::format_date_parser<boost::gregorian::date, char>::format_date_parser(std::string const&, std::locale const&) (format_date_parser.hpp:188) ==11026== by 0x8431435: boost::date_time::date_input_facet<boost::gregorian::date, char, std::istreambuf_iterator<char, std::char_traits<char> > >::date_input_facet(std::string const&, unsigned int) (date_facet.hpp:462) ==11026== by 0x84315E0: boost::date_time::time_input_facet<boost::posix_time::ptime, char, std::istreambuf_iterator<char, std::char_traits<char> > >::time_input_facet(std::string const&, unsigned int) (time_facet.hpp:696)
The actual problem is in GNU libc6, strftime_l.c:574, which computes a 12 hour clock in __strftime_internal
regardless of the format string:
if (hour12 > 12) hour12 -= 12; else if (hour12 == 0) hour12 = 12;
The attached patch works around the warning by using an initialised struct tm in two places:
tm tm_value = { 0, 0, 0, 0, 0, 0, 0, 0, 0 };
We'd very much appreciate if the attached patch was accepted, even if it is only cosmetic.
Attachments (1)
Change History (5)
by , 12 years ago
Attachment: | valgrind.cosmetic.patch added |
---|
comment:1 by , 12 years ago
This patch has the same problem as was observed in #3477 - on some platforms, struct tm has different numbers of elements. Is
tm tm_value = {};
sufficient to fix this problem?
comment:4 by , 12 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Patch for uninitialized struct tm in strings_from_facet.hpp