Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running down a 'stack overflow' bug

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?

like image 727
ChuckO Avatar asked Dec 03 '09 13:12

ChuckO


People also ask

How do I overcome stack overflow?

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.

What is stack smashing detected?

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.

What are the consequences of stack overflow?

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.

How do I fix stack overflow on Windows 10?

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.


2 Answers

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.

like image 141
frogb Avatar answered Oct 15 '22 16:10

frogb


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.

like image 44
mj2008 Avatar answered Oct 15 '22 14:10

mj2008