AutoCAD suddenly closes without any message or error while jigging

AutoCAD suddenly closes without any message or error while jigging

a.kouchakzadeh
Advocate Advocate
992 Views
13 Replies
Message 1 of 14

AutoCAD suddenly closes without any message or error while jigging

a.kouchakzadeh
Advocate
Advocate

Hello to every one. happy new year in advance.

I have an issue with jigging a couple of entities. my class inherits from DrawJig.

in this class I have some heavy calculation per mouse movement. some times, not always, AutoCAD suddenly closes without any prior notice, message or error.

it doesn't crash and show the error message. it just suddenly closes.

 

I have two methods called in my sampler, one gets PromptPointOptions and the other manipulates some objects after I have the new jigRes point:

 

public Point3d UpdatePosition(Point3d position)
{
    if(Dim1 is null)
    {
        _movingPoint = position;
        return _movingPoint;
    }
    else
    {
        var reflectedOnBaseLine = _wallsAndSoffit.BaseLine.line.GetClosestPointTo(position, true);
        Dim1.XLine2Point = reflectedOnBaseLine;
        Dim1.DimLinePoint = Dim1.XLine1Point.Add(_dimLinePointVector);
        _movingPoint = position;
        return reflectedOnBaseLine;
    }
}
public JigPromptPointOptions GetJigPromptPointOptions()
{
    var output = new JigPromptPointOptions();
    if (_guideLine1 is null)
    {
        output.UseBasePoint = false;
        var message = "\nInsert Sprinkler or[use Dimension / New wall or soffit]:";
        var keyword = "D N";
        output.SetMessageAndKeywords(message, keyword);
        return output;
    }
    else
    {
        output.Message = "\nInsert Sprinkler or enter distance:";
        output.UseBasePoint = true;
        output.BasePoint = _guideLine1.GetClosestPointTo(_movingPoint,true);
    }
            
    return output;
}

 

this is the sampler itself:

 

protected override SamplerStatus Sampler(JigPrompts prompts)
{
    if (_showMoreInfo)
    {
        var infoForm = new InformationForm("More Info",
                                _meshInfo.dict,
                                Design_Assistant.Properties.Resources.Base_Pendent_Rquired_Icon);
        infoForm.ShowDialog();
        _showMoreInfo = false;
    }
    var jigResult = prompts.AcquirePoint(_jigOptions.GetJigPromptPointOptions());

    switch (jigResult.Status)
    {
        case PromptStatus.OK:
            Sprinkler.Position = _jigOptions.UpdatePosition(jigResult.Value);
            GetMeshInfo();
            return SamplerStatus.OK;
        default:
            return SamplerStatus.Cancel;
    }
    throw new NotImplementedException("Should never reach this point while jig");
}

has any one faced this issue before?

do I have to manually dispose some thing ?

0 Likes
993 Views
13 Replies
Replies (13)
Message 2 of 14

a.kouchakzadeh
Advocate
Advocate

I found where the dump files are. but is there any one who can explain if this dump files can give me any lead of why or how autocad crashed?

does this crash have any thing to do with ntdll? what does that ntdll do anyway?

I opened the dump with windbg and this is what I got

 

The user dump currently examined is a minidump. Consequently, only a subset
of sos.dll functionality will be available. If needed, attaching to the live
process or debugging a full dump will allow access to sos.dll's full feature
set.
To create a full user dump use the command: .dump /ma <filename>
----------------------------------------------------------------------------
ntdll!RtlIsZeroMemory+0x119:
00007ffa`a4b6c399 eb00            jmp     ntdll!RtlIsZeroMemory+0x11b (00007ffa`a4b6c39b)
0:007> .ecxr
rax=0000ffff00001f80 rbx=000000f7363fedb0 rcx=0000000000000000
rdx=0000000000000000 rsi=000000f7363fe8c0 rdi=000000f7363fe8c0
rip=00007ffaa4b6c399 rsp=000000f7363fefd0 rbp=000002aeee0cdf70
 r8=0000000000000000  r9=0000000000000000 r10=0000000000001f30
r11=0000000000000000 r12=0000000000000000 r13=000000f7363ff6c0
r14=000002aec717c700 r15=0000000000000000
iopl=0         nv up ei pl nz na po nc
cs=0033  ss=002b  ds=002b  es=002b  fs=0053  gs=002b             efl=00000204
ntdll!RtlIsZeroMemory+0x119:
00007ffa`a4b6c399 eb00            jmp     ntdll!RtlIsZeroMemory+0x11b (00007ffa`a4b6c39b)
0:007> !analyze -v
*******************************************************************************
*                                                                             *
*                        Exception Analysis                                   *
*                                                                             *
*******************************************************************************
0 Likes
Message 3 of 14

