Modify

Ticket #4031 (closed Bugs: fixed)

Opened 4 years ago

Last modified 3 years ago

vectorstream causes a memory leak at construction

Reported by: Mark Domschot <mark.domschot@…> Owned by: igaztanaga
Milestone: Boost 1.43.0 Component: interprocess
Version: Boost 1.42.0 Severity: Problem
Keywords: vectorstream, memory leak, init Cc:

Description

Hi,

This happens with Visual Studio 2008 (msvcp90.dll).

When a vectorstream is constructed, it specifically calls 'basic_ios_t::init()' on 'm_buf' after 'm_buf' was already initialized in its constructor.

The leak occurs in 'std::ios_base::_Init()', which has a pointer to a 4 byte locale.

It is worth noting that the memory leak detector that visual studio provides you will not report this leak. That tool does not report any memory with the block type of _CRT_BLOCK (Apparently no one at MS must make mistakes ;) ). If you want to see it with that tool, you can step into the allocation and manually change the block variable from 2 to 1.

Test program (its so short, the isn't a need to attach it): #include <boost\interprocess\streams\vectorstream.hpp> #include <boost\interprocess\containers\string.hpp>

namespace ip = boost::interprocess;

int main(int argc, char* argv[]) {

ip::basic_vectorstream<ip::string> stream1;

}

  • Mark

Attachments

vectorstream.hpp Download (22.1 KB) - added by Mark Domschot <mark.domschot@…> 4 years ago.
my local (NOT fully tested) fix

Change History

comment:1 Changed 4 years ago by Mark Domschot <mark.domschot@…>

Hi again,

My explanation of the issue is not entirely correct (sorry, I am rather unfamiliar with the source code of boost). It would be more accurate to say: When a vectorstream is constructed, it specifically calls 'basic_ios_t::init()' on 'm_buf' after it calls its base constructor constructor (which calls init()).

  • Mark

Changed 4 years ago by Mark Domschot <mark.domschot@…>

my local (NOT fully tested) fix

comment:2 Changed 4 years ago by Mark Domschot <mark.domschot@…>

The above attachment is the fix that I came up with for my company's program. It works for our purposes and may actually break boost elsewhere. The only testing I did with it was running our program.

  • Mark

comment:3 Changed 3 years ago by Jia-Jium Lee

Same problem with Visual Studio 2010.

comment:4 Changed 3 years ago by igaztanaga

Fixed in Boost 1.47

comment:5 Changed 3 years ago by igaztanaga

  • Status changed from new to closed
  • Resolution set to fixed
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.