[Boost-bugs] [Boost C++ Libraries] #11009: Possible memory leak in gregorian::from_simple_string

Subject: [Boost-bugs] [Boost C++ Libraries] #11009: Possible memory leak in gregorian::from_simple_string
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2015-02-09 23:49:35


#11009: Possible memory leak in gregorian::from_simple_string
------------------------------+------------------------
 Reporter: lszczygielek@… | Owner: az_sw_dude
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: date_time
  Version: Boost 1.57.0 | Severity: Problem
 Keywords: |
------------------------------+------------------------
 Hi,
 I've made some unit test to my code where I use date_time and Valgrind
 reports me possible memory leak. Here is code sample:
 {{{
 #include <boost/date_time/gregorian/gregorian.hpp>

 using namespace std;

 int main()
 {
     boost::gregorian::from_simple_string("2015-Jan-1");
     boost::gregorian::from_simple_string("2015-January-1");
     return 0;
 }
 }}}
 {{{
 valgrind --leak-check=full ./DateTimeMemoryLeak
 ==19696== Memcheck, a memory error detector
 ==19696== Copyright (C) 2002-2012, and GNU GPL'd, by Julian Seward et al.
 ==19696== Using Valgrind-3.8.1 and LibVEX; rerun with -h for copyright
 info
 ==19696== Command: ./DateTimeMemoryLeak
 ==19696==
 ==19696==
 ==19696== HEAP SUMMARY:
 ==19696== in use at exit: 1,858 bytes in 48 blocks
 ==19696== total heap usage: 110 allocs, 62 frees, 3,713 bytes allocated
 ==19696==
 ==19696== 308 bytes in 11 blocks are possibly lost in loss record 3 of 6
 ==19696== at 0x4A075BC: operator new(unsigned long)
 (vg_replace_malloc.c:298)
 ==19696== by 0x4CEE928: std::string::_Rep::_S_create(unsigned long,
 unsigned long, std::allocator<char> const&) (new_allocator.h:104)
 ==19696== by 0x4CEF4FA:
 std::string::_Rep::_M_clone(std::allocator<char> const&, unsigned long)
 (basic_string.tcc:629)
 ==19696== by 0x4CEFB7B: std::basic_string<char, std::char_traits<char>,
 std::allocator<char> >::basic_string(std::string const&)
 (basic_string.h:229)
 ==19696== by 0x408AA2:
 boost::gregorian::greg_month::get_month_map_ptr() (in
 /home/Lukasz/projekty/build-DateTimeMemoryLeak-
 Desktop_Qt_5_3_0_g_4_8_0-Debug/DateTimeMemoryLeak)
 ==19696== by 0x405BEF: unsigned short
 boost::date_time::month_str_to_ushort<boost::gregorian::greg_month>(std::string
 const&) (date_parsing.hpp:67)
 ==19696== by 0x405057: boost::gregorian::date
 boost::date_time::parse_date<boost::gregorian::date>(std::string const&,
 int) (date_parsing.hpp:143)
 ==19696== by 0x404793:
 boost::gregorian::from_simple_string(std::string) (parsers.hpp:35)
 ==19696== by 0x403D57: main (main.cpp:9)
 ==19696==
 ==19696== 374 bytes in 12 blocks are possibly lost in loss record 4 of 6
 ==19696== at 0x4A075BC: operator new(unsigned long)
 (vg_replace_malloc.c:298)
 ==19696== by 0x4CEE928: std::string::_Rep::_S_create(unsigned long,
 unsigned long, std::allocator<char> const&) (new_allocator.h:104)
 ==19696== by 0x4CEF4FA:
 std::string::_Rep::_M_clone(std::allocator<char> const&, unsigned long)
 (basic_string.tcc:629)
 ==19696== by 0x4CEFB7B: std::basic_string<char, std::char_traits<char>,
 std::allocator<char> >::basic_string(std::string const&)
 (basic_string.h:229)
 ==19696== by 0x4087E7:
 boost::gregorian::greg_month::get_month_map_ptr() (in
 /home/Lukasz/projekty/build-DateTimeMemoryLeak-
 Desktop_Qt_5_3_0_g_4_8_0-Debug/DateTimeMemoryLeak)
 ==19696== by 0x405BEF: unsigned short
 boost::date_time::month_str_to_ushort<boost::gregorian::greg_month>(std::string
 const&) (date_parsing.hpp:67)
 ==19696== by 0x405057: boost::gregorian::date
 boost::date_time::parse_date<boost::gregorian::date>(std::string const&,
 int) (date_parsing.hpp:143)
 ==19696== by 0x404793:
 boost::gregorian::from_simple_string(std::string) (parsers.hpp:35)
 ==19696== by 0x403D57: main (main.cpp:9)
 ==19696==
 ==19696== LEAK SUMMARY:
 ==19696== definitely lost: 0 bytes in 0 blocks
 ==19696== indirectly lost: 0 bytes in 0 blocks
 ==19696== possibly lost: 682 bytes in 23 blocks
 ==19696== still reachable: 1,176 bytes in 25 blocks
 ==19696== suppressed: 0 bytes in 0 blocks
 ==19696== Reachable blocks (those to which a pointer was found) are not
 shown.
 ==19696== To see them, rerun with: --leak-check=full --show-reachable=yes
 ==19696==
 ==19696== For counts of detected and suppressed errors, rerun with: -v
 ==19696== ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 6 from 6)
 }}}

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/11009>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:17 UTC