Re: getProperties() error ?

From: <msevior_at_physics.unimelb.edu.au>
Date: Sun Jul 11 2004 - 02:23:17 CEST

>
> I'm totally stuck here...
>
> Martin or Tomas, could you help me out?
>
> Testcase:
>
> Start Abi, and set the number of columns to 2. Nothing more. Now, when I
> do (somewhere in the code, doesn't really matter):
>
> const PP_AttrProp* pAP = NULL;
> PP_RevisionAttr* pRevisions = NULL;
> bool bShowRevisions = false;
> UT_uint32 iId =
> static_cast<FV_View*>(pLayout->getDocLayout()->getAvView())->getRevisionLevel();
> bool bHiddenRevision = false;
>
> pLayout->getAttrProp(&pAP, pRevisions, bShowRevisions, iId,
> bHiddenRevision);
> DELETEP(pRevisions); // we don't need it

Never do this! The properties vector points to allocated memory that is
only deleted when the whole piecetable is delted. You get bitten by this
later.

> UT_return_if_fail(pAP);
>

Looks like pAP->getProperties() has a pointer to the same class as
pRevisions. When you delete one you invalidate the other. Get rid of the
DELETEP(pRevisions) line.

Why do you want it anyway?

Cheers

Martin

> const XML_Char ** attribs = pAP->getAttributes();
> const XML_Char ** props = pAP->getProperties();
> props = pAP->getProperties();
> props = pAP->getProperties(); // and again
> props = pAP->getProperties(); // and again
> props = pAP->getProperties(); // and again
> props = pAP->getProperties(); // and again
> props = pAP->getProperties(); // and again
> props = pAP->getProperties(); // and again
> props = pAP->getProperties(); // and again
>
> AbiWord always crashes. Valgrind complains the second time
> pAP->getProperties() is called, complaining about:
>
> pp_AttrProp::getProperties, line 452:
>
> pList[i] = pP->first();
>
> ==9603== Invalid read of size 4
> ==9603== at 0x83D1322: UT_Pair<char const*, PP_PropertyType
> const*>::first() const (ut_pair.h:44)
>
>
> Of course, this error is not only visible when "setting the number of
> columns to 2"; any property-setting option will work.
>
> Please, have you guys _any_ idea? This totally sucks, and I'm stuck with
> it for days now :-/
>
> Marc
>
>
Received on Sun Jul 11 02:11:35 2004

This archive was generated by hypermail 2.1.8 : Sun Jul 11 2004 - 02:11:35 CEST