# Seg fault curving 2D mesh in Netgen

2 months 2 weeks ago #1379 by ddrake
Hi,

When I call the method:

mesh.curve(max(p,2)) with p = 2, I'm getting a segfault in Netgen:

netgen/libsrc/geom2d/genmesh2d.cpp:403
403 if (bbox.Diam() < mp.maxh)

0x00007fffdca3f8ac in netgen::MeshFromSpline2D (geometry=...,
at /home/dow/ngsuite/ngsolve-src/external_dependencies/netgen/libsrc/geom2d/genmesh2d.cpp:403

Our code is rather complex, but was working before Christmas and hasn't changed since. I'm not seeing this issue with versions of NGSolve/Netgen built more than a week or two ago. If you have trouble reproducing it, I can try to provide more details.

Thanks,
Dow

2 months 2 weeks ago #1381 by ddrake
The following change seems to have fixed the problem:

swap the base classes in netgen/libsrc/geom2d/geometry2d.hpp as follows

class SplineGeometry2d : public NetgenGeometry, public SplineGeometry<2>

Best,
Dow

2 months 2 weeks ago #1384
Hi,
I cannot reproduce the Segfault, I do not see a problem in changing the base classes but don't really understand why this fixes the problem and I would assume that it is more or less a coincidence and an explanation would be nice... If you have time to create a reproducible case I would be interested.
Best
Christopher

2 months 1 week ago #1390 by ddrake
Hi Christopher,

Swapping the order of the base classes was a suggestion from Joachim, passed along by Jay -- not something I would have thought of myself. I'll try to post a reproducible case soon.

Best,
Dow

2 months 1 week ago #1391
Ah, I think I know, try in the python_geom2d.cpp in the export of the SplineGeometry adding py::multiple_inheritance():
py::class_<SplineGeometry2d, NetgenGeometry, shared_ptr<SplineGeometry2d>>
(m, "SplineGeometry",
"a 2d boundary representation geometry model by lines and splines",
py::multiple_inheritance())
If this fixes your problem then we already know the problem and you don't need to create a test case. I thought we already fixed that.

Best
Christopher
The following user(s) said Thank You: ddrake

2 months 1 week ago #1392 by ddrake
Hi Christopher,

I restored the original order of the base classes in netgen/libsrc/geom2d/geometry2d.hpp and added the py:multiple_inheritance() argument to python_geom2d.cpp as you suggested. I'm not seeing any seg faults or other issues after making those changes.

Best,
Dow