I have derived an object from AcDbEntity. whenever the save command is issued in debug time, I get this exception :
"First-chance exception at 0x000007fefd6faa7d in acad.exe: Microsoft C++ exception: _com_error at memory location 0x2c2fea00.."
the callStack breaks at:
and dissassembly at this:
"000007FEFD6FAA7D 48 81 C4 C8 00 00 00 add rsp,0C8h "
The problem leads to this error when running autoCAD out of debugging environment:
"FATAL ERROR: Unhandled Access violation reading 0xffffffff exception at 77521e02h"
I have put break points at dwgOutFields() method of the custom class and the exception occurres after passing the control to the caller.
Thank you in advance.
It's not clear why you think the _com_error exception is related to the fatal error. Set your debugger to break at the access violation exception, then check the call stack to find the context within your code where the exception occurs.
Thanks Owen for your reply.
I set the debugger to break at access violation through: "debug->exceptions->win32 exceptions->c000005 access violation" but the debugger did not break. Actually the program is built in debug version. When I run it directly from AutoCAD the fatal error window appears. however, debugging with all the exceptionsturnes on leads only to the exception I mentioned before and the error window does not come up in autoCAD.
The output window shows the same exception too.
I forgot to say I am using objectARX 2012 with visual studio 2010. I have a class derived from AcDbEntity which itself is parent of 6 more classes that overwrite som of the methods.
If the bug is not evident in your debug build, then you have to debug your release build instead. Add debug information to your release build to make it easier.
Thank you all for your kind helps.
After removing all components and sequentially assembling them testing the program after adding each library, I finally found the error cause. In a routine -which was written long time ago when I was so beginner and the program was still too small- I had allocated memory dynamically to a string and returned the pointer to the new string. However, deallocating the memory by the caller was omitted in the program. calling the routine times and times in each dwgOutFields() call, accumulatedly used up the stack. A problem in which AutoCAD seems to suffer from extra sensitivity as some other posts comply too.
About the _com_error, it still persists to come up but the fatal error has been solved.
Thank you again
Such issues are hard to spot. Here are few suggestions :
1. Check to see if you have left any AutoCAD entities without closing them. Although you might be thinking that the error is during saving it could well be from an db operation performed earlier. Watch this recording :
You may find some clue if it is similar to what your app does. It is mainly to do with .Net API but some concepts are relevant to OARX.
2. As you said your class is the base class to several other classes. Narrow down on which entity is causing the save to fail. This might require some iterations to figure out.
3. Since you have mentioned that it does not crash when in debug mode, resort to logging messages. Use "acutPrintf" in places to track the flow before the crash happens.
Hope it helps.
Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register