electronic-structure / SIRIUS

Domain specific library for electronic structure calculations
BSD 3-Clause "New" or "Revised" License
121 stars 40 forks source link

Sirius doesn't properly report exceptions #867

Closed yurivict closed 6 months ago

yurivict commented 1 year ago

For example, this exception:

1475│     int npk = comm_.size() / npb;
1476│     if (npk * npb != comm_.size()) {
1477│         std::stringstream s;
1478│         s << "Can't divide " << comm_.size() << " ranks into groups of size " << npb;
1479├───────> RTE_THROW(s);
1480│     }

in src/context/simulation_context.cpp causes Abort trap:

$ sirius.scf --test_against=output_ref.json --control.processing_unit=cpu --control.mpi_grid_dims=2:2 --control.std_evp_solver_name=scalapack --control.gen_evp_solver_name=scalapack
SIRIUS 7.4.3, git hash: https://api.github.com/repos/electronic-structure/SIRIUS/git/ref/tags/v7.4.3
Warning! Compiled in 'debug' mode with assert statements enabled!
Abort trap

The error message is lost.

Linux reports lost exceptions anyway, but other OSes do not - such reporting is a linux extension and is not covered by the C++ standard.

You need to have a proper try-catch block in your main function.

toxa81 commented 1 year ago

Implemented in 'develop'