a.kouchakzadeh
Advocate
Advocate

from a bit of search, I feel that the error has some thing to do with heap corruption and I also think my code is attempting to free a memory which has been already freed based on this message:

 

FAILURE_BUCKET_ID:  HEAP_CORRUPTION_ACTIONABLE_BlockNotBusy_DOUBLE_FREE_c0000374_ntdll.dll!RtlpFreeHeapInternal

 

however Im not manipulating memory by myself.

Im jigging a region which constantly changes, and Im hatching that region every time mouse moves in the sampler.

I have not manually disposed anything.

this is another part of the log from the dump file. its too heavy 98 MB so I cant upload the file here.

 

FILE_IN_CAB:  acad.exe.42968.dmp

NTGLOBALFLAG:  0

APPLICATION_VERIFIER_FLAGS:  0

CONTEXT:  (.ecxr)
rax=0000ffff00001f80 rbx=000000f7363fedb0 rcx=0000000000000000
rdx=0000000000000000 rsi=000000f7363fe8c0 rdi=000000f7363fe8c0
rip=00007ffaa4b6c399 rsp=000000f7363fefd0 rbp=000002aeee0cdf70
 r8=0000000000000000  r9=0000000000000000 r10=0000000000001f30
r11=0000000000000000 r12=0000000000000000 r13=000000f7363ff6c0
r14=000002aec717c700 r15=0000000000000000
iopl=0         nv up ei pl nz na po nc
cs=0033  ss=002b  ds=002b  es=002b  fs=0053  gs=002b             efl=00000204
ntdll!RtlReportFatalFailure+0x9:
00007ffa`a4b6c399 eb00            jmp     ntdll!RtlReportFatalFailure+0xb (00007ffa`a4b6c39b)
Resetting default scope

EXCEPTION_RECORD:  (.exr -1)
ExceptionAddress: 00007ffaa4b6c399 (ntdll!RtlReportFatalFailure+0x0000000000000009)
   ExceptionCode: c0000374
  ExceptionFlags: 00000081
NumberParameters: 1
   Parameter[0]: 00007ffaa4bd7780

PROCESS_NAME:  acad.exe

ERROR_CODE: (NTSTATUS) 0xc0000374 - A heap has been corrupted.

EXCEPTION_CODE_STR:  c0000374

EXCEPTION_PARAMETER1:  00007ffaa4bd7780

ADDITIONAL_DEBUG_TEXT:  Followup set based on attribute [Heap_Error_Type] from Frame:[0] on thread:[PSEUDO_THREAD] ; Followup set based on attribute [Is_ChosenCrashFollowupThread] from Frame:[0] on thread:[PSEUDO_THREAD]

FAULTING_THREAD:  ffffffff

STACK_TEXT:  
00000000`00000000 00000000`00000000 ntdll!RtlpFreeHeapInternal+0x0


STACK_COMMAND:  !heap ; ** Pseudo Context ** ManagedPseudo ** Value: ffffffff ** ; kb

SYMBOL_NAME:  ntdll!RtlpFreeHeapInternal+0

MODULE_NAME: ntdll

IMAGE_NAME:  ntdll.dll

FAILURE_BUCKET_ID:  HEAP_CORRUPTION_ACTIONABLE_BlockNotBusy_DOUBLE_FREE_c0000374_ntdll.dll!RtlpFreeHeapInternal

OS_VERSION:  10.0.22000.1

BUILDLAB_STR:  co_release

OSPLATFORM_TYPE:  x64

OSNAME:  Windows 10

IMAGE_VERSION:  10.0.22000.2538

FAILURE_ID_HASH:  {f9e860eb-b03f-7415-804c-7e671e26c730}

Followup:     MachineOwner
---------

 the problem is, I cant even detect when exactly this happens. some times it does happen, some times it doesn't.

any help is REALLY appreciated.

0 Likes
Message 4 of 14

daniel_cadext
Advisor
Advisor

I think RtlIsZeroMemory is a null pointer check

 

I would remove the throw in Sampler, maybe use a print, alert or assert

I would also put a try catch in Sampler, we cant see if GetMeshInfo throws

InformationForm should be inside a using statement since it’s disposable

 

Python for AutoCAD, Python wrappers for ARX https://github.com/CEXT-Dan/PyRx
0 Likes
Message 5 of 14

a.kouchakzadeh
Advocate
Advocate

No lock sir.
I used a try catch block in the sampler, but AutoCAD randomly crashes without going into the catch block.

I found this post from Fenton. it seemed to be my case. but forcing GC to run on main thread didn't help.

the problem is I can't even find out what triggers the issue. its seems very random. 
EDIT: I found this link created by Tony.

I think that might lead me some where

0 Likes
Message 6 of 14

kerry_w_brown
Advisor
Advisor

@a.kouchakzadeh 

That post at theSwamp is more than 12 years old.

If it had been made here ( in this forum) it would have been deleted with this months "clean-up"

Just be thankful.
As a sort-of side issue, the matters discussed in that thread have still not been documented to our satisfaction, despite our earnest requests over the years.

Stay well,

 


// Called Kerry or kdub in my other life.

Everything will work just as you expect it to, unless your expectations are incorrect. ~ kdub
Sometimes the question is more important than the answer. ~ kdub

NZST UTC+12 : class keyThumper<T> : Lazy<T>;      another  Swamper
Message 7 of 14

a.kouchakzadeh
Advocate
Advocate

so, what that means is, where ever I use a dbobject, I either have to add to database or keep it in a using statement ? if so, its really surprising this is not documented anywhere.

0 Likes
Message 8 of 14

_gile
Consultant
Consultant

@a.kouchakzadeh  a écrit :

so, what that means is, where ever I use a dbobject, I either have to add to database or keep it in a using statement ? if so, its really surprising this is not documented anywhere.


It is documented here, but it is still confusing. The "need to dispose" conditions should have been:

  • Always with a Transaction or DocumentLock object
  • Always with newly created database objects, objects derived from DBObject, that are not (or could not be) added to the database
  • Always with newly created database objects, objects derived from DBObject, that are being added to a transaction
  • Do not have to with newly created database objects, objects derived from DBObject, that are being added to a transaction with the AddNewlyCreatedDBObject method
  • Do not have to with existing database objects, objects derived from DBObject, opened with a transaction object and the GetObject method


Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

Message 9 of 14

daniel_cadext
Advisor
Advisor

Ouch, memory management in C++ is way easier 😬

Python for AutoCAD, Python wrappers for ARX https://github.com/CEXT-Dan/PyRx
0 Likes
Message 10 of 14

_gile
Consultant
Consultant

@daniel_cadext  a écrit :

Ouch, memory management in C++ is way easier 😬


It's quite simple.

Any opened or newly created object deriving from DBObject have to be disposed.

Transactions can help to make this more simple: an object opened with Transaction.GetObject or a newly created object added to the transaction with Transaction.AddNewlyCreatedDBObject will be automatically disposed when the transaction is disposed,

That said, we have to take care of explicitly disposing of newly created DBObjects that are not, or potentially may not be, added to the database.



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

Message 11 of 14

a.kouchakzadeh
Advocate
Advocate

"or a newly created object added to the transaction with Transaction.AddNewlyCreatedDBObject will be automatically disposed when the transaction is disposed"
does this apply for DBObjects which are not meant to be added to database? 

0 Likes
Message 12 of 14

_gile
Consultant
Consultant

@a.kouchakzadeh  a écrit :

"or a newly created object added to the transaction with Transaction.AddNewlyCreatedDBObject will be automatically disposed when the transaction is disposed"
does this apply for DBObjects which are not meant to be added to database? 


You can only add a DBObject to a transaction with AddNewlyCreatedDBObject if the DBObject is already database resident (see the docs).

For DBObjects which are not meant to be added to database, you have to explicitly dispose them (typically with a using statement).



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

0 Likes
Message 13 of 14

a.kouchakzadeh
Advocate
Advocate

thats exactly my question. how can I dispose some thing when I want to use it out of the scope it was created? ex. I create a region in the sampler, but I need it in the worlddraw method.

0 Likes
Message 14 of 14

ActivistInvestor
Mentor
Mentor

You can make it a member of your class, and dispose it when its no longer needed (or just before you assign a new value to the member variable), or you can use the Disposables class found here.

 

Usually, a variable that's declared in a given scope is not available in any outer/enclosing scopes, so if you are declaring the variable as a local in an outer/enclosing scope, just change that so that the variable is a member of your class.

 

Once your jigging operation is complete, you just dispose the member variable.

 


@a.kouchakzadeh wrote:

thats exactly my question. how can I dispose some thing when I want to use it out of the scope it was created? ex. I create a region in the sampler, but I need it in the worlddraw method.