-
Notifications
You must be signed in to change notification settings - Fork 249
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Summary
WarpXParticleContainer::DepositChargeinParticles/WarpXParticleContainer.cpp:1485-1489and again in the overload at1816-1820tries to guard against depositing into a component that was never allocated.- The guard compares
rho->nComp() >= icomp - 1, which is always true becauseicompis non-negative. The check never fails, so requests for component1(used for the “new” charge) succeed even whenrho_fponly allocated one component. - When
do_dive_cleaningis disabled (the default),rho_fphas a single component. The subsequent aliasMultiFab rhoi(*rho, amrex::make_alias, icomp*nc, nc);therefore indexes past the end of the allocation andlockAddwrites out-of-bounds. On GPU this manifests as miscomputed charge and intermittent crashes.
Suggested patch
diff --git a/Particles/WarpXParticleContainer.cpp b/Particles/WarpXParticleContainer.cpp
@@
- WARPX_ALWAYS_ASSERT_WITH_MESSAGE(
- rho->nComp() >= icomp - 1,
+ WARPX_ALWAYS_ASSERT_WITH_MESSAGE(
+ rho->nComp() >= (icomp + 1) * WarpX::ncomps,
"Cannot deposit charge in rho component icomp=" + std::to_string(icomp) +
": not enough components allocated (" + std::to_string(rho->nComp()) + "!"
);
@@
- WARPX_ALWAYS_ASSERT_WITH_MESSAGE(
- rho->nComp() >= icomp - 1,
+ WARPX_ALWAYS_ASSERT_WITH_MESSAGE(
+ rho->nComp() >= (icomp + 1) * WarpX::ncomps,
"Cannot deposit charge in rho component icomp=" + std::to_string(icomp) +
": not enough components allocated (" + std::to_string(rho->nComp()) + "!"
);Prepared by Codex
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working