Query about CodeChef IDE

Why an infinite recursive function gives TLE (SIGSTP) in CodeChef IDE instead of giving segmentation fault?
How can 5 second be not enough to fill up the stack size?

#include <bits/stdc++.h>
using namespace std;

int fun(int n) {
	return fun(n - 1) + fun(n - 2);

int main() {
	cout << fun(100) << '\n';

The compiler might be doing tail call optimisation, in which case the stack space used will be small and constant.


Although I’ve just tried this on my machine and it segfaulted after 0.33 seconds, so maybe not :slight_smile: (gcc version 7.5.0 (Ubuntu 7.5.0-3ubuntu1~18.04), with -O3).


@admin @vijju123 is this any kind of bug? Just want to know what is actually happening inside.

Isn’t SIGSTP error associated to integer overflow?

If you do the same but use modular addition the error message is SIGSEGV