Boost C++ Libraries: Ticket #2349: execution monitor and terminate() https://svn.boost.org/trac10/ticket/2349 <p> In versions 1.35.0 and 1.36.0 the execution monitor does not detect if <code>terminate()</code> is called. In the current trunk (<a class="changeset" href="https://svn.boost.org/trac10/changeset/48903" title="Final wording">r48903</a>) it does, but still does not have any test cases for this condition (so I think it was fixed without knowing the problem). I think a test case would be useful to detect regressions. </p> <p> I noticed this problem with GCC 3.4.6 and GCC 4.1.2 on i486-linux-gnu. These compilers always call <code>terminate()</code> from <code>unexpected()</code> (ie. they call <code>terminate()</code> even if <code>std::bad_exception</code> is in the throw-list), and <code>terminate()</code> calls <code>abort()</code>. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/2349 Trac 1.4.3 Norbert Buchmuller <norbi@…> Sat, 20 Sep 2008 10:18:05 GMT attachment set https://svn.boost.org/trac10/ticket/2349 https://svn.boost.org/trac10/ticket/2349 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">boost.test-execution_monitor-terminate-testcases.diff</span> </li> </ul> <p> Patch to create test cases for std::bad_exception and terminate(). </p> Ticket Gennadiy Rozental Sun, 21 Sep 2008 08:12:22 GMT <link>https://svn.boost.org/trac10/ticket/2349#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/2349#comment:1</guid> <description> <ol><li>I don't remember changing anything in this area. Can you pinpoint specific revision? </li><li>I don't see a point of your tests. Both produce the result. Maybe if first one setup custom re-throwing unexpected handler, it would make sence. Though I still don't see what exactly we are testing here. </li></ol> </description> <category>Ticket</category> </item> <item> <author>Norbert Buchmuller <norbi@…></author> <pubDate>Sun, 21 Sep 2008 19:20:15 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/2349#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/2349#comment:2</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/2349#comment:1" title="Comment 1">rogeeff</a>: </p> <blockquote class="citation"> <ol><li>I don't remember changing anything in this area. Can you pinpoint specific revision? </li></ol></blockquote> <p> In fact the unexpected exception was just a red herring: the problem is that in 1.36.0 (as compiled on my machine) the SIGABRT signal is not detected by the Program Execution Monitor, as later I discovered that <code>test/prg_exec_fail3.cpp</code> fails, too: </p> <pre class="wiki">prg_exec_fail3: ../../libs/test/test/prg_exec_fail3.cpp:22: int cpp_main(int, char**): Assertion `div != 0' failed. no errors detected EXIT STATUS: 0 </pre><p> Regarding the change that fixed the bug, it was in <a class="changeset" href="https://svn.boost.org/trac10/changeset/45160" title="bug fix for missing default clause for si_code value switch">r45160</a>. Previously if the check for <code>m_sig_info-&gt;si_code &lt;= 0</code> (source:/trunk/boost/test/impl/execution_monitor.ipp@45159#L252) was true (as it is on my system when a SIGABRT is received), then the check for <code>SIGABRT</code> (source:/trunk/boost/test/impl/execution_monitor.ipp@45159#L278) was not run (as it was in the <em>else</em> branch). And, as the value of <code>m_sig_info-&gt;si_code</code> did not match any of the case labels in the <em>then</em> branch (source:/trunk/boost/test/impl/execution_monitor.ipp@45159#L253), it did not reported it as an error. </p> <p> The good news is that now it's fixed in trunk. </p> <blockquote class="citation"> <ol start="2"><li>I don't see a point of your tests. Both produce the result. Maybe if first one setup custom re-throwing unexpected handler, it would make sence. Though I still don't see what exactly we are testing here. </li></ol></blockquote> <p> Well, the first test (<code>test/prg_exec_fail5.cpp</code>) is useless in fact. I was misled by Stroustrup's book: it says (though a bit ambiguously) that if I add <code>std::bad_exception</code> to the throw-list then the unexpected exception will be mapped to <code>std::bad_exception</code> by the default <code>unexpected_handler</code> implementation (<em>The C++ Programming Language 3rd ed.</em>, 14.6.3). In fact he just forgot to emphasize that you must provide a new <code>unexpected_handler</code> that simply throws <code>std::bad_exception</code> for this to work. </p> <p> I looked it up in <em>ISO/IEC 14882:2003(E)</em>, and the default implementation of <code>unexpected_handler</code> must call <code>terminate()</code> indeed (18.6.2.2/3, independently of the presence of <code>std::bad_exception</code> in the throw-list), and the default implementation of <code>terminate_handler</code> must call <code>abort()</code> (18.6.3.1/3). So, sorry for the noise. :-) </p> <p> Now, both <code>unexpected()</code> (see above) and <code>assert()</code> (<em>ISO/IEC 9899:1990(E)</em> 7.2/2) terminates the program using <code>abort()</code> and there's already a test case for <code>assert()</code>, so there's no need for one more test case - unless we care about <code>NDEBUG</code> (<em>ISO/IEC 9899:1990(E)</em> 7.2/1). Do we? </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Gennadiy Rozental</dc:creator> <pubDate>Sun, 28 Sep 2008 11:56:36 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/2349#comment:3 https://svn.boost.org/trac10/ticket/2349#comment:3 <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">worksforme</span> </li> </ul> <p> No. I think we fine. </p> <p> As for std::bad_exception - you just need to register re-throwing handler (throw; as the only statement inside) to cause bad std::bad_exception, but this is not really what I should be testing for. </p> Ticket