Opened 5 years ago

Last modified 5 years ago

#8007 new Bugs

Possible memory leak in filesystem::copy()

Reported by: anonymous Owned by: Beman Dawes
Milestone: To Be Determined Component: filesystem
Version: Boost 1.52.0 Severity: Problem
Keywords: Cc:


I executed my program in valgrind to try to find out some memory leaks and I discovered one in boost::filesystem::copy().

My code is something like this:

namespace fs = boost::filesystem;
std::string from("file1"), to("file2"); // where from and to are regular files
try {
  fs::copy(from,to); // leak here 
} catch(fs::filesystem_error) {
  // treat exception

The backtrace I could get with valgrind is:

==4966== 32,768 bytes in 1 blocks are definitely lost in loss record 1,463 of 1,516 
==4966==    at 0x4C2BBF7: operator new[](unsigned long) (vg_replace_malloc.c:363)
==4966==    by 0x10A09C1: boost::filesystem::detail::copy(boost::filesystem::path const&, boost::filesystem::path const&, boost::system::error_code*) (in /old
==4966==    by 0x109A501: boost::filesystem::copy(boost::filesystem::path const&, boost::filesystem::path const&) (operations.hpp:367)
==4966==    by 0x109A26B: System::copyFile(std::string const&, std::string const&) (system.cpp:78)

Where System::copyFile(string,string) is a class from my system, which basically calls the above code.

I'm using Ubuntu 12.04 amd64 with boost 1.52 compiled by myself. I'm also using jemalloc as memory allocator.

Attachments (0)

Change History (1)

comment:1 Changed 5 years ago by anonymous

Summary: Possibly memory leak in filesystem::copy()Possible memory leak in filesystem::copy()

Modify Ticket

Change Properties
Set your email in Preferences
as new The owner will remain Beman Dawes.

Add Comment

E-mail address and name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.