Skip to content

mesh.RefineHP → .vol save/load segfaults (memory corruption) on 6.2.2604 #249

Description

@mmlanger

Environment

  • ngsolve / netgen 6.2.2604 (pip)
  • macOS (Darwin, arm64), Python 3.14

Summary
A 2D OCC mesh refined with mesh.RefineHP(...) saves to .vol without error, but loading that file crashes with a fatal signal — no Python exception. The signal is non-deterministic across runs (observed both SIGSEGV/11 and SIGBUS/10 for the identical script), indicating memory corruption in the .vol reader rather than a handled error. Removing the RefineHP line makes save/load work. This is the documented OCC hp pattern (edge.hpref + mesh.RefineHP(levels, factor)), so it is not a misuse.

Minimal reproducer

import os, tempfile
import ngsolve
from netgen.occ import OCCGeometry, WorkPlane
from netgen.meshing import Mesh as NgMesh

face = WorkPlane().Rectangle(1, 1).Face()
face.edges[0].hpref = 1
mesh = ngsolve.Mesh(OCCGeometry(face, dim=2).GenerateMesh(maxh=0.3))
mesh.RefineHP(levels=2, factor=0.2)          # remove this line -> save/load works

vol = os.path.join(tempfile.mkdtemp(), "m.vol")
mesh.ngmesh.Save(vol)                        # OK
print("Save OK, loading...")
NgMesh().Load(vol)                           # <-- fatal signal (SIGSEGV / SIGBUS)
print("Load OK")                             # never reached

Observed (two runs of the identical script)

Save OK, loading...
zsh: segmentation fault   python repro.py
Save OK, loading...
zsh: bus error            python repro.py

Independent of maxh / mesh resolution.

Expected
Load reproduces the saved mesh, or raises a clean Python exception — not a process crash.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions