Opened 11 years ago

Closed 11 years ago

#6254 closed Bugs (invalid)

segmentation fault when different signals call each other

Reported by: Juan.Arrieta@… Owned by: Douglas Gregor
Milestone: To Be Determined Component: signals
Version: Boost 1.48.0 Severity: Problem
Keywords: segmentation fault Cc:

Description

I was playing around with boost/signal and I came up with the following code:

#include<stdlib.h>
#include<iostream>
#include<boost/signal.hpp>

boost::signal<void ()> SIG1;
boost::signal<void ()> SIG2;

void f1(){
std::cout<<"f1 called"<<std::endl;
SIG2();
}

void f2(){
std::cout<<"f2 called"<<std::endl;
SIG1();
}

int main(){
SIG1.connect(&f1);
SIG2.connect(&f2);
SIG1();
return EXIT_SUCCESS;
}

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:

f1 called
f2 called

after the 12,478th line, I get a segmentation fault.

I would have expected the call to continue endlessly (until hitting Ctrl-C), but this is not the case.

Is this the intended behavior?

I understand it is silly to call "recursively" as in the example, but this was intended as a test.

Thank you.

PS. Please review the "severity" accordingly - this may not even be a bug.

Thank you!

Change History (2)

comment:1 by Juan.Arrieta@…, 11 years ago

I should mention how I compiled the program, and how optimizations affect the point at which the segmentation fault happens.

g++ sigs.cpp -O0 -I$HOME/local/include -L$HOME/local/lib -lboost_signals

seg fault after printing 12,478 lines

g++ sigs.cpp -O1 -I$HOME/local/include -L$HOME/local/lib -lboost_signals

seg fault after printing 9,036 lines

g++ sigs.cpp -O2 -I$HOME/local/include -L$HOME/local/lib -lboost_signals

seg fault after printing 9,358 lines

g++ sigs.cpp -O3 -I$HOME/local/include -L$HOME/local/lib -lboost_signals

seg fault after printing 9,358 lines

comment:2 by Steven Watanabe, 11 years ago

Resolution: invalid
Status: newclosed

Inifinite recursion always overflows the stack. You don't even need to use signals to get this.

Note: See TracTickets for help on using tickets.