Modify

Ticket #7156 (closed Bugs: fixed)

Opened 21 months ago

Last modified 8 months ago

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

bufferstream_leak.cpp Download (667 bytes) - added by Jonathan Jones <jonathan.jones@…> 21 months 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 Download (2.9 KB) - added by Jonathan Jones <jonathan.jones@…> 21 months ago.
Patch which seems to fix the leak.

Change History

Changed 21 months 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 21 months ago by Jonathan Jones <jonathan.jones@…>

Patch which seems to fix the leak.

comment:1 Changed 19 months ago by Sorin Fetche <sorin.fetche@…>

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

comment:2 Changed 8 months ago by anonymous

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

comment:3 Changed 8 months 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 8 months ago by igaztanaga

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

(In [85555]) Fixes #7156

View

Add a comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
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.