Click here to Skip to main content
15,896,207 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Problems with realloc - heap corruption Pin
Waldermort7-Sep-06 7:20
Waldermort7-Sep-06 7:20 
GeneralRe: Problems with realloc - heap corruption Pin
nadiric7-Sep-06 7:24
nadiric7-Sep-06 7:24 
GeneralRe: Problems with realloc - heap corruption Pin
Waldermort7-Sep-06 7:28
Waldermort7-Sep-06 7:28 
AnswerRe: Problems with realloc - heap corruption Pin
Jun Du7-Sep-06 7:15
Jun Du7-Sep-06 7:15 
GeneralRe: Problems with realloc - heap corruption Pin
nadiric7-Sep-06 7:22
nadiric7-Sep-06 7:22 
GeneralRe: Problems with realloc - heap corruption Pin
Jun Du7-Sep-06 7:43
Jun Du7-Sep-06 7:43 
GeneralRe: Problems with realloc - heap corruption Pin
Zac Howland7-Sep-06 8:39
Zac Howland7-Sep-06 8:39 
AnswerRe: Problems with realloc - heap corruption Pin
Stephen Hewitt8-Sep-06 2:03
Stephen Hewitt8-Sep-06 2:03 
When you get heap corruption the actual cause need not be near where the problem manifests itself; often there is no obvious connection. He's what I'd try first:
 - If you haven't already got it, down and install WinDBG[^]. This is an absolute essential and every C/C++ developer should have the latest version installed at all times.
 - Select "Start->All Programs->Debugging Tools for Windows->Global Flags".
 - Select the "Image File" tab.
 - Type the name your application in the "Image: (TAB to refresh)" edit box then press TAB. The name should be the whole file name and extension but not the full path.
 - Tick "Enable page heap", "Enable heap tail checking", "Enable heap free checking", "Enable heap parameter checking", "Enable heap validation on call" & "Create user mode stack trace database".
 - Press "OK".

Now run your application. It will run many, many times slower then normal and consume huge amounts of memory but most heap errors will cause a break point to be generated as soon as the heap error occurs. If you use WinDBG as your debugger you can also get access to stack traces for each allocation. For example for a double free you can get a stack trace to the first free and a break point is generated for the second. It's good to have a machine with the fastest possible CPU and as much RAM as you can afford for debugging processes with the page heap.

After you've finished you'll want to turn the page heap off again for your process. Follow the steps above but uncheck all the tick boxes.

Steve

QuestionAnother impossible question Pin
Waldermort7-Sep-06 6:50
Waldermort7-Sep-06 6:50 
AnswerRe: Another impossible question Pin
JWood7-Sep-06 7:09
JWood7-Sep-06 7:09 
GeneralRe: Another impossible question Pin
Waldermort7-Sep-06 7:15
Waldermort7-Sep-06 7:15 
GeneralRe: Another impossible question [modified] Pin
Anonymuos7-Sep-06 11:38
Anonymuos7-Sep-06 11:38 
AnswerRe: Another impossible question Pin
Jun Du7-Sep-06 7:36
Jun Du7-Sep-06 7:36 
QuestionRe: Another impossible question Pin
Zac Howland7-Sep-06 8:50
Zac Howland7-Sep-06 8:50 
AnswerRe: Another impossible question Pin
Waldermort7-Sep-06 18:41
Waldermort7-Sep-06 18:41 
Questionpreprocessor directive Pin
Lord_Vader7-Sep-06 6:49
Lord_Vader7-Sep-06 6:49 
QuestionRe: preprocessor directive Pin
David Crow7-Sep-06 8:18
David Crow7-Sep-06 8:18 
AnswerRe: preprocessor directive Pin
Chris Losinger7-Sep-06 8:22
professionalChris Losinger7-Sep-06 8:22 
AnswerRe: preprocessor directive Pin
Hamid_RT8-Sep-06 7:28
Hamid_RT8-Sep-06 7:28 
QuestionMFC Toolbar handle Pin
ninolaroca7-Sep-06 6:05
ninolaroca7-Sep-06 6:05 
Questionwprintf failing me Pin
Waldermort7-Sep-06 5:33
Waldermort7-Sep-06 5:33 
AnswerRe: wprintf failing me Pin
Zac Howland7-Sep-06 5:50
Zac Howland7-Sep-06 5:50 
GeneralRe: wprintf failing me Pin
Waldermort7-Sep-06 5:56
Waldermort7-Sep-06 5:56 
GeneralRe: wprintf failing me Pin
Waldermort7-Sep-06 5:59
Waldermort7-Sep-06 5:59 
GeneralRe: wprintf failing me Pin
Zac Howland7-Sep-06 6:15
Zac Howland7-Sep-06 6:15 

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.