From 00fc55c4bd019b496bb498b60f2a12c65c670bed Mon Sep 17 00:00:00 2001 From: Stan Moore Date: Wed, 25 Feb 2026 14:39:36 -0700 Subject: [PATCH 1/2] Prevent dangling pointer which can lead to crashes --- src/KOKKOS/comm_kokkos.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/KOKKOS/comm_kokkos.cpp b/src/KOKKOS/comm_kokkos.cpp index e65986f9cc4..424751a7c35 100644 --- a/src/KOKKOS/comm_kokkos.cpp +++ b/src/KOKKOS/comm_kokkos.cpp @@ -1120,6 +1120,11 @@ void CommKokkos::exchange_device() k_exchange_sendlist,k_exchange_copylist, k_exchange_copylist_bonus, ExecutionSpaceFromDevice::space); + + // pack_exchange_kokkos may resize k_buf_send + + buf_send = k_buf_send.view_host().data(); + atom->nlocal = nlocal; if (bonus_flag) atomKK->avecKK->set_status_nlocal_bonus(nlocal_bonus); @@ -1695,7 +1700,6 @@ void CommKokkos::grow_send_kokkos(int n, int flag, ExecutionSpace space) atomKK->avecKK->size_border + atomKK->avecKK->size_velocity); else k_buf_send.resize(maxsend_border,atomKK->avecKK->size_border); - buf_send = k_buf_send.view_host().data(); } else { if (ghost_velocity) MemoryKokkos::realloc_kokkos(k_buf_send,"comm:k_buf_send",maxsend_border, @@ -1703,8 +1707,8 @@ void CommKokkos::grow_send_kokkos(int n, int flag, ExecutionSpace space) else MemoryKokkos::realloc_kokkos(k_buf_send,"comm:k_buf_send",maxsend_border, atomKK->avecKK->size_border); - buf_send = k_buf_send.view_host().data(); } + buf_send = k_buf_send.view_host().data(); } /* ---------------------------------------------------------------------- From e2b1f3fceca4cc7db32bc6c760ec1df9357f600d Mon Sep 17 00:00:00 2001 From: Stan Moore Date: Wed, 25 Feb 2026 14:39:12 -0700 Subject: [PATCH 2/2] Initialize variables --- src/KOKKOS/atom_vec_kokkos.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/KOKKOS/atom_vec_kokkos.cpp b/src/KOKKOS/atom_vec_kokkos.cpp index c934822c9cc..52d0b57d5b8 100644 --- a/src/KOKKOS/atom_vec_kokkos.cpp +++ b/src/KOKKOS/atom_vec_kokkos.cpp @@ -33,7 +33,7 @@ AtomVecKokkos::AtomVecKokkos(LAMMPS *lmp) : AtomVec(lmp) kokkosable = 1; buffer = nullptr; buffer_size = 0; - size_exchange = 0; + size_exchange = size_exchange_default = size_exchange_bonus = 0; datamask_grow = datamask_comm = datamask_comm_vel = datamask_reverse = datamask_border = datamask_border_vel = datamask_exchange =