Access Violations
-
I have been getting access violations lately. To fix it all I have to do is delete all the object files in the Debug\ directory and recompile. After doing this everything works fine. My question is, Is this normal? Does this happen to other people too or do I have another problem that needs addressing? -Jack To an optimist the glass is half full. To a pessimist the glass is half empty. To a programmer the glass is twice as big as it needs to be.
Jack this definitely isn't normal. In fact I've never seen anything like this and I work in VC++ a zillion hours a day, every day. It sounds like an out and out problem which is only randomly rearing its head, and doing a clean build makes it *appear* to go away. Is the violation address consistent? If you are using a lesser version of Windows (not NT,2K,XP), then once something like this happens it can continue to happen until you reboot. Try and run your app under the Debugger at all times, then when you have a problem like this you can step right in and hopefully track it down. It could be a pointer which isn't pointing anywhere valid. If you have exception handling code in your app you should be picking up most if not all problems like this. Neville Franks, Author of ED for Windows. www.getsoft.com
-
I have been getting access violations lately. To fix it all I have to do is delete all the object files in the Debug\ directory and recompile. After doing this everything works fine. My question is, Is this normal? Does this happen to other people too or do I have another problem that needs addressing? -Jack To an optimist the glass is half full. To a pessimist the glass is half empty. To a programmer the glass is twice as big as it needs to be.
I agree with Neville. It looks like there may be something awry in your code. /ravi "There is always one more bug..." http://www.ravib.com ravib@ravib.com
-
Jack this definitely isn't normal. In fact I've never seen anything like this and I work in VC++ a zillion hours a day, every day. It sounds like an out and out problem which is only randomly rearing its head, and doing a clean build makes it *appear* to go away. Is the violation address consistent? If you are using a lesser version of Windows (not NT,2K,XP), then once something like this happens it can continue to happen until you reboot. Try and run your app under the Debugger at all times, then when you have a problem like this you can step right in and hopefully track it down. It could be a pointer which isn't pointing anywhere valid. If you have exception handling code in your app you should be picking up most if not all problems like this. Neville Franks, Author of ED for Windows. www.getsoft.com
Hmmm, so you don't agree with Tom? (see above) Because that was along the lines of what I was thinking. -Jack To an optimist the glass is half full. To a pessimist the glass is half empty. To a programmer the glass is twice as big as it needs to be.
-
I agree with Neville. It looks like there may be something awry in your code. /ravi "There is always one more bug..." http://www.ravib.com ravib@ravib.com
Hmmm, so you don't agree with Tom? (see above) Because that was along the lines of what I was thinking. -Jack To an optimist the glass is half full. To a pessimist the glass is half empty. To a programmer the glass is twice as big as it needs to be.
-
Hmmm, so you don't agree with Tom? (see above) Because that was along the lines of what I was thinking. -Jack To an optimist the glass is half full. To a pessimist the glass is half empty. To a programmer the glass is twice as big as it needs to be.
Jack Handy wrote: Hmmm, so you don't agree with Tom? (see above) Because that was along the lines of what I was thinking. Tom wrote: However, you need to find out why an incremental build is not building the binaries that need to be built for the app to run. I certainly agree with this, but in my experience VC doesn't get this wrong as long as you've got the project and it's dependencies set up correctly. If you do a Rebuild All and then it happens again and none of the dependant code has changed, then me thinks it must be a problem in your code. Neville Franks, Author of ED for Windows. www.getsoft.com
-
Jack Handy wrote: Hmmm, so you don't agree with Tom? (see above) Because that was along the lines of what I was thinking. Tom wrote: However, you need to find out why an incremental build is not building the binaries that need to be built for the app to run. I certainly agree with this, but in my experience VC doesn't get this wrong as long as you've got the project and it's dependencies set up correctly. If you do a Rebuild All and then it happens again and none of the dependant code has changed, then me thinks it must be a problem in your code. Neville Franks, Author of ED for Windows. www.getsoft.com
Neville Franks wrote: If you do a Rebuild All and then it happens again and none of the dependant code has changed, then me thinks it must be a problem in your code. It only happens if I do a normal build (F7) but is fine after I rebuild all. -Jack To an optimist the glass is half full. To a pessimist the glass is half empty. To a programmer the glass is twice as big as it needs to be.
-
Neville Franks wrote: If you do a Rebuild All and then it happens again and none of the dependant code has changed, then me thinks it must be a problem in your code. It only happens if I do a normal build (F7) but is fine after I rebuild all. -Jack To an optimist the glass is half full. To a pessimist the glass is half empty. To a programmer the glass is twice as big as it needs to be.
I don't know if this really getting anyone anywhere. Why don't you jump into the debugger and track down the exception. Neville Franks, Author of ED for Windows. www.getsoft.com
-
Hmmm, so you don't agree with Tom? (see above) Because that was along the lines of what I was thinking. -Jack To an optimist the glass is half full. To a pessimist the glass is half empty. To a programmer the glass is twice as big as it needs to be.
Tom is right in that you're likely run into weird behavior if VC++ doesn't get the dependencies right. And a "rebuild all" forces recompilation of all modules, thereby getting around a bad dependency check. But I suspect the real problem may lie in the code. I've often run into annoying situations (my fault) when I forget to delete an unused #define from resource.h. It causes no end of problems until I figure out that I'm calling
GetDlgItem()
with a bogus id. Although theASSERT
s I liberally sprinkle my code with will usually catch that. But annoying all the same. :) /ravi "There is always one more bug..." http://www.ravib.com ravib@ravib.com -
Tom is right in that you're likely run into weird behavior if VC++ doesn't get the dependencies right. And a "rebuild all" forces recompilation of all modules, thereby getting around a bad dependency check. But I suspect the real problem may lie in the code. I've often run into annoying situations (my fault) when I forget to delete an unused #define from resource.h. It causes no end of problems until I figure out that I'm calling
GetDlgItem()
with a bogus id. Although theASSERT
s I liberally sprinkle my code with will usually catch that. But annoying all the same. :) /ravi "There is always one more bug..." http://www.ravib.com ravib@ravib.comVery good point, Ravi. That's why while it doesn't hurt anything to do rebuilds, I let him know that it's probably a dependency issue so that he can start looking in that area. Cheers, Tom Archer Author, Inside C# A total abstainer is one who abstains from everything but abstention, and especially from inactivity in the affairs of others.
-
I have been getting access violations lately. To fix it all I have to do is delete all the object files in the Debug\ directory and recompile. After doing this everything works fine. My question is, Is this normal? Does this happen to other people too or do I have another problem that needs addressing? -Jack To an optimist the glass is half full. To a pessimist the glass is half empty. To a programmer the glass is twice as big as it needs to be.
It may be worth checking your clocks date/time and seeing if its set to earlier then some of the .cpp/.h files of your project. This can cause the project to only build partially after a change and link using old .obj files. Roger Allen Sonork 100.10016 If I had a quote, it would be a very good one.