Boost C++ Libraries: Ticket #6254: segmentation fault when different signals call each other https://svn.boost.org/trac10/ticket/6254 <p> I was playing around with boost/signal and I came up with the following code: </p> <pre class="wiki">#include&lt;stdlib.h&gt; #include&lt;iostream&gt; #include&lt;boost/signal.hpp&gt; boost::signal&lt;void ()&gt; SIG1; boost::signal&lt;void ()&gt; SIG2; void f1(){ std::cout&lt;&lt;"f1 called"&lt;&lt;std::endl; SIG2(); } void f2(){ std::cout&lt;&lt;"f2 called"&lt;&lt;std::endl; SIG1(); } int main(){ SIG1.connect(&amp;f1); SIG2.connect(&amp;f2); SIG1(); return EXIT_SUCCESS; } </pre><p> When I compile and run (g++ 4.0.1 Apple Inc. build 5490 / boost v. 1.48), the I get 12,478 lines of the form: </p> <pre class="wiki">f1 called f2 called </pre><p> after the 12,478th line, I get a segmentation fault. </p> <p> I would have expected the call to continue endlessly (until hitting Ctrl-C), but this is not the case. </p> <p> Is this the intended behavior? </p> <p> I understand it is silly to call "recursively" as in the example, but this was intended as a test. </p> <p> Thank you. </p> <p> PS. Please review the "severity" accordingly - this may not even be a bug. </p> <p> Thank you! </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/6254 Trac 1.4.3 Juan.Arrieta@… Sun, 11 Dec 2011 22:41:02 GMT <link>https://svn.boost.org/trac10/ticket/6254#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6254#comment:1</guid> <description> <p> I should mention how I compiled the program, and how optimizations affect the point at which the segmentation fault happens. </p> <pre class="wiki">g++ sigs.cpp -O0 -I$HOME/local/include -L$HOME/local/lib -lboost_signals </pre><p> seg fault after printing 12,478 lines </p> <pre class="wiki">g++ sigs.cpp -O1 -I$HOME/local/include -L$HOME/local/lib -lboost_signals </pre><p> seg fault after printing 9,036 lines </p> <pre class="wiki">g++ sigs.cpp -O2 -I$HOME/local/include -L$HOME/local/lib -lboost_signals </pre><p> seg fault after printing 9,358 lines </p> <pre class="wiki">g++ sigs.cpp -O3 -I$HOME/local/include -L$HOME/local/lib -lboost_signals </pre><p> seg fault after printing 9,358 lines </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Steven Watanabe</dc:creator> <pubDate>Sun, 11 Dec 2011 23:08:47 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/6254#comment:2 https://svn.boost.org/trac10/ticket/6254#comment:2 <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> Inifinite recursion always overflows the stack. You don't even need to use signals to get this. </p> Ticket