The test program calls b.Aptr() multiple times, which creates multiple wrappers for class A. At the end of the simulation, each distinct wrapper will try to deallocate the same A instance, causing the double-free.
We need to add a option to create a wrapper which knows the C++ instance is shared and doesn't try to free it. Unfortunately that means adding bytes to the python wrapper structure, but that's life.
The test program calls b.Aptr() multiple times, which creates multiple wrappers for class A. At the end of the simulation, each distinct wrapper will try to deallocate the same A instance, causing the double-free.
We need to add a option to create a wrapper which knows the C++ instance is shared and doesn't try to free it. Unfortunately that means adding bytes to the python wrapper structure, but that's life.