No stack overflow protection in recursions through _sprintf
Imported from http://bugzilla.roxen.com/bugzilla/show_bug.cgi?id=2715
Reported by Martin Stjernholm mast@roxen.com
The following program will, with the normal backtrace formatter, cause an infinite recursion:
class X
{
string _sprintf()
{
werror (describe_backtrace (backtrace()));
return "X()";
}
}
int main()
{
werror ("%O\n", X());
}
The problem is that it isn't handled graciously. Seems like there is a "Stack overflow" exception, but when the backtrace for it is formatted the resulting recursion kills Pike. I get:
Error in handle_error in master object!
Error in handle_error in master object!
Attempting to dump raw error: (may fail)
/home/mast/Pike/devel/src/svalue.c:1078: Fatal error:
Type error: 17332
Attempting to dump backlog (may fail)...
Fatal in exit_on_error!
Abort (core dumped)
(With 7.2, this "merely" makes Pike unresponsive, for as long as I've cared to test.)
Besides from what seems to be the lack of a fatal_check_c_stack() somewhere, the best fix seems to be to avoid all calls to _sprintf functions if master()->handle_error is reentered.