What are the symptoms in a C ++ program?

I just ran into a problem when a stack overflow in a C ++ streaming program on HPUX caused SEGV_MAPERR when a local object tried to call a very simple procedure. For a while I was puzzled, but, fortunately, I talked with someone who recognized this as a stack size problem, and we were able to fix the problem by increasing the stack size available for threads.

How to find out when stack overflow? Are the symptoms different on windows / linux / hpux?

+6
c ++ stack-overflow
source share
5 answers

How to find out when stack overflow?

If you know the size of the stack, where the stack begins, and the direction that it grows in memory, you can simply check the address of the stack pointer and see if it has passed the end of the stack. C ++ does not allow direct access to the stack pointer. You can easily write a small function in the assembly to perform this analysis and associate it with your program.

+2
source share

Assuming you are not on a platform that will stop your application and say β€œstack overflow”, I suspect you will see the same behavior as with any buffer overflow. The stack is another pre-allocated memory chunk for your program, and if you go beyond that ... good luck! Who knows what you will stomp on!

You can write according to the temperature readings from the CPU, it can be the email address that you type on Larry, maybe it means that the kernel is locked, which causes a funny deadlock condition! Who knows.

As for C ++, nothing is said about how the stack should be laid out in relation to other things in memory or that this thing should even be a stack!

+10
source share

Windows exception code 0xC00000FD .

It is usually easier to diagnose when you realize that your SEH is stopping.

0
source share

Perhaps a little off topic, but a similar problem in Ada (ends from the stack space in tasks) is a fairly common "unusual" error. Many compilers will stop the task (but not the main task) using the PROGRAM_ERROR exception.

In a sense, you should almost be able to sniff it out. He tends to start with something like: "I moved this large array to my task, and suddenly it stopped working."

0
source share

The output of the text on the screen became mixed with lines of code from the tested program. Previous bash commands and other text of unidentified origin were also present. Added to everything that the program text is damaged.

-one
source share

All Articles