I have an application written in Delphi W32 that is in beta.
On the test PC, it haphazardly kicks out a 'stack overflow' message after a few hours of use.
How can I trap the error and find the cause?
Can I increase the Stack size?
Steps to Prevent Stack Overflow One method to prevent stack overflow is to track the stack pointer with test and measurement methods. Use timer interrupts that periodically check the location of the stack pointer, record the largest value, and watch that it does not grow beyond that value.
Usually, the compiler generates the stack smashing detected error in response to its defense mechanism against buffer overflows. A buffer overflow occurs when the user input exceeds the buffer capacity.
The consequence of a stack overflow is that the program used, crashes as a result of incorrectly entered variables or because a return address contains no reachable target. In the case of an exploit, the attacker manages to overwrite the stack with their own code, thereby inserting this code in the return address.
A stack overflow occurs when there is not enough space in memory to run the hardware interrupt routines. To resolve these behaviors, you can modify the “STACKS=” line in the Config. sys file, eliminate terminate-and-stay-resident program (TSRs), and eliminate hardware conflicts.
You should REDUCE the stack size in linker options. Then run it under the debugger and hopefully the problem will show up without your having to wait two hours.
Get madExcept and it will tell you exactly what is happening at the time of the fault. You'll see the full stack, and particularly where it is running away.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With