mesh: validate dimensions, null pointers and indices at the public boundary - #4517
Merged
Merged
Conversation
jhale
added this pull request to stack #4520
September 15, 2026 09:18
jhale
commented
Sep 15, 2026
jhale
commented
Sep 15, 2026
jhale
force-pushed
the
jhale/mesh-review-wp3-boundary-validation
branch
from
September 15, 2026 13:03
bbdc9f9 to
1b040bd
Compare
jhale
marked this pull request as ready for review
September 15, 2026 13:05
jhale
force-pushed
the
jhale/mesh-review-wp3-boundary-validation
branch
from
September 15, 2026 13:12
1b040bd to
8187cd3
Compare
jhale
force-pushed
the
jhale/mesh-review-wp3-boundary-validation
branch
from
September 15, 2026 13:50
8187cd3 to
3f54bc1
Compare
jhale
force-pushed
the
jhale/mesh-review-wp3-boundary-validation
branch
from
September 15, 2026 13:59
3f54bc1 to
b27bd63
Compare
jhale
force-pushed
the
jhale/mesh-review-wp3-boundary-validation
branch
2 times, most recently
from
September 16, 2026 08:16
f7cbb66 to
9bfbd33
Compare
jhale
force-pushed
the
jhale/mesh-review-wp3-boundary-validation
branch
from
September 16, 2026 15:19
9bfbd33 to
560c48e
Compare
garth-wells
previously requested changes
Sep 16, 2026
Base automatically changed from
jhale/mesh-review-wp2-assert-to-throw
to
main
September 17, 2026 06:27
jhale
force-pushed
the
jhale/mesh-review-wp3-boundary-validation
branch
2 times, most recently
from
September 17, 2026 11:18
338822f to
b3dd996
Compare
…undary Several public entry points took dimension/index arguments, or shared_ptr<const Topology> arguments, with no validation at all, so bad input from Python was undefined behaviour in Release rather than an exception: Topology::index_map(s) indexed _entity_types with unchecked operator[] (the root cause several other constructors route through), cell_types.cpp's entity/sub-entity lookups indexed basix tables directly, EntityMap's and MeshTags' constructors dereferenced their Topology arguments before checking them, create_geometry never validated its gdim argument or cross-checked x/nodes/xdofs sizes, compute_incident_entities passed caller entity indices straight into an unchecked AdjacencyList lookup, reorder_cells never validated a user reorder_fn's returned permutation, and transfer_meshtags_to_submesh never checked that its EntityMap arguments actually related the topologies it was given - swapping them (the natural mistake, since that's create_submesh's own return order) was an unchecked OOB read and write. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
jhale
force-pushed
the
jhale/mesh-review-wp3-boundary-validation
branch
from
September 17, 2026 16:39
b3dd996 to
79ee1eb
Compare
jhale
dismissed
garth-wells’s stale review
September 17, 2026 16:41
Braces added - why can't this be linted without heavy tools like clang-tidy...
garth-wells
approved these changes
Sep 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Several public entry points took dimension/index arguments, or
shared_ptr arguments, with no validation at all, so bad
input from Python was undefined behaviour in Release rather than an
exception: Topology::index_map(s) indexed _entity_types with unchecked
operator[] (the root cause several other constructors route through),
cell_types.cpp's entity/sub-entity lookups indexed basix tables directly,
EntityMap's and MeshTags' constructors dereferenced their Topology
arguments before checking them, create_geometry never validated its
gdim argument or cross-checked x/nodes/xdofs sizes, compute_incident_entities
passed caller entity indices straight into an unchecked AdjacencyList
lookup, reorder_cells never validated a user reorder_fn's returned
permutation, and transfer_meshtags_to_submesh never checked that its
EntityMap arguments actually related the topologies it was given -
swapping them (the natural mistake, since that's create_submesh's own
return order) was an unchecked OOB read and write.
Co-Authored-By: Claude Sonnet 5 noreply@anthropic.com
Stack created with GitHub Stacks CLI • Give Feedback 💬