Click here to Skip to main content
16,016,781 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionRe: Memory Allocation Pin
David Crow27-Sep-06 3:16
David Crow27-Sep-06 3:16 
AnswerRe: Memory Allocation Pin
User 21559726-Sep-06 20:26
User 21559726-Sep-06 20:26 
GeneralRe: Memory Allocation Pin
Polite Programmer26-Sep-06 20:31
Polite Programmer26-Sep-06 20:31 
QuestionRe: Memory Allocation Pin
David Crow27-Sep-06 3:22
David Crow27-Sep-06 3:22 
GeneralRe: Memory Allocation Pin
nutkase27-Sep-06 18:35
nutkase27-Sep-06 18:35 
AnswerRe: Memory Allocation Pin
kakan26-Sep-06 20:33
professionalkakan26-Sep-06 20:33 
GeneralRe: Memory Allocation Pin
Polite Programmer26-Sep-06 20:41
Polite Programmer26-Sep-06 20:41 
GeneralRe: Memory Allocation [modified] Pin
kakan26-Sep-06 20:51
professionalkakan26-Sep-06 20:51 
Hello.

IMO, The usual reason for stack corruption is this:

foo
{
char text[5];
strcpy(text, "Hello");
}


text is a stack variable of 5 chars, but the strcpy() copies 6 bytes to it.
The last character written (the '\0' byte) will be written outside the boundry of text.

******** THIS IS A SIMPLIFIED EXPLANATION ********

The return address (to the function that called foo()) is also saved on the stack.
When the function foo returns, the return address is picked up from the stack. But a part of the return address is now overwritten by the the '\0' byte, and is altered.
So the program retuns to the wrong address, causing the program to go bananas.

That's stack corruption.



-- modified at 3:06 Wednesday 27th September, 2006
But you can get a lot of different fishy behaviour from stack corruption. It depends how the compiler uses the stack. It doesn't have to result in wrong return address, other things can happen, such as another stack variable suddenly changes its value, e.t.c.

Alcohol. The cause of, and the solution to, all of life's problems - Homer Simpson

Questionhow to refresh automatically in a property page? Pin
yijia_2426-Sep-06 20:04
yijia_2426-Sep-06 20:04 
QuestionRe: how to refresh automatically in a property page? Pin
David Crow27-Sep-06 3:25
David Crow27-Sep-06 3:25 
AnswerRe: how to refresh automatically in a property page? Pin
yijia_2427-Sep-06 15:47
yijia_2427-Sep-06 15:47 
QuestionRe: how to refresh automatically in a property page? Pin
David Crow28-Sep-06 2:37
David Crow28-Sep-06 2:37 
QuestionRe: how to refresh automatically in a property page? Pin
yijia_242-Oct-06 18:03
yijia_242-Oct-06 18:03 
AnswerRe: how to refresh automatically in a property page? Pin
David Crow3-Oct-06 2:49
David Crow3-Oct-06 2:49 
QuestionResucing the flickerring rate Pin
Pratheep Kenny26-Sep-06 19:08
Pratheep Kenny26-Sep-06 19:08 
AnswerRe: Resucing the flickerring rate Pin
kakan26-Sep-06 19:30
professionalkakan26-Sep-06 19:30 
Questionvcl in borlands c++ to be used in vc++ Pin
zareee26-Sep-06 18:45
zareee26-Sep-06 18:45 
AnswerRe: vcl in borlands c++ to be used in vc++ Pin
Christian Graus26-Sep-06 18:54
protectorChristian Graus26-Sep-06 18:54 
GeneralRe: vcl in borlands c++ to be used in vc++ Pin
zareee26-Sep-06 19:11
zareee26-Sep-06 19:11 
GeneralRe: vcl in borlands c++ to be used in vc++ Pin
Christian Graus26-Sep-06 19:39
protectorChristian Graus26-Sep-06 19:39 
GeneralRe: vcl in borlands c++ to be used in vc++ Pin
zareee26-Sep-06 22:06
zareee26-Sep-06 22:06 
GeneralRe: vcl in borlands c++ to be used in vc++ Pin
David Crow27-Sep-06 3:28
David Crow27-Sep-06 3:28 
QuestionWin32 Window Boundry Pin
beeejay26-Sep-06 18:24
beeejay26-Sep-06 18:24 
AnswerRe: Win32 Window Boundry Pin
Waldermort26-Sep-06 22:25
Waldermort26-Sep-06 22:25 
GeneralRe: Win32 Window Boundry Pin
beeejay27-Sep-06 14:34
beeejay27-Sep-06 14:34 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.