Active Member
9 Posts
0 Kudos
Registered: ‎09-02-2005
Post 1 of 7

pb with explode and AcDbVoidPtrArray

605 Views, 6 Replies
08-30-2011 02:04 AM

Dear All,


I have a pb with using explode and especialy with AcDbVoidPtrArray.

I upgrade  my code from VS2008 to VS2010 and autocad 2011 and 2012.


And now when I execute this code I have a crash when the application try to free memory for the entitySet (AcDbVoidPtrArray). It's very strange because the same code works fine in VS2008 and AutoCad2010.

I tried to free and close all pointers but I still have the same pb.



The aim of this code is to find the crossing point between two lines (one of the two line is in a block). The result is ok (I found the point) but I have a Acad error :in acarray.h :

template <class T, class R>
    if (mpArray != NULL)
        delete[] mpArray;

and then in free.c

oid __cdecl _free_base (void * pBlock)

        int retval = 0;

        if (pBlock == NULL)

        RTCCALLBACK(_RTC_Free_hook, (pBlock, 0));

        retval = HeapFree(_crtheap, 0, pBlock);
        if (retval == 0)
            errno = _get_errno_from_oserr(GetLastError());




[Code begin]

 AcDbEntity *pCurRefEnt;
 AcGePoint3dArray TestintersectionPoints;

 AcDbBlockReference *pBlockRef = AcDbBlockReference::cast (pEnt1);
 if (pBlockRef != NULL)
      AcDbVoidPtrArray entitySet;
      // explode the block, this will return a load of pre-transfromed entities for our perusal
      Acad::ErrorStatus es = pBlockRef->explode (entitySet);
      // if it worked ok
      if (es == Acad::eOk)
        // loop round getting the intersection points
        for (int i = 0; i < entitySet.length(); i++)
            pCurRefEnt = (AcDbEntity*)entitySet.at(i);
            if ((pCurRefEnt->isKindOf(AcDbLine::desc())) && (TestintersectionPoints.isEmpty()))
                Acad::ErrorStatus es1 = pCurRefEnt->intersectWith (pEnt2, AcDb::kOnBothOperands, TestintersectionPoints);

            delete pCurRefEnt;
 }==> acad.exe error!!!

[Code End]

ADN Support Specialist
685 Posts
80 Kudos
Registered: ‎06-02-2009
Post 2 of 7

Re: pb with explode and AcDbVoidPtrArray

08-30-2011 03:21 AM in reply to: sebastien.letutour

Hi Sebastien,


Try not to "Close" the "pCurRefEnt"... It is an exploded entity, so it isn't database resident, therefore closing it doesn't make much sense. You should simply delete it as you do at the nd of the loop.


I hope it helps.



Philippe Leefsma
Developer Consultant
Developer Technical Services



Philippe Leefsma
Developer Technical Services
Autodesk Developer Network

Distinguished Mentor
738 Posts
100 Kudos
Registered: ‎08-06-2002
Post 3 of 7

Re: pb with explode and AcDbVoidPtrArray

08-30-2011 07:40 AM in reply to: philippe.leefsma

Closing a non-DBR entity should be harmless. If this is the reason for the crash, then there is a bug in the object's implementation or related code.

Owen Wengerd
Active Member
9 Posts
0 Kudos
Registered: ‎09-02-2005
Post 4 of 7

Re: pb with explode and AcDbVoidPtrArray

08-30-2011 09:32 AM in reply to: owenwengerd

I do confirm that removing the fact to close the pointer doesn't change anything.

I still have a crash when Acad try to release the mpArray of the entityset. Even if I do a removeall of the entityset and if I put logicallength to 0.

Perhaps if I could release the pointer (?) because Acad test if this pointer is !=Null, but of course this pointer is read only.


Thanks for your help, if you have another suggest, you are welcome.



Active Member
10 Posts
4 Kudos
Registered: ‎03-13-2011
Post 5 of 7

Re: pb with explode and AcDbVoidPtrArray

08-31-2011 12:36 PM in reply to: sebastien.letutour
Hi, don't know if this causes the crash, but pEnt1 and pBlockRef are pointing to the same object (entity), and you call close on both pointers. Arnold
3 Posts
0 Kudos
Registered: ‎02-23-2012
Post 6 of 7

Re: pb with explode and AcDbVoidPtrArray

02-25-2013 12:13 PM in reply to: sebastien.letutour

Has anyone found a solution to this problem? I am experiencing very similar behaviour. I try to delete an entity from an AcDbVoidPtrArray of exploded entities and I get a crash. Entities that I am deleting are not database resident so according to documentation of explode() function, I should delete them myself.

1,464 Posts
277 Kudos
Registered: ‎04-09-2008
Post 7 of 7

Re: pb with explode and AcDbVoidPtrArray

02-25-2013 02:29 PM in reply to: Madon77

Maybe you post yours code?

Пожалуйста не забывайте про Утвердить в качестве решения! Утвердить в качестве решения и Give Kudos!Баллы
Please remember to Accept Solution! Accept as Solution and Give Kudos!Kudos

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post