Click here to Skip to main content
15,879,613 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionMemory Corruption [modified] Pin
devvvy19-Sep-07 15:59
devvvy19-Sep-07 15:59 
Hi... this is a bit philosophical ... I noticed a class attributed getting corrupted *on return* of a function... BUT when I step INTO the function, no memory corruption even when debugger pointing at *last* line (return statement) of the function. It wasn't until [the moment] debugger stepped *out* of the function when the class attributed is corrupted.

I'm looking for general idea/approach to such problem:

<br />
class CSomeClass { <br />
void MethodA(...) <br />
{ <br />
... <br />
MethodA1(...);<br />
MethodA2(...); <br />
MethodA3(...); << Boom!! m_attrib corrupted the moment MethodA3 returned debugger still pointing at this line *after*MethodA3 executed/return (I know from Watch Window) <br />
MethodA4(...); <br />
MethodA5(...); <br />
... <br />
} <br />
<br />
int MethodA3(...) <br />
{ <br />
... code ... <br />
return id; << m_attrib still okay but this is last statement of the method! <br />
} <br />
<br />
static SomeAttrib m_attrib; <br />
<br />
};



Note that the attribute "m_attrib" is static. And I don't think this section of the code is multi-threadedn (i.e. I don't see any AfxBeginThread or anything similar within the process boundary).

I guess the question is, what happenned between last statement (return id) within MethodA3, and immediately after debugger step out of MethodA3.


Thanks!


REF:
http://www.eventhelix.com/RealtimeM...are_crashes.htm[^]
http://www.eventhelix.com/RealtimeM...#Using%20assert[^]




-- modified at 23:20 Wednesday 19th September, 2007
AnswerRe: Memory Corruption Pin
Roger Broomfield19-Sep-07 18:07
Roger Broomfield19-Sep-07 18:07 
GeneralRe: Memory Corruption Pin
devvvy19-Sep-07 18:10
devvvy19-Sep-07 18:10 
QuestionHow to Monitor an application which required kill and regenerate if hang Pin
littlecheer19-Sep-07 15:18
littlecheer19-Sep-07 15:18 
AnswerRe: Monitor an application - kill and regenerate if hang Pin
Nathan Holt at EMOM19-Sep-07 15:42
Nathan Holt at EMOM19-Sep-07 15:42 
GeneralRe: Monitor an application - kill and regenerate if hang Pin
littlecheer19-Sep-07 15:55
littlecheer19-Sep-07 15:55 
GeneralRe: Monitor an application - kill and regenerate if hang Pin
devvvy19-Sep-07 18:49
devvvy19-Sep-07 18:49 
GeneralRe: Monitor an application - kill and regenerate if hang Pin
ThatsAlok19-Sep-07 20:35
ThatsAlok19-Sep-07 20:35 
GeneralRe: Monitor an application - kill and regenerate if hang Pin
devvvy19-Sep-07 20:43
devvvy19-Sep-07 20:43 
GeneralRe: Monitor an application - kill and regenerate if hang Pin
littlecheer19-Sep-07 22:26
littlecheer19-Sep-07 22:26 
QuestionMessage Removed Pin
19-Sep-07 12:01
Armond Sarkisian19-Sep-07 12:01 
AnswerRe: Checking for downloadable link Pin
Mark Salsbery19-Sep-07 12:13
Mark Salsbery19-Sep-07 12:13 
GeneralMessage Removed Pin
19-Sep-07 12:16
Armond Sarkisian19-Sep-07 12:16 
GeneralRe: Checking for downloadable link Pin
ThatsAlok19-Sep-07 20:36
ThatsAlok19-Sep-07 20:36 
QuestionGPS Open just right after Close=> Error Pin
shpid3r19-Sep-07 11:04
shpid3r19-Sep-07 11:04 
AnswerRe: GPS Open just right after Close=> Error Pin
Nathan Holt at EMOM19-Sep-07 11:34
Nathan Holt at EMOM19-Sep-07 11:34 
AnswerRe: GPS Open just right after Close=> Error Pin
shpid3r19-Sep-07 15:00
shpid3r19-Sep-07 15:00 
GeneralRe: GPS Open just right after Close=> Error Pin
Nathan Holt at EMOM19-Sep-07 15:12
Nathan Holt at EMOM19-Sep-07 15:12 
GeneralRe: GPS Open just right after Close=&gt; Error Pin
shpid3r19-Sep-07 15:29
shpid3r19-Sep-07 15:29 
GeneralRe: GPS Open just right after Close=&gt; Error Pin
Nathan Holt at EMOM19-Sep-07 15:37
Nathan Holt at EMOM19-Sep-07 15:37 
Questionhow to get a memory address into a CString Pin
USAFHokie8019-Sep-07 10:46
USAFHokie8019-Sep-07 10:46 
QuestionRe: how to get a memory address into a CString Pin
David Crow19-Sep-07 10:58
David Crow19-Sep-07 10:58 
AnswerRe: how to get a memory address into a CString Pin
USAFHokie8019-Sep-07 11:06
USAFHokie8019-Sep-07 11:06 
QuestionRe: how to get a memory address into a CString Pin
David Crow20-Sep-07 2:39
David Crow20-Sep-07 2:39 
AnswerRe: how to get a memory address into a CString Pin
Nathan Holt at EMOM19-Sep-07 11:40
Nathan Holt at EMOM19-Sep-07 11:40 

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.