[test-suite] CLAMR: port upstream index resize fix in rezone_all (#300)
When running CLAMR with libstdc++ container checks enabled
(_GLIBCXX_DEBUG or _GLIBCXX_ASSERTIONS), Mesh::rezone_all sometimes
aborts with a std::vector<int>::operator[] assertion.
The root cause is that index is resized to new_ncells, but both the
REZONE_NO_OPTIMIZATION and optimized paths fill and read index[ic]
for ic in [0, ncells). On net coarsening steps we have
new_ncells = ncells + add_ncells < ncells,
so index has size new_ncells but is indexed up to ncells - 1, causing
an out-of-bounds access.
Fix this by resizing index to ncells (as done in upstream CLAMR),
because index is a map from old cells to new cells and the loops that
populate and read it always use ic < ncells.
This makes CLAMR pass under libstdc++ debug mode and assertions on
Fedora 42 with GCC 15.
References:
- https://github.com/lanl/CLAMR/blob/master/mesh/mesh.cpp#L2974-L2978
- llvm/llvm-project#144678
- llvm/llvm-test-suite#259 (follow-up for the remaining CLAMR failure)
Signed-off-by: Jerry Zhang Jian <[email protected]>diff --git a/MultiSource/Benchmarks/DOE-ProxyApps-C++/CLAMR/mesh.cpp b/MultiSource/Benchmarks/DOE-ProxyApps-C++/CLAMR/mesh.cpp
index f87dff1..27bc78e 100644
--- a/MultiSource/Benchmarks/DOE-ProxyApps-C++/CLAMR/mesh.cpp
+++ b/MultiSource/Benchmarks/DOE-ProxyApps-C++/CLAMR/mesh.cpp
@@ -2760,7 +2760,8 @@
mesh_memory.memory_swap(&level, &level_old);
index.clear();
- index.resize(new_ncells);
+ // allocate to ncells (oldsize) because index is a map from old cells to new
+ index.resize(ncells);
#ifdef _OPENMP
}
#pragma omp barrier