Modify

Opened 8 years ago

Closed 6 years ago

#4031 closed Bugs (fixed)

vectorstream causes a memory leak at construction

Reported by: Mark Domschot <mark.domschot@…> Owned by: Ion Gaztañaga
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 (1)

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

Download all attachments as: .zip

Change History (6)

comment:1 Changed 8 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 8 years ago by Mark Domschot <mark.domschot@…>

Attachment: vectorstream.hpp added

my local (NOT fully tested) fix

comment:2 Changed 8 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 6 years ago by Jia-Jium Lee

Same problem with Visual Studio 2010.

comment:4 Changed 6 years ago by Ion Gaztañaga

Fixed in Boost 1.47

comment:5 Changed 6 years ago by Ion Gaztañaga

Resolution: fixed
Status: newclosed

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Ion Gaztañaga.
The resolution will be deleted.

Add Comment


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

 
Note: See TracTickets for help on using tickets.