Has anyone seen this error before?
I''m making a Win32API game with MSVC++ 6.
The game compiles error free, but crashes when executed. I''m reading data from a seperate text file, and I think that''s when the crash happens.
The error box I''m getting says...
The instruction at "0x004067dc" referenced memory at "0xcccccccc". The memory could not be "read".
This may not be enough info, so if needed, I have no problems posting my source...
Thanks in advance.
So many time !!
Check for bad pointing.
Why English rules?? C pas très malin tout ça!
Check for bad pointing.
Why English rules?? C pas très malin tout ça!
_______________
Jester, studient programmerThe Jester Home in French
Jester, studient programmerThe Jester Home in French
MSVC's debug memory routines fill uninitialized stack memory with the code "0xCC". This would insinuate that you are referring to a pointer that hasn't been initialized.
I should just make this my tagline for this board:
99% of memory access violations come from:
- dereferencing a NULL pointer
- dereferencing an uninitialized pointer
- dereferencing a deleted pointer
edit--changed "heap" to "stack". It's Monday, what can I say.
Edited by - Stoffel on May 14, 2001 4:26:25 PM
I should just make this my tagline for this board:
99% of memory access violations come from:
- dereferencing a NULL pointer
- dereferencing an uninitialized pointer
- dereferencing a deleted pointer
edit--changed "heap" to "stack". It's Monday, what can I say.
Edited by - Stoffel on May 14, 2001 4:26:25 PM
Ok I fixed that...but now I'm getting an error window saying...
gamename has caused an error in KERNEL32.DLL.
gamename will now close.
Edited by - Zoe on May 14, 2001 9:44:18 PM
gamename has caused an error in KERNEL32.DLL.
gamename will now close.
Edited by - Zoe on May 14, 2001 9:44:18 PM
I had the same error message, my problem was I had a struct with character arrays like so..
struct Level
{
WORD nLevel;
int nOffset;
char szId[4]
}
And when it came to filling the struct, I was adding an extra 0 at the end of the struct therefore overwriting malloced memory from some other variable...
Level NewLevel;
NewLevel.nLevel = 2;
NewLevel.nOffset = 340;
strcpy(NewLevel.szId,"LVL2"); // This will add an extra 0
It should be...
NewLevel.nLevel = 2;
NewLevel.nOffset = 340;
NewLevel.szId[0] = ''L'';
NewLevel.szId[1] = ''V'';
NewLevel.szId[2] = ''L'';
NewLevel.szId[3] = ''2'';
Maybe your problem is similar, hope I helped![](smile.gif)
struct Level
{
WORD nLevel;
int nOffset;
char szId[4]
}
And when it came to filling the struct, I was adding an extra 0 at the end of the struct therefore overwriting malloced memory from some other variable...
Level NewLevel;
NewLevel.nLevel = 2;
NewLevel.nOffset = 340;
strcpy(NewLevel.szId,"LVL2"); // This will add an extra 0
It should be...
NewLevel.nLevel = 2;
NewLevel.nOffset = 340;
NewLevel.szId[0] = ''L'';
NewLevel.szId[1] = ''V'';
NewLevel.szId[2] = ''L'';
NewLevel.szId[3] = ''2'';
Maybe your problem is similar, hope I helped
![](smile.gif)
Downloads: ZeroOne Realm
Actually...i''m not sure if that is the reason...I''ve got chars like...
char Name[30];
char WeaponName[30];
etc...
I''m not sure what the 30 will consist of... that is pulled in from a seperate file.
How would I stop overwriting the malloc mem if i don''t know what will be in the struct?
char Name[30];
char WeaponName[30];
etc...
I''m not sure what the 30 will consist of... that is pulled in from a seperate file.
How would I stop overwriting the malloc mem if i don''t know what will be in the struct?
I think it pads heap allocs with 0xCDCDCDCD
Magmai Kai Holmlor
- The disgruntled & disillusioned
Magmai Kai Holmlor
- The disgruntled & disillusioned
- The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara
In Devstudio you can adjust the compiler/project settings to create browse infromation (bsc and sbr files) so when the program crashes and gives the kernel error, click on debug and VC should pop up and show you which line the program crashed on.
Otherwise if you dont use DevStudio like me or it doesnt debug accurately, create a debug log system to help you determine exactly whats going on.
This is how I do it..
On application creation: create a new empty log file.
During the game loop: dump certain variable values to the log file, saving and re-opening the log file everytime you log something. Then when the app crashes, look at the log and see if any vars exceed their array limits etc.. If you have an idea where its crashing, for instance a newly created function, put log outputs within that function like so..
void MyBastardFunction()
{
DebugOut("Tag Bastard function is starting..");
// your code1
DebugOut("Tag Bastard function processing #1..");
// your code2
DebugOut("Tag Bastard function processing #2..");
// your code3
DebugOut("Tag Bastard function processing #3..");
// your code4
DebugOut("Tag Bastard function finished!");
}
So if the program crashed at code3, the last line in the log file would be
"DebugOut("Tag Bastard function processing #2..");
Its important to save every log line otherwise if the program crashes when the log file is still open, the file will be empty.
Check out my game demo at www.geocities.com/neoseeka and look at the log file to get some ideas.
Otherwise if you dont use DevStudio like me or it doesnt debug accurately, create a debug log system to help you determine exactly whats going on.
This is how I do it..
On application creation: create a new empty log file.
During the game loop: dump certain variable values to the log file, saving and re-opening the log file everytime you log something. Then when the app crashes, look at the log and see if any vars exceed their array limits etc.. If you have an idea where its crashing, for instance a newly created function, put log outputs within that function like so..
void MyBastardFunction()
{
DebugOut("Tag Bastard function is starting..");
// your code1
DebugOut("Tag Bastard function processing #1..");
// your code2
DebugOut("Tag Bastard function processing #2..");
// your code3
DebugOut("Tag Bastard function processing #3..");
// your code4
DebugOut("Tag Bastard function finished!");
}
So if the program crashed at code3, the last line in the log file would be
"DebugOut("Tag Bastard function processing #2..");
Its important to save every log line otherwise if the program crashes when the log file is still open, the file will be empty.
Check out my game demo at www.geocities.com/neoseeka and look at the log file to get some ideas.
Downloads: ZeroOne Realm
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement