Skip to content

Add better error handling for locate_dofs_topological#4033

Open
jorgensd wants to merge 7 commits intomainfrom
dokken/error-handling-locate-topological
Open

Add better error handling for locate_dofs_topological#4033
jorgensd wants to merge 7 commits intomainfrom
dokken/error-handling-locate-topological

Conversation

@jorgensd
Copy link
Member

@jorgensd jorgensd commented Jan 5, 2026

Resolves #4010

@jorgensd jorgensd requested a review from garth-wells January 5, 2026 12:10
@jorgensd jorgensd added the housekeeping Tidying and style improvements label Jan 5, 2026
Copy link
Contributor

@schnellerhase schnellerhase left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personally would prefer std::ranges::any_of. Maybe good to think about how we deal with input checks in general at some later point. Ref #4053.

@jhale
Copy link
Member

jhale commented Feb 17, 2026

There are a few notoriously 'easy to get wrong' functions, and this is one of them.

On the broader discussion, there are a number of things that could be done:

  1. For cheap checks, we could consider a cheap 'hardening mode', e.g. https://libcxx.llvm.org/Hardening.html. And the same for expensive checks, an expensive 'hardening mode'. Users and distributors could then pick the mode they fancy. There should probably be some policy here on the complexity of the check and which category it fits in.
  2. Packages in the latest distributions built against C++ standard libraries now have their cheap hardening checks enabled by default https://best.openssf.org/Compiler-Hardening-Guides/Compiler-Options-Hardening-Guide-for-C-and-C++.html. These errors don't have nice messages, but at least you get an error and termination. This PR looks like a manual check for valid-element-access policy in https://libcxx.llvm.org/Hardening.html.
  3. Bit embarrassing that this isn't done but we still need to convert all of our throws to a dolfinx::runtime_error - it's bad design for callers to have to catch std::runtime_error.

@jhale
Copy link
Member

jhale commented Feb 17, 2026

The other option would be to have two modes; a hardened mode where we put in any check we feel necessary, regardless of complexity, and an unhardened mode.

@jorgensd jorgensd requested a review from jhale February 18, 2026 08:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

housekeeping Tidying and style improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG]: locate_dofs_topological segmentation (core dumped)

3 participants

Comments