Boost C++ Libraries: Ticket #10621: CRT Debug Heap reports leak when including exception_ptr.hpp https://svn.boost.org/trac10/ticket/10621 <p> I created a Win32 Console application with Visual Studio 2013 (vc12) and Boost 1.56.0. </p> <p> This is my only file: </p> <pre class="wiki">#define _CRTDBG_MAP_ALLOC #include &lt;stdlib.h&gt; #include &lt;crtdbg.h&gt; //#define CHECK_THREAD #ifdef CHECK_THREAD #include &lt;boost/thread.hpp&gt; #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 &lt;boost/exception/detail/exception_ptr.hpp&gt; #endif #include &lt;Windows.h&gt; 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; } </pre><p> When I run this I get the following output in <a class="missing wiki">MemoryLeaks</a>.txt: </p> <pre class="wiki">Detected memory leaks! Dumping objects -&gt; 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: &lt; 0 p &gt; 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: &lt;bad exception &gt; 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: &lt; @ &gt; 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: &lt;h X p &gt; 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: &lt; X &gt; B4 0C 0C 00 00 00 00 00 58 0D 0C 00 F0 0C 0C 00 Object dump complete. </pre><p> 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. </p> <p> I'm attaching the solution. It assumes that the Boost library resides in c:\workspace\boost_1_56_0. </p> <p> Thanks! </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/10621 Trac 1.4.3 Dina Goldshtein <dinazil@…> Mon, 06 Oct 2014 04:47:30 GMT attachment set https://svn.boost.org/trac10/ticket/10621 https://svn.boost.org/trac10/ticket/10621 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">boost_memory_leak_reporo.7z</span> </li> </ul> <p> The VS2013 solution </p> Ticket Dina Goldshtein <dinazil@…> Mon, 06 Oct 2014 06:32:21 GMT version changed https://svn.boost.org/trac10/ticket/10621#comment:1 https://svn.boost.org/trac10/ticket/10621#comment:1 <ul> <li><strong>version</strong> <span class="trac-field-old">Boost 1.54.0</span> → <span class="trac-field-new">Boost 1.56.0</span> </li> </ul> Ticket viboes Sun, 12 Oct 2014 13:53:13 GMT component changed; owner set https://svn.boost.org/trac10/ticket/10621#comment:2 https://svn.boost.org/trac10/ticket/10621#comment:2 <ul> <li><strong>owner</strong> set to <span class="trac-author">Emil Dotchevski</span> </li> <li><strong>component</strong> <span class="trac-field-old">None</span> → <span class="trac-field-new">exception</span> </li> </ul> Ticket nonubik Wed, 15 Jul 2015 14:31:11 GMT <link>https://svn.boost.org/trac10/ticket/10621#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/10621#comment:3</guid> <description> <p> I have encountered the same issue with boost 1.58.0. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Emil Dotchevski</dc:creator> <pubDate>Wed, 15 Jul 2015 19:06:11 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/10621#comment:4 https://svn.boost.org/trac10/ticket/10621#comment:4 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">invalid</span> </li> </ul> <p> Try this, let me know if the problem persists: <a class="ext-link" href="http://stackoverflow.com/questions/2323458/how-to-ignore-false-positive-memory-leaks-from-crtdumpmemoryleaks"><span class="icon">​</span>http://stackoverflow.com/questions/2323458/how-to-ignore-false-positive-memory-leaks-from-crtdumpmemoryleaks</a> </p> Ticket nonubik Mon, 27 Jul 2015 14:36:58 GMT <link>https://svn.boost.org/trac10/ticket/10621#comment:5 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/10621#comment:5</guid> <description> <p> That did not solve my specific issue, but I have found out my issue was similar (I can detail on it and <strong>its fix</strong> if needed) and indeed the memory leaks were reported too early, thus false. </p> </description> <category>Ticket</category> </item> </channel> </rss>