Modify

Opened 5 years ago

Closed 4 years ago

#7156 closed Bugs (fixed)

interprocess buffer streams leak memory on construction

Reported by: Jonathan Jones <jonathan.jones@…> Owned by: igaztanaga
Milestone: To Be Determined Component: interprocess
Version: Boost 1.44.0 Severity: Problem
Keywords: Cc:

Description

All of the boost::interprocess::*bufferstream classes leak memory on construction. Using our own, in-house leak checker, we discovered it's the following call for all classes:

basic_ios_t::init(&m_buf);

This leak only happens on Windows (seen with VS 2008 and VS 2010). We didn't see the problem with g++ 4.4.5 on Linux, nor with g++ 4.2.1 on Macintosh.

Attachments (2)

bufferstream_leak.cpp (667 bytes) - added by Jonathan Jones <jonathan.jones@…> 5 years ago.
Very crude program which demonstrates the leak. Bufferstream types are constructed in a loop along with an int on the heap. The address of the integer advances with each iteration.
bufferstream.hpp.patch (2.9 KB) - added by Jonathan Jones <jonathan.jones@…> 5 years ago.
Patch which seems to fix the leak.

Download all attachments as: .zip

Change History (6)

Changed 5 years ago by Jonathan Jones <jonathan.jones@…>

Very crude program which demonstrates the leak. Bufferstream types are constructed in a loop along with an int on the heap. The address of the integer advances with each iteration.

Changed 5 years ago by Jonathan Jones <jonathan.jones@…>

Patch which seems to fix the leak.

comment:1 Changed 5 years ago by Sorin Fetche <sorin.fetche@…>

The same leak appears in vectorstream family of classes, too. Tested with Boost 1.51.

comment:2 Changed 4 years ago by anonymous

We are also facing this issue. please fix this in the official boost release.

comment:3 Changed 4 years ago by igaztanaga

This is a known problem of the MSVC STL implementation. However, basic_ios::init call should be called only once, as the standard does not give any guarantee to allow calling it twice (MSVC STL leaks in this case). As pointed in http://accu.org/index.php/journals/264 we need to take of a potentially throwing custom streambuf so that basic_ios is not destroyed without being initialized. This is not a problem for bufferstream (has nothrow constructors) but it could affect vectorstream. In this second case a null streambuf will be passed to initialize basic_[i/o]stream, which will call basic_ios::init. After that, the streambuf will be replaced with vectorstream.

comment:4 Changed 4 years ago by igaztanaga

  • Resolution set to fixed
  • Status changed from new to closed

(In [85555]) Fixes #7156

Add Comment

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain igaztanaga.
The resolution will be deleted. Next status will be 'reopened'.
Author


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

 
Note: See TracTickets for help on using tickets.