Boost C++ Libraries: Ticket #12475: boost::fast_pool_allocator causes a deadlock on Windows 7 https://svn.boost.org/trac10/ticket/12475 <p> When invoked from a DLL, Boost.Wave's C++ lexer causes the application to hang on Windows 7 (and only on Windows 7) and to crash when interrupted with CTRL+C on other Windows versions. </p> <p> Here is a minimal test program in two parts, a DLL and an EXE, that reproduces the problem: </p> <h4 class="section" id="DLL">DLL</h4> <div class="wiki-code"><div class="code"><pre><span class="cp">#include</span> <span class="cpf">&lt;boost/wave.hpp&gt;</span><span class="cp"></span> <span class="cp">#include</span> <span class="cpf">&lt;boost/wave/cpplexer/cpp_lex_token.hpp&gt;</span><span class="cp"></span> <span class="cp">#include</span> <span class="cpf">&lt;boost/wave/cpplexer/cpp_lex_iterator.hpp&gt;</span><span class="cp"></span> <span class="kr">__declspec</span><span class="p">(</span><span class="n">dllexport</span><span class="p">)</span> <span class="kt">void</span> <span class="n">foo</span><span class="p">()</span> <span class="p">{</span> <span class="k">typedef</span> <span class="n">boost</span><span class="o">::</span><span class="n">wave</span><span class="o">::</span><span class="n">cpplexer</span><span class="o">::</span><span class="n">lex_token</span><span class="o">&lt;&gt;</span> <span class="n">token_type</span><span class="p">;</span> <span class="k">typedef</span> <span class="n">boost</span><span class="o">::</span><span class="n">wave</span><span class="o">::</span><span class="n">cpplexer</span><span class="o">::</span><span class="n">lex_iterator</span><span class="o">&lt;</span><span class="n">token_type</span><span class="o">&gt;</span> <span class="n">lex_iterator_type</span><span class="p">;</span> <span class="k">typedef</span> <span class="n">boost</span><span class="o">::</span><span class="n">wave</span><span class="o">::</span><span class="n">context</span><span class="o">&lt;</span><span class="n">std</span><span class="o">::</span><span class="n">string</span><span class="o">::</span><span class="n">iterator</span><span class="p">,</span> <span class="n">lex_iterator_type</span><span class="o">&gt;</span> <span class="n">context_type</span><span class="p">;</span> <span class="n">std</span><span class="o">::</span><span class="n">string</span> <span class="n">s</span> <span class="o">=</span> <span class="s">&quot;</span><span class="se">\n</span><span class="s">&quot;</span><span class="p">;</span> <span class="n">context_type</span> <span class="nf">ctx</span><span class="p">(</span><span class="n">s</span><span class="p">.</span><span class="n">begin</span><span class="p">(),</span> <span class="n">s</span><span class="p">.</span><span class="n">end</span><span class="p">());</span> <span class="k">auto</span> <span class="n">first</span> <span class="o">=</span> <span class="o">*</span><span class="n">ctx</span><span class="p">.</span><span class="n">begin</span><span class="p">();</span> <span class="p">}</span> </pre></div></div><h4 class="section" id="EXE">EXE</h4> <div class="wiki-code"><div class="code"><pre><span class="cp">#include</span> <span class="cpf">&lt;stdio.h&gt;</span><span class="cp"></span> <span class="kr">__declspec</span><span class="p">(</span><span class="n">dllimport</span><span class="p">)</span> <span class="kt">void</span> <span class="n">foo</span><span class="p">();</span> <span class="kt">int</span> <span class="nf">main</span><span class="p">()</span> <span class="p">{</span> <span class="n">foo</span><span class="p">();</span> <span class="n">fprintf</span><span class="p">(</span><span class="n">stderr</span><span class="p">,</span> <span class="s">&quot;Press CTRL+C to terminate...</span><span class="se">\n</span><span class="s">&quot;</span><span class="p">);</span> <span class="k">while</span> <span class="p">(</span><span class="nb">true</span><span class="p">)</span> <span class="p">{}</span> <span class="k">return</span> <span class="mi">0</span><span class="p">;</span> <span class="p">}</span> </pre></div></div><p> On Windows 7, this program will hang at startup, before entering <code>main()</code>. On other versions of Windows, the program will start and print the message, but pressing CTRL+C to terminate it will cause a crash. </p> <hr /> <p> A deeper investigation reveals that the problem is actually caused by Boost's <code>fast_pool_allocator</code>. Here is another minimal example that triggers the same bug as the program above: </p> <h4 class="section" id="DLL1">DLL</h4> <div class="wiki-code"><div class="code"><pre><span class="cp">#include</span> <span class="cpf">&lt;boost/pool/pool_alloc.hpp&gt;</span><span class="cp"></span> <span class="cp">#include</span> <span class="cpf">&lt;list&gt;</span><span class="cp"></span> <span class="k">typedef</span> <span class="n">std</span><span class="o">::</span><span class="n">list</span><span class="o">&lt;</span> <span class="kt">int</span><span class="p">,</span> <span class="n">boost</span><span class="o">::</span><span class="n">fast_pool_allocator</span><span class="o">&lt;</span><span class="kt">int</span><span class="o">&gt;</span> <span class="o">&gt;</span> <span class="n">container</span><span class="p">;</span> <span class="k">static</span> <span class="n">container</span> <span class="n">last</span><span class="p">;</span> <span class="kr">__declspec</span><span class="p">(</span><span class="n">dllexport</span><span class="p">)</span> <span class="kt">void</span> <span class="n">foo</span><span class="p">()</span> <span class="p">{}</span> </pre></div></div><h4 class="section" id="EXE1">EXE</h4> <p> <em>Same as in the previous program.</em> </p> <p> The symptoms of this program should be exactly the same as those of the previous one. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/12475 Trac 1.4.3 dictoon@… Wed, 21 Sep 2016 13:32:33 GMT attachment set https://svn.boost.org/trac10/ticket/12475 https://svn.boost.org/trac10/ticket/12475 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">DxDiag.txt</span> </li> </ul> <p> <a class="missing wiki">DxDiag</a> output on a Windows 7 where the bug occurs </p> Ticket