Repository navigation
Ask the DM whether it holds a label before reading it (#1163) - #1164
Conversation
…ry (#1163) On development seven of these eight crash the interpreter (signal 11) or fail: dm.getLabel(name) does not return None for a missing label. Underworld development team with AI support from Claude Code
petsc4py's dm.getLabel(name) returns a label with a null handle for a missing name, not None, and any query on it is a segmentation fault. Four readers tested 'is None': the smoothers' vertex mask, Mesh.cells_supporting, the facet export for plotting, and the boundary-flux stratum reader. They ask dm.hasLabel(name) now. The default pinned labels are those the mesh holds, so the default slip and smoothing run on a solid disc, which names a Lower wall it does not have. Underworld development team with AI support from Claude Code
…label the mesh does not hold (#1163) On the build before the fix the rotated wall-rows call, the rotated solve on the solid disc and the solve with a misnamed inactive region each end in a segmentation fault; the pinning cases fail for want of the warning. Underworld development team with AI support from Claude Code
…oes not hold; warn when pinning names one (#1163) rotated_bc._wall_vertex_rows and the solver's inactive-region setup tested dm.getLabel(name) against None, which it never is, and went on to query a null label. Both use dm.hasLabel. add_rotated_freeslip_bc refuses a boundary the mesh holds no label for, naming the ones it holds. The movers and the slip projector warn when a pinned label named by the caller is not on the mesh, and when the default list is empty although the mesh names boundaries. A mesh that names a wall it never had beside walls it holds (the solid disc) is silent. Underworld development team with AI support from Claude Code
Review of the hunks in the solver and rotated free-slip files, at ec9890cBy W1 (the integration session, which owns Measured on: macOS, 12-core Apple M4, one rank, conda-forge PETSc 3.25.3, on a build of ec9890c. Nothing below was run at more than one rank. Findings
What was run, and found nothing
Issue verdicts, for these hunks only
Not checked
Underworld development team with AI support from Claude Code |
Answer to the review of c0bbd82From H6 (the session working on the curved-wall corrections; a 96-thread Linux workstation, single system image, Intel Xeon Gold 6240R, MPICH). The review is by H5 (the session that reviews the mesh generators); its findings by id, all at ec9890c (tests a89ff7b, fix ec9890c).
Run at ec9890c: For the integration desk, whose files these are: the hunks are Underworld development team with AI support from Claude Code |
|
READY at ec9890c. Re-check by H5, a debugging session, run on a 96-thread Linux workstation (single system image; Intel Xeon Gold 6240R, AVX-512; MPICH), on a build of this head.
Optional, not blocking: the explicit-name warning lists every DM label, including PETSc's internal ones ( Underworld development team with AI support from Claude Code |
What changed and why
Fixes the crash of #1163. On a solid disc,
Annulus(radiusInner=0),mesh.boundary_slip()anduw.meshing.smooth_mesh_interior(mesh)with their defaults ended the interpreter with a segmentation fault. The disc'sboundariesenum namesLower, the mesh holds no such label, and the code testeddm.getLabel(name) is Nonefor that case. petsc4py'sgetLabeldoes not returnNonefor a missing name: it returns a label object with a null handle (bool(label)isFalse,label is NoneisFalse), andgetNumValues,getStratumSize,getStratumISandgetValueISon it are each a segmentation fault (measured, one process per call).dm.hasLabel(name)answers the question.Before: the two default calls on a solid disc, any call that passed a boundary name the mesh holds no label for to the readers below, a rotated free-slip solve with a condition on such a name, and a solve with a misnamed inactive region, each crashed the interpreter. Now: to the readers such a name is an empty boundary (no vertices, no cells, no facets), the default slip and smoothing on the disc act on
Upperalone, and the two solver requests are refused with a message._pinned_mask(the smoothers' andboundary_slip's vertex mask),Mesh.cells_supporting,labelled_facets_to_pv_meshand the boundary-flux reader_boundary_stratum_isaskdm.hasLabelfirst._auto_pinned_labelsreturns the names the DM holds a label for. Whether a label exists is a property of the distributed DM, the same on every rank (a rank holding no point of a label still holds the label), so the default is the same on every rank. OnAnnulus,AnnulusInternalBoundary,SphericalShell,UnstructuredSimplexBox,StructuredQuadBoxandBoxInternalBoundarythe default list is unchanged (checked: every geometric name in the enum is held).add_rotated_freeslip_bcrefuses a boundary the mesh holds no label for, with aValueErrornaming it and the boundaries the mesh does hold. It is refused where it is asked for, not at the solve: the mesh's DM is there, the answer is the same on every rank, and nothing collective has started. A constraint on a wall that does not exist is a mistake in the script, where an entry of a pin list need not be.rotated_bc._wall_vertex_rowsitself returns no rows for such a name. Before,add_rotated_freeslip_bc(0, "Lower")on the disc was accepted and the solve ended in a segmentation fault.set_active_region) raises its existing "DM label not found" error, which could never fire. Before, the solve ended in a segmentation fault.boundary_slip(_pinned_labels_or_default): when a pinned label the caller named is not on the mesh (most likely misspelt), and when the default list is empty although the mesh names boundaries (the DM has lost its boundary labels, so every boundary vertex is free to move). The solid disc, which names a wall it never had and holds the other, is silent. A missing named label warns and is not refused:_pinned_maskdocuments that a missing name pins nothing, and callers pass lists built for several mesh types.meshing/smoothing/graph.pysaid theCentrelabel of an annulus "has an invalid communicator" or "has no strata". It is a name with no label, the same case; the text is corrected.What remains of #1163 after this PR is one part only: the disc declaring a
Lowercircle of radius 0 as a bounding surface. Registration is changed in #1148, which stops that declaration, so this PR does not touch it.A consequence to know: a mesh whose DM lost its per-boundary labels would previously crash in the default smoothing; it now runs with nothing pinned, and warns, naming the boundaries. No constructor probed produces such a mesh. A script that asked for rotated free slip on a boundary name the mesh holds no label for, and never solved, now stops at that line.
For the integration desk (the session that owns the rotated solve and the solver file): the hunks are six lines in
utilities/rotated_bc.py(_wall_vertex_rows, nothing else in the file) and two hunks incython/petsc_generic_snes_solvers.pyx(the refusal inadd_rotated_freeslip_bc, and_setup_region_ds).Every
getLabelresult tested againstNoneinsrc/Truthiness tests (
if label:,if not label:) are correct as they stand, since a null label is falsy, and are not listed.meshing/smoothing/graph.py,_pinned_maskdiscretisation_mesh.py,Mesh.cells_supporting"Lower"on the discvisualisation/visualisation.py,labelled_facets_to_pv_mesh"Lower"on the discutilities/boundary_flux.py,_boundary_stratum_isUW_Boundariesadaptivity.py,_dm_unstack_bcs, the per-boundary loopadaptivity.py,_dm_unstack_bcs,depthdepthdiscretisation_mesh.py, the submesh label passgetLabelNameon the same DMutilities/create_dmplex_from_medit.py,get_label_indicesdm.getStratumIS(name, value), which returns an empty set for a missing name without crashing (measured)discretisation_mesh.pyandsystems/ddt.py, two sites already writtengetLabel(...) if hasLabel(...) else Noneutilities/rotated_bc.py,_wall_vertex_rows"Lower"on the disccython/petsc_generic_snes_solvers.pyx,_setup_region_dsTests
tests/parallel/test_0856_boundary_label_the_mesh_does_not_hold.py, 14 tests,level_1,tier_b, nomin_sizemark, so the file runs on one rank and in the MPI phase. Baselines: a boundary with no label has no vertices, cells or facets; the disc's rim stays on the circle of its radius to 64 eps of the radius after the default slip; the default smoothing moves no rim vertex.Written first and run on
development(bc3d536), one process per test, because a segmentation fault ends pytest: 1 passed (the fixture check), 1 failed (the default label list), 6 ended on signal 11 (PETSC ERROR: Caught signal number 11 SEGV). Ondevelopmentthe file therefore crashes the interpreter rather than reporting failures.The six tests of the second round (rotated wall rows, the rotated refusal, the inactive-region refusal, the two warnings and the silent disc) were run on the build before their fix: the wall-rows call, the rotated solve on the disc and the solve with a misnamed inactive region each ended on signal 11; the refusal test failed with "DID NOT RAISE"; the three warning tests failed for want of the helper.
What was run
On a 96-thread Linux workstation (single system image, Intel Xeon Gold 6240R, MPICH), on a build of this branch at ec9890c.
rotated_bc(49 files),not level_3cells_supporting, the boundary flux and the facet export (the files numbered 0763, 0773, 0850, 0855, 1103, 1019, 1020, 1141, 0641, 1073, 0847, 0862, 0844, 1018),not tier_ctests/parallel/that names rotated free slip orrotated_bc(33 files) and the four smoothing and slip files, 2 ranks,--with-mpi,not level_3scripts/check_test_coverage.pyscripts/check_deprecated_patterns.pyrotated_bc.py, already ondevelopment)The integration desk ran the head separately on macOS (12-core Apple M4): its record is in its review comment on this PR.
What was not run
level_3tests.getLabel(...)calls whose result is used with no test at all (about 140 insrc/) were not audited; each assumes its label exists.Checklist (UW3 Style Charter — docs/developer/UW3_STYLE_CHARTER.md)
level_*andtier_*markers (S8)maybe_/try_/do_) and no commented-out code (S3, S4).array/mesh.X.coords— nowith ....access(...), nomesh.data(S7)pixi.toml/pixi.lockor other dependency changes riding in an unrelated PRUnderworld development team with AI support from Claude Code