Pickling Segmentation Fault/ Inconsistent behaviour

Hi everyone,

to restart a simulation I’m using data pickled in a previous run. To ensure that the meshes are the same, I take a copy of the mesh from a pickled GridFunction. Using this copy a create new FESpace and a new GridFunction into which I copy the data from the pickled GridFunction.

When I try to pickle this new grid function I sometimes get a segmentation fault. Attached is a MWE (run once with ‘restart=False’ and then with ‘True’).

Can anyone help me to avoid these segmentation faults?

Best wishes,
Henry

PS: This inconsistency is both on mac an linux, self build on commits gee9a66d1 and gac4d9b1f (NGSolve 2006).

Attachment: test_pickle_seg_fault.py

Update:

The issue seems to stem from the fact that I delete the unpickled GridFunction. I thought this would not be problematic, since I explicitly copy the meshmesh = Mesh(_gfu_pic.space.mesh.ngmesh.Copy())

Is there a better way to copy the mesh?

Best wishes,
Henry

Hi Henry,

Thanks for the report and the update. We are on it and already found the issue (it’s about pointers in the netgen::Mesh, which are not correctly set in the copy). The fix will be on master soon.

Best,
Matthias

Hi Matthias,

thank for the quick reply and fix :slight_smile: !

Best wishes,
Henry

Fix is online, a new release is in the pipeline.
Best,
Matthias