I have been debugging a crash in a program which aborts with the error stack smashing detected
. I have narrowed down the crash to just one function which is:
static ssize_t a (const char *x, const char *y, size_t z) {
#ifdef SOME_FLAG
return b(x, y, z);
#endif
}
Since I am not defining SOME_FLAG anywhere, the function essentially does nothing and exits without a return statement.
I observed that if I just add a return 0
outside the #ifdef #endif
block, the program doesn't abort (due to stack smash). The abort is also not seen if I define the function as static void
instead of static ssize_t
Can the lack of a return statement cause stack-protector to trigger abort?