Debugging Problem

Debugging Problem

Kyudos
Advisor Advisor
1,447 Views
5 Replies
Message 1 of 6

Debugging Problem

Kyudos
Advisor
Advisor

In my 2018 ARX I'm having problems finding a bug. When I delete one of my custom objects it consistently causes an access violation crash (apparently) in mscordacwks.dll. If i let it go, ACAD throws up a typically unhelpful message:

 

internal error !dbobji.cpp@8440: eNotOpenForWrite

 

If I skip the object deletion in the debugger - no crash. But the deletion itself doesn't (immediately) cause the crash. Any ideas on how I can find what the problem really is?

 

 

0 Likes
Accepted solutions (1)
1,448 Views
5 Replies
Replies (5)
Message 2 of 6

moogalm
Autodesk Support
Autodesk Support

@Kyudos ,

 

We need more information than what you mentioned, like sample code to understand the work flow.

 

'error message simple says you are accessing a object which isn't opened for write'

 

Trying AUDIT on the drawing with your custom object, see audit complains. 

0 Likes
Message 3 of 6

tbrammer
Advisor
Advisor

You may not delete an AcDbObject if it is database resident - even if you have erased it. If you delete a DB resident AcDbObject, your app won't crash within the C++ destructor, but AutoCAD will crash at some point later like you reported.

 

Is the object in question DB resident? If it is: Don't delete  it. If you want to release it's memory use AcDbDatabase::reclaimMemoryFromErasedObjects().

 

Otherwise: The error message "eNotOpenForWrite" shows that AutoCAD tries to write to a DB resident object - because non DB-resident objects are treated as write enabled. Does your custom object own other AcDbObjects that might be erased/deleted along with their owner? Or could it be a reactor issue?

 

Besides this I agree with @moogalm: More information and/or source code would help to track down the problem.


Thomas Brammer ● Software Developer ● imos AG ● LinkedIn
If an answer solves your problem please [ACCEPT SOLUTION]. Otherwise explain why not.

0 Likes
Message 4 of 6

Kyudos
Advisor
Advisor
Accepted solution

Thanks for the replies - I actually found the issue. It was caused by a fix I added for another platform ... and probably the non-standard, recursive method we use to erase objects :).

 

Essentially, returning eOK from both entries to subErase causes the issue. If I return eVetoed from the outer one, everything is fine.

0 Likes
Message 5 of 6

tbrammer
Advisor
Advisor

@Kyudos wrote:

Thanks for the replies - I actually found the issue. It was caused by a fix I added for another platform ... and probably the non-standard, recursive method we use to erase objects :).

 

Essentially, returning eOK from both entries to subErase causes the issue. If I return eVetoed from the outer one, everything is fine.


This sounds a bit strange to me. Returning a value other than eOk from subErase() should terminate the erase operation. Maybe this fix works due to your "non-standard recursive way" to erase objects. Why do you use recursion to erase objects? I would recomment to use recursion only to collect AcDbObjectIds. But then use a simple loop to open, erase and close the objects.

 

However - if you think your issue is solved, please click [Accept Solution] in your previous posting.


Thomas Brammer ● Software Developer ● imos AG ● LinkedIn
If an answer solves your problem please [ACCEPT SOLUTION]. Otherwise explain why not.

0 Likes
Message 6 of 6

Kyudos
Advisor
Advisor

The recursion was mostly for the expediency of using old code. We moved to AutoCAD from a different CAD platform and tried to use as much old code as possible, both for speed and reliability. The basic assumption is that the user is not allowed to delete our objects unless we say it is OK. We already had a tried and tested central 'am I allowed to delete this object' function. So on first entering subErase a flag indicates we don't delete and we call our check function, the check function subsequently sets the 'can delete' flag (or not) and calls erase again. If deletion is allowed, the second (inner) call returns eOK, the first (outer) one returns eVetoed. In some cases I was returning eOK from the outer call, which caused the problem.

0 Likes