高级会员
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
|
【转帖】access violation at program exi
access violation at program exit
access violation at program exit
i'm using dwgdirect 1.14.01 with borland c++ builder 6.0 and have tried to get the included sample programs to run properly. they seem to function properly, but always cause and access violation at program end due to some smart pointer trying to free something that was already freed before (smartptr.h: 261). i've tried around with compiler settings but didn't manage to get rid of that error.
a minimal sample program is attached. the error occurs at "return 0" when all leftover objects are freed.
is borland c++ builder still supported or should i think of switching to visual studio? i just don't want to deal with the mfc.
attached files
i have experienced a similar problem using borland builder but it i believe the same issue exists in mfc. this was documented in the group discussion somewhere previously. try searching for the solution in the group discussions.
solution was to assign null to the drawing database pointer before exiting. ie. dwgpointer = null;
maybe someone else can detail further.
hope this helps.
not using any db
thanks for the prompt reply. i guess you were referring to the thread at right?
the problem here is that in the small project i've attached in my original post, i'm not creating any databases. the code of the main() function is
code:
odstaticrxobject<myservices> svcs;
odinitialize(&svcs);
oduninitialize();
additionally, oduninitialize() is not the function to cause the error. the access violation occurs after that, when all objects go out of scope. neither is it only a problem of my sample program, as odreadex and odcopyex cause the same error. i guess it must be something in my compilation settings.
more info
after doing some step-though debugging, i can pinpoint the error location to exhostappservices or some parent of it, that on construction creates an odhatchpatternmanager, and on destruction first frees that odhatchpatternmanager and then tries to free an instance of odpwdcache, which was never instantiated. that instance is pointed to by m_ppwdcache from dbhostappservices. i've tried detaching m_ppwdcache on construction of exhostappservices, which causes the program to fail when trying to free and instance of dbplotsettingsvalidator, pointed to by m_pvalidator of dbhostappservices. detaching that as well on construction makes the program fail after freeing m_pvalidator, but i stopped tracing at that point because i guess that the reason's somewhere else. any ideas what might go wrong there?
i've found the solution: "treat enum types as ints" has to be set for it to work.
quote:
originally posted by jdrugo
i've found the solution: "treat enum types as ints" has to be set for it to work.
you are absolutely right! it's mentioned in faq section.
misha kuzinets
|