|
Hi,
I'm trying to solve a problem I have, when I run my program in debug mode is works without a problem, but when I run it in without debug it gives me a Unhandled win32 exception. When I go into the debug from there in the output Unhandled exception at 0x7c911e58 in program.exe: 0xC0000005: Access violation reading location 0x00000000. Any idea of how I can track down what is causing this problem?
Thanks
Simon
|
|
|
|
|
simoncoul wrote: when I run my program in debug mode...
Are you using F5 or Ctrl+F5?
Have you read this article?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hi I'm using VS2k5 and using Ctrl+F5, I'm taking a look at those things in the website you gave me but I have no idea where to start looking, like I'm assuming that this is probably a allocationg error right?
Simon
|
|
|
|
|
A debug run tends to give your uninitialized pointers a garbage memory address, so if you check the value of these pointers, be careful.
|
|
|
|
|
Could you explain this a bit more? Like it doesn't make sense taht the error is occuring in the release mode of when I run the debug without debugging, I thought the whole point of bugging was to find errors so they won't be in the final product
thanks again
Simon
|
|
|
|
|
simoncoul wrote: ...the error is occuring in the release mode of when I run the debug without debugging...
This makes no sense. What exactly are you trying to say?
simoncoul wrote: ...I thought the whole point of bugging was to find errors so they won't be in the final product
You thought wrong. "Bugging" is the act of actually putting bugs in the code. Identifying and eradicating those bugs is called "debugging."
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
So...to run an app in the bugger...is that Alt-F5?
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
yeah that is fine for now, but when I need to make a final product it will not work.
|
|
|
|
|
Right - remove the debugging info when you ship it.
But for debugging, you need a release configuration (using non-debug libraries, any code
optimizing enabled, etc.) but WITH debug info so you can debug it easier
You probably want the /DEBUG linker switch too.
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
I've tried doing the following:
if (pObj != NULL)<br />
{<br />
}
...but pObj was never NULL in the first place, if I didn't initialize it to NULL, since the debugger will give it a bad memory address like 0xbaadf00d (bad food? ), which is why you should always initialize your pointers to 0 if you aren't about to use them right away.
|
|
|
|
|
simoncoul wrote: Hi I'm using VS2k5 and using Ctrl+F5...
Use F5 instead.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
simoncoul wrote: When I go into the debug from there in the output Unhandled exception at 0x7c911e58 in program.exe: 0xC0000005: Access violation reading location 0x00000000. Any idea of how I can track down what is causing this problem?
If you attach to a debugger there, then you should be able to back through the stack trace to the
offending line of code.
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
That's what I'm trying to do but it just points me to the free.c file, and I can't find out which part of the code I wrote is pointing to it.
|
|
|
|
|
simoncoul wrote: and I can't find out which part of the code I wrote is pointing to it.
There's none of your code in the call stack?
Have you included debug info (/Zi compiler option) in the release build configuration?
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
alrite I enable that and it's pointing me to this
n0_L=new double [N+2];
but I don't see what would be wrong about that, it declared like this
double *n0_L;
And at the end of the function that uses that value I have
delete [] n0_L;
and N is the value I need and I added 2 just to be sure I don't over write anything and it only holds no more then 40 numbers.
Thanks
|
|
|
|
|
Now the output from running it is throwing out all these
'kpSim.exe': Loaded 'C:\WINDOWS\system32\ntdll.dll', No symbols loaded.
'kpSim.exe': Loaded 'C:\WINDOWS\system32\kernel32.dll', No symbols loaded.
'kpSim.exe': Loaded 'C:\WINDOWS\system32\msimg32.dll', No symbols loaded.
'kpSim.exe': Loaded 'C:\WINDOWS\system32\gdi32.dll', No symbols loaded.
Any idea of what is happening here because in the call stack it ends it says
[Frames below may be incorrect and/or missing, no symbols loaded for ntdll.dll]
ntdll.dll!7c93426d()
Thanks again
|
|
|
|
|
No need to worry about those. That means you aren't going to be able to step into any of those
libraries symbolically. You should get those even in debug builds unless you're using Windows
OS debug symbols.
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Well do you see anything wrong with the way that I declared that array? Cause that is causing my problems?
thanks very much
|
|
|
|
|
Looks good unless N is negative
Does the exception occur on the line "n0_L=new double [N+2];"? If so, and N is a valid value,
then the heap is already corrupt at that point I would guess...
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
The exception occurs on the "n0_L=new double [N+2];" line? If so, is N valid?
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Thank you very much for the help I have a good idea of where too look now for the error, hopefully I will be able to figure it out tomorrow.
|
|
|
|
|
For info on the possible meaning of 0xBAADF00D see here[^].
I give the following advice about once a month (recently every few days); it often helps me track down the nastier heap errors:
Try enabling the page heap[^] for your process. Follow these steps:
1. Download and install WinDBG[^].
2. Select “Start”->“All Programs”->“Debugging Tools for Windows”->“Global Flags”.
3. Select the “Image File” tab.
4. In the “Image: (TAB to refresh)” edit control enter the name of your app then press TAB. Just the name with the extension; not the full path.
5. Tick the following:
- “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”
6. Press “Apply”.
7. Debug your application. Any debugger will do but with WinDBG you have access to the stack traces of allocations via the !heap –p –a command, for example. When a heap problem is detected a breakpoint will be generated.
8. When done un-tick all the options you ticked, press “Apply” then dismiss GFlags. This step is important as if it’s skipped all applications named as entered in step 4 will run with the page heap enabled.
Note that when using the page heap your application will run much slower than normal and consume way more memory. It’s good to have a beefy machine to do such tests; and such tests should be ran regularly on all applications you develop as part of regular testing activities. If I find a part of my application that’s too slow with the page heap enabled I optimize the memory allocation in that region.
Steve
|
|
|
|
|
Hi all,
My brain is fried after a long days work, and I'm struggling with a loop that will enable me to enter a if statement every third interval. Can anyone please help me ??
Many Thanks
Regards,
The only programmers that are better than C programmers are those who code in 1's and 0's.....
Programm3r
My Blog: ^_^
|
|
|
|
|
if ((number % 3) == 0)
...
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|