Emanuel,
Based on the fact that you references those wiki pages, I assume you have already tried increasing stack and heap sizes and it didn't help?
Are you working with one of the Hercules example projects or used them as a baseline for your project? If so, check to make sure that the stack is not being overwritten by one of their default source files. The C I/O routines typically require a certain amount of stack and heap space as mentioned in the wiki pages you referenced. If the project has assembly routines that also set the stack pointer, they may be overwriting the stack.