Skip to content

Throw Exceptions in Asserts#1350

Open
ax3l wants to merge 1 commit intoBLAST-ImpactX:developmentfrom
ax3l:fix-throw-assert
Open

Throw Exceptions in Asserts#1350
ax3l wants to merge 1 commit intoBLAST-ImpactX:developmentfrom
ax3l:fix-throw-assert

Conversation

@ax3l
Copy link
Copy Markdown
Member

@ax3l ax3l commented Mar 11, 2026

Fix #1348: Set AMReX system::throw_exception so that in interactive usage we can potentially catch an exception and handle it, instead of terminating the process (Python interpreter).

To Do

@ax3l ax3l added this to the Advanced Methods (SciDAC-5) milestone Mar 11, 2026
@ax3l ax3l added bug Something isn't working bug: affects latest release Bug also exists in latest release version component: core Core ImpactX functionality component: python Python bindings labels Mar 11, 2026
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Mar 11, 2026

Merging this PR will not alter performance

✅ 37 untouched benchmarks


Comparing ax3l:fix-throw-assert (105cee4) with development (62d0e9c)

Open in CodSpeed

Fix BLAST-ImpactX#1348: Set AMReX `system::throw_exception` so that in interactive
usage we can potentially catch an exception and handle it, instead of
terminating the process (Python interpreter).
@ax3l ax3l force-pushed the fix-throw-assert branch from 7d3d184 to 105cee4 Compare March 23, 2026 15:47
@ax3l ax3l mentioned this pull request Mar 23, 2026
5 tasks
WeiqunZhang pushed a commit to AMReX-Codes/amrex that referenced this pull request Mar 23, 2026
## Summary

We use AMReX interactively with `amrex.throw_exception = true` to be
able to handle user errors or convergence issues and act on them.

In Geometry, some methods are defined `noexcept` which breaks exception
propagation in ImpactX
BLAST-ImpactX/impactx#1348 and still aborts
the process as a consequence.

This removes the `noexcept` where they are not guaranteed to be true at
runtime. First seen in `computeRoundoffDomain` which is called from a
couple of places.

Performance impact for this host-side code should be minimal / not a
problem.

## Additional background

Throwing an actual abort in a Python script will abort the whole
interpreter, resetting all its state, terminating the process. That is a
big problem in interactive usage, e.g., Jupyter Notebooks, but also for
general C++ - Python and back error handling logic.

BLAST-ImpactX/impactx#1350

## Checklist

The proposed changes:
- [x] fix a bug or incorrect behavior in AMReX
- [ ] add new capabilities to AMReX
- [ ] changes answers in the test suite to more than roundoff level
- [ ] are likely to significantly affect the results of downstream AMReX
users
- [ ] include documentation in the code and/or rst files, if appropriate
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug: affects latest release Bug also exists in latest release version bug Something isn't working component: core Core ImpactX functionality component: python Python bindings

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Crash with 3D space charge and compact particle distributions

1 participant