[Boost-bugs] [Boost C++ Libraries] #10621: CRT Debug Heap reports leak when including exception_ptr.hpp

Subject: [Boost-bugs] [Boost C++ Libraries] #10621: CRT Debug Heap reports leak when including exception_ptr.hpp
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2014-10-06 04:46:57


#10621: CRT Debug Heap reports leak when including exception_ptr.hpp
-----------------------+------------------------------
 Reporter: dinazil@… | Type: Bugs
   Status: new | Milestone: To Be Determined
Component: None | Version: Boost 1.54.0
 Severity: Problem | Keywords:
-----------------------+------------------------------
 I created a Win32 Console application with Visual Studio 2013 (vc12) and
 Boost 1.56.0.

 This is my only file:

 {{{
 #define _CRTDBG_MAP_ALLOC
 #include <stdlib.h>
 #include <crtdbg.h>

 //#define CHECK_THREAD

 #ifdef CHECK_THREAD

 #include <boost/thread.hpp>

 #else

 #ifdef _DEBUG
 #define DEBUG_CLIENTBLOCK new( _CLIENT_BLOCK, __FILE__, __LINE__)
 #else
 #define DEBUG_CLIENTBLOCK
 #endif // _DEBUG

 #ifdef _DEBUG
 #define new DEBUG_CLIENTBLOCK
 #endif

 #include <boost/exception/detail/exception_ptr.hpp>

 #endif

 #include <Windows.h>

 int main()
 {
         HANDLE hLogFile = CreateFile(L"MemoryLeaks.txt", GENERIC_WRITE,
 FILE_SHARE_WRITE,
                 NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);

         //Turn on debugging for memory leaks. This is automatically turned
 off when the build is Release.
         _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
         _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE);
         _CrtSetReportFile(_CRT_WARN, hLogFile);
         _CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_FILE);
         _CrtSetReportFile(_CRT_ERROR, hLogFile);
         _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_FILE);
         _CrtSetReportFile(_CRT_ASSERT, hLogFile);

         _CrtDumpMemoryLeaks();

         CloseHandle(hLogFile);
         return 0;
 }

 }}}


 When I run this I get the following output in MemoryLeaks.txt:

 {{{
 Detected memory leaks!
 Dumping objects ->
 c:\workspace\externals\boost_1_56_0\include\boost\smart_ptr\detail\shared_count.hpp(130)
 : {156} client block at 0x00709AC8, subtype 0, 16 bytes long.
  Data: < 0 p > 84 0F 0C 00 02 00 00 00 01 00 00 00 30 9A 70 00
 {155} normal block at 0x00709A88, 14 bytes long.
  Data: <bad exception > 62 61 64 20 65 78 63 65 70 74 69 6F 6E 00
 c:\workspace\externals\boost_1_56_0\include\boost\exception\detail\exception_ptr.hpp(130)
 : {154} client block at 0x00709A30, subtype 0, 44 bytes long.
  Data: < @ > 04 0E 0C 00 00 00 00 00 40 0E 0C 00 F0 0C 0C 00
 c:\workspace\externals\boost_1_56_0\include\boost\smart_ptr\detail\shared_count.hpp(130)
 : {151} client block at 0x007089B0, subtype 0, 16 bytes long.
  Data: <h X p > 68 0F 0C 00 02 00 00 00 01 00 00 00 58 89 70 00
 c:\workspace\externals\boost_1_56_0\include\boost\exception\detail\exception_ptr.hpp(130)
 : {150} client block at 0x00708958, subtype 0, 44 bytes long.
  Data: < X > B4 0C 0C 00 00 00 00 00 58 0D 0C 00 F0 0C 0C 00
 Object dump complete.
 }}}

 I first discovered this issue in a unit test which included
 boost/thread.hpp. However the unit tests don't include source and line
 information about the leak and thread.hpp doesn't compile with the
 DEBUG_CLIENTBLOCK macro.
 So I started eliminating all includes until I found out that the one
 causing the reported leak was exception_ptr and luckily enough this one
 did compile with the macro.

 I'm attaching the solution. It assumes that the Boost library resides in
 c:\workspace\boost_1_56_0.

 Thanks!

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/10621>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:17 UTC