Repository navigation
Stokes.set_active_region refuses instead of ending in a segfault (#1154) - #1202
Conversation
The method configured a region discrete system (DMSetRegionDS). The first residual evaluation then segfaulted inside PETSc while inserting the essential boundary values, the region value was never used (PETSc takes a labelled system's cells from the stratum at value 1), and the default system would still have been assembled on the inactive cells. It now raises NotImplementedError on every rank, naming mesh.extract_region, the route the design record took (2026-04-05). tests/parallel/test_1154_stokes_active_region_refused_parallel.py: the issue's case refuses with the same message on every rank, and the solve without it converges; development does not refuse (and the solve segfaults). test_0856's missing-label case now expects the refusal at the call. Underworld development team with AI support from Claude Code
|
Review from the Underworld development team with AI support from Claude Code (H1: review and parallel test runs on a 96-thread Linux workstation (Intel Xeon Gold 6240R, AVX-512; MPICH)) Verdict on head 532dbfe: ready to merge on green from this review (a comment, not a GitHub approval). The segfault reproduces on Merge base: fafbecb (current FindingsThere are no blocking findings. 1. Minor: one investigation script still calls
|
development (176958a; it differs from fafbecb only in Python files the solver does not use) |
this head | |
|---|---|---|
BoxInternalBoundary, np 1 |
SEGV in the first residual evaluation | refused; solve converges (reason 2) |
BoxInternalBoundary, np 2 |
SEGV in the first residual evaluation | refused; solve converges (reason 2) |
AnnulusInternalBoundary (the layout from the phase-3 investigation script), np 1 |
SEGV in the first residual evaluation | refused; solve converges (reason 2) |
AnnulusInternalBoundary, np 2 |
not run | refused; solve converges (reason 2) |
- Every rank refuses together, including an empty rank. The method raises from its arguments alone, before any PETSc or MPI call, so no rank can take a different path.
- I checked this with an
allgatherof the messages at np 1 and 2 (default partition), and at np 3 and 4 with a shell partition that leaves the last rank with no cells (cells per rank: 38/38/0 and 27/22/27/0). - All messages were identical, and the same solver then solved on every rank.
- I checked this with an
- No legitimate caller is broken. I searched
src,tests,docsand the examples. The only caller outside the PR's own tests is the investigation script in finding 1. The rewritten test_0856 case asserts the refusal at the call, which is where the missing-label path now ends.
What was run
- Serial (
pytest -n 8): 124 passed.- The PR's tests: test_1154 and test_0856.
- Stokes: test_1010–1014, 1017, 0786, 1066 and 1145.
- Regions and submeshes: test_0771, 0772, 0856_remove_embedded, 0073, test_1154_a_deleted_solver_is_freed and test_1175.
- Parallel, under the MPI supervisor: test_1154, test_0856, test_0786 (Stokes on a rank without cells), test_1175, test_0770 and test_1085.
- np 2: 36 passed and 1 skipped on each rank. The skip is test_0786's own np 2 case: its one-cell triangle has no free velocity node.
- np 4: 37 passed on each rank.
- Reproduction script: 3 runs on
development(box at np 1 and 2, annulus at np 1). 6 runs on this head (box and annulus at np 1 and 2, and the box at np 3 and 4 with an empty rank). Logs are kept by the reviewer.
Not run:
- the full
scripts/test.sh. - the investigation script itself. Its behaviour follows from the line it calls.
Underworld development team with AI support from Claude Code
…nreachable region-DS setup (H1's review) set_active_region refuses, so _setup_region_ds and the check in the Stokes set-up that called it could not be reached: removed, with their entries in the docstring inventory and review queue. No behaviour changes. Underworld development team with AI support from Claude Code
Fixes #1154 by refusing (the issue's option 2).
The defect.
SNES_Stokes_SaddlePt.set_active_region(name, value)is a public method. It configured a region discrete system (DMSetRegionDS) so that only one region's cells would be assembled. On #1154's case, a box with an internal boundary and essential conditions on the walls, the first residual evaluation segfaulted inside PETSc while inserting the essential boundary values (ISGetIndicesinDMProjectLocal_Generic_Plex). Two more defects, by reading:The fix. The method now raises
NotImplementedErroron every rank, from its arguments alone, namingmesh.extract_region. That is the route the design record took (docs/developer/design/submesh-solver-architecture.md, 2026-04-05: "PETSc Region DS segfaults during assembly ... Dead end for now"). A user can no longer reach a segmentation fault through a documented method.Removed (H1's review):
_setup_region_dsand the check in the solver set-up that called it, now unreachable, with their entries in the docstring inventory and review queue. That is the issue's option 1 for the dead code. The method itself stays, refusing.The example
docs/examples/submesh_investigation/test_region_ds_phase3.pycalls the method. It now stops with the refusal instead of segfaulting; it is one line of #944.Tests.
tests/parallel/test_1154_stokes_active_region_refused_parallel.py, tier B: the issue's case refuses with the same message on every rank, and the same solver without the call converges. Development does not refuse, and its solve segfaults. It passes at np 1 and 2, and runs in batch 3 and under--p N.Measured on a 96-thread Linux workstation (single system image; Intel Xeon Gold 6240R, AVX-512; MPICH).
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