thliebig / CSXCAD

A C++ library to describe geometrical objects and their physical or non-physical properties.
http://openEMS.de
GNU Lesser General Public License v3.0
34 stars 38 forks source link

Fix double-free of CSRectGrid #10

Closed forrestv closed 7 years ago

forrestv commented 7 years ago

ContinuousStructure.__cinit__ creates an instance of CSRectGrid that does not own its contents, then tries to prevent it from freeing its contents by nulling its thisptr in ContinuousStructure.__dealloc__.

However, when reference cycles exist, ContinuousStructure.__dealloc__ is not guaranteed to be called before CSRectGrid.__dealloc__, since the garbage collector may call ContinuousStructure's tp_clear function (which frees the CSRectGrid instance).

forrestv commented 7 years ago

Running python3 Simple_Patch_Antenna.py on current openEMS-Project HEAD results in the following error being displayed after all the plot windows are closed:

*** Error in `python3': double free or corruption (!prev): 0x0000000003202520 ***

This patch fixes it.