Repository navigation
Conversation
The "stat:sum handles empty particle bank" section of test_mcpl_stat_sum
passed bank_index = {0}. write_mcpl_source_bank_internal() expects
n_procs + 1 cumulative offsets and reads bank_index[rank + 1], so the
test read past the end of a one-element vector. Plain builds happen to
pass; with bounds-checked standard libraries the read traps (SIGILL with
hardened libc++ as reported, SIGABRT with -D_GLIBCXX_ASSERTIONS).
Use {0, 0}, the offsets for one rank holding no particles.
Fixes openmc-dev#4054
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
Description
The "stat:sum handles empty particle bank" section of
test_mcpl_stat_sumpassedbank_index = {0}.write_mcpl_source_bank_internal()expectsn_procs + 1cumulative offsets and readsbank_index_all_ranks[rank_idx + 1], so with one rank the test read past the end of a one-element vector. Plain builds happen to pass. A standard library with bounds checks traps on that read, which is theSIGILLin #4054 (FreeBSD's libc++ is hardened). This PR uses{0, 0}, the offsets for one rank holding no particles. It is a test-only change. Real callers already passn_procs + 1entries.Reproduced on
developat 5d63501, Ubuntu 24.04, MCPL frompip install mcpl, runningtests/cpp_unit_teststest_mcpl_stat_sum:-D_GLIBCXX_ASSERTIONS__n < this->size()(exit 134)-stdlib=libc++ -D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_FASTassertions: 6 | 5 passed | 1 failed(exit 132), the same as the reportWith the fix, all 16 C++ unit tests also pass under
-D_GLIBCXX_ASSERTIONS(ctest, 16/16). Removal control: reverting the one-line change in the same assertions build brings back the SIGABRT (exit 134). These runs were local builds (cmake -DOPENMC_FORCE_FETCHCONTENT=ON -DOPENMC_USE_OPENMP=OFF); the full CI matrix will run here on the PR.Fixes #4054
AI Assistance
The agent found the cause, wrote the change and ran the builds above. It is opened on behalf of @kvnloo.
Checklist
Summary by CodeRabbit