I wrote a function in C that, when called, immediately leads to a stack overflow.
Prototype: void dumpOutput( Settings *, char **, FILE * );
Calling line: dumpOutput( stSettings, sInput, fpOut );
At the time of its call, stSettings already a pointer to the Settings structure, sInput is a dynamically distributed 2D array, and fpOut is FILE * . It reaches the calling line without any errors, memory leaks, etc.
The actual function is quite long, and I think itβs not worth sharing it here, because the overflow occurs just like the code enters the function (the so-called part of the prolog, I think)
I tried calling the same function directly from main() with dummy variables to check if there are any problems with the arguments passed, but it still throws a condition.
The error occurs from chkstk.asm when the function is called. This asm file (in accordance with the comments presented in it) tries to check the stack to check / allocate memory for the called function. It just keeps jumping to the Find next lower page and probe until.
Local variables in dumpOutput also not memory characters, only 6 integers and 2 pointers.
The memory used by the code at the time of entering this function is 60.936K, which increases to 61.940K at the point when the stack overflows. Most of this memory is in sInput . Is this the cause of the error? I donβt think so, because only its pointer is passed. Secondly, I do not understand why dumpOutput trying to allocate 1004K of memory on the stack?
I do not understand here at all. Any help would be greatly appreciated.
Thanks in advance.