You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
read_mtx() in KokkosKernels_IOUtils.hpp:998 loads a list of (row,col) pairs, sorts them, and then inserts into the CRS structure one row at a time. The loop over entries in the current row only checked if the next entry matches the current row, but NOT that the end of the pair array
has been reached. This caused an invalid read just after inserting the last entry in the matrix.
To fix this, I added another loop condition that makes sure eind < nE before reading edges[eind].
Valgrind output demonstrating the bug:
==59918== Invalid read of size 4
==59918== at 0x43E819: int KokkosKernels::Impl::read_mtx<int, unsigned long, double>(char const*, int*, unsigned long*, unsigned long**, int**, double**, bool, bool, bool) (KokkosKernels_IOUtils.hpp:998)
==59918== by 0x43F2FD: void KokkosKernels::Impl::read_matrix<int, unsigned long, double>(int*, unsigned long*, unsigned long**, int**, double**, char const*) (KokkosKernels_IOUtils.hpp:1019)
==59918== by 0x43F480: KokkosSparse::CrsMatrix<double, int, Kokkos::Cuda, void, unsigned long> KokkosKernels::Impl::read_kokkos_crst_matrix<KokkosSparse::CrsMatrix<double, int, Kokkos::Cuda, void, unsigned long> >(char const*) (KokkosKernels_IOUtils.hpp:1055)
==59918== by 0x405810: main (spgemm.cpp:55)
==59918== Address 0xe169e50 is 0 bytes after a block of size 178,496 alloc'd
==59918== at 0x4C2A1E3: operator new(unsigned long) (vg_replace_malloc.c:334)
==59918== by 0x43DF9B: allocate (new_allocator.h:111)
==59918== by 0x43DF9B: allocate (alloc_traits.h:436)
==59918== by 0x43DF9B: _M_allocate (stl_vector.h:172)
==59918== by 0x43DF9B: _M_create_storage (stl_vector.h:187)
==59918== by 0x43DF9B: _Vector_base (stl_vector.h:138)
==59918== by 0x43DF9B: vector (stl_vector.h:283)
==59918== by 0x43DF9B: int KokkosKernels::Impl::read_mtx<int, unsigned long, double>(char const*, int*, unsigned long*, unsigned long**, int**, double**, bool, bool, bool) (KokkosKernels_IOUtils.hpp:933)
==59918== by 0x43F2FD: void KokkosKernels::Impl::read_matrix<int, unsigned long, double>(int*, unsigned long*, unsigned long**, int**, double**, char const*) (KokkosKernels_IOUtils.hpp:1019)
==59918== by 0x43F480: KokkosSparse::CrsMatrix<double, int, Kokkos::Cuda, void, unsigned long> KokkosKernels::Impl::read_kokkos_crst_matrix<KokkosSparse::CrsMatrix<double, int, Kokkos::Cuda, void, unsigned long> >(char const*) (KokkosKernels_IOUtils.hpp:1055)
==59918== by 0x405810: main (spgemm.cpp:55)
The text was updated successfully, but these errors were encountered:
read_mtx() in KokkosKernels_IOUtils.hpp:998 loads a list of (row,col) pairs, sorts them, and then inserts into the CRS structure one row at a time. The loop over entries in the current row only checked if the next entry matches the current row, but NOT that the end of the pair array
has been reached. This caused an invalid read just after inserting the last entry in the matrix.
To fix this, I added another loop condition that makes sure
eind < nE
before readingedges[eind]
.Valgrind output demonstrating the bug:
The text was updated successfully, but these errors were encountered: