Description:
netgen.meshing.Mesh.Save() crashes with SIGSEGV when called on a 1D mesh (Mesh(dim=1)). This affects any workflow that serializes 1D meshes to .vol / .vol.gz for on-disk caching.
Minimal reproducer:
import tempfile, os
from netgen.meshing import Mesh, MeshPoint, Pnt, Element1D, Element0D
m = Mesh(dim=1)
m.SetMaterial(1, 'reg_a')
m.SetMaterial(2, 'reg_b')
p1 = m.Add(MeshPoint(Pnt(0, 0, 0)))
p2 = m.Add(MeshPoint(Pnt(1, 0, 0)))
p3 = m.Add(MeshPoint(Pnt(2, 0, 0)))
m.Add(Element1D([p1, p2], index=1))
m.Add(Element1D([p2, p3], index=2))
m.Add(Element0D(p1, index=1))
m.Add(Element0D(p3, index=2))
tmp = tempfile.NamedTemporaryFile(suffix='.vol', delete=False)
tmp.close()
m.Save(tmp.name) # <-- SIGSEGV
Expected: Save() writes a valid .vol file (as it does for 2D/3D).
Actual: Segmentation fault. Process crashes before writing anything (or writes 0 bytes when the OS pre-created the file).
Environment:
- netgen 6.2.2606 (PyPI wheel, Windows x86_64)
- Python 3.13
- Also reproduces via ngsolve.Mesh(...).ngmesh.Save() on a NGSolve-wrapped 1D mesh.
Additional context:
Confirmed working in netgen 6.2.2601 with the same code — regression introduced between 2601 and 2606.
Description:
netgen.meshing.Mesh.Save() crashes with SIGSEGV when called on a 1D mesh (Mesh(dim=1)). This affects any workflow that serializes 1D meshes to .vol / .vol.gz for on-disk caching.
Minimal reproducer:
import tempfile, os
from netgen.meshing import Mesh, MeshPoint, Pnt, Element1D, Element0D
m = Mesh(dim=1)
m.SetMaterial(1, 'reg_a')
m.SetMaterial(2, 'reg_b')
p1 = m.Add(MeshPoint(Pnt(0, 0, 0)))
p2 = m.Add(MeshPoint(Pnt(1, 0, 0)))
p3 = m.Add(MeshPoint(Pnt(2, 0, 0)))
m.Add(Element1D([p1, p2], index=1))
m.Add(Element1D([p2, p3], index=2))
m.Add(Element0D(p1, index=1))
m.Add(Element0D(p3, index=2))
tmp = tempfile.NamedTemporaryFile(suffix='.vol', delete=False)
tmp.close()
m.Save(tmp.name) # <-- SIGSEGV
Expected: Save() writes a valid .vol file (as it does for 2D/3D).
Actual: Segmentation fault. Process crashes before writing anything (or writes 0 bytes when the OS pre-created the file).
Environment:
Additional context:
Confirmed working in netgen 6.2.2601 with the same code — regression introduced between 2601 and 2606.