Small correction around MMGT_OPT=0(2) and MMGT_CLEAR=0

In TDF_Data.cxx myAllowModification is uninitialized parameter when we use malloc(or scalable_malloc) instead of calloc and after we have problem with detection of current state of transaction and Standard_ImmutableObject raise as result.

TDF_Data::TDF_Data() :
myTransaction (0),
myNbTouchedAtt (0),
myNotUndoMode (Standard_True),
myTime (0),
myAllowModification (Standard_True) //need this line
{

Denis Barbier's picture

Hello, Yuriy, this line is there since at least OCCT 6.3.0, which version are you using?

JuryS's picture

It's wrong. After night assemblages has mixed.

TDocStd_Document::TDocStd_Document(const TCollection_ExtendedString& aStorageFormat) :
myStorageFormat(aStorageFormat),
myData (new TDF_Data()),
myUndoLimit(0),
mySaveTime(0),
myIsNestedTransactionMode(0),
myOnlyTransactionModification(0) //Add this line
{

Here is some blocks like
...
if(myOnlyTransactionModification) {
myData->AllowModification(myUndoTransaction.IsOpen() && myUndoLimit
? Standard_True :Standard_False);

}
...

And if myOnlyTransactionModification is not initialized we catch Standard_ImmutableObject with TDF_Label and TDF_Attribute.

I think a reason that when we use calloc, I really don't understand how, but myOnlyTransactionModification is set with 0 ( ? TDocStd_Document is a pointer data ?), but when malloc, we catch exceptions.

Denis Barbier's picture

Weird, I do not understand why this is needed. Anyway, you should not set MMGT_CLEAR to 0 in order to avoid those errors.

JuryS's picture

I don't see any problem around use this option. Also I think that free method is more memory return with malloc, but it's only assumption, before I don't use calloc before and now I want to use malloc.

Denis Barbier's picture

Sorry, I do not understand your answer. Obviously there is a problem, otherwise you would not post here ;-) And I am quite confident that this problem disappears if you do not set MMGT_CLEAR=0.

If you want to check all class members which are not explicitly initialized, be warned that this is a gigantic task. G++ reports that there are 143159 members not explicitly initialized. This is fine, those members are implicitly initialized and should not contain garbage.

JuryS's picture

I'm working on this at this moment )) And I don't find easy way ))