[Bug report] BRepMesh_FastDiscret::Add modifes the size of a map during iteration

I guess it went unnoticed before (http://www.opencascade.org/org/forum/thread_17541/) so I decided to repost.

BRepMesh_FastDiscret::Add crashes in some cases on the line:

structure->ForseRemoveLink(anIter.Key());

In my case it happens with the debug version of OCC only. MMGT_OPT was set to 0.

To tell the truth it seems to be a bug to me.

The algorithm iterates through a map (MeshDS_MapOfInteger& aLinks)
that changes its size (ForseRemoveLink changes the size of the map) during the iteration - that can be easily observed in the debugger.

Setting MMGT_OPT to 1 probably hides the issue as the memory is intact during the iteration.

Can anyone from the OCC team confirm this?

Pawel

Pawel's picture

Change the line 445 in BRepMesh_FastDiscret.cxx from

const MeshDS_MapOfInteger& aLinks = structure->LinkOfDomain(nbDomains);

to

MeshDS_MapOfInteger aLinks = structure->LinkOfDomain(nbDomains);

in order to avoid modification of the referenced map in a loop.

Works for OCC6.3.0 - in case anyone still needs it.

Pawel