[petsc-dev] [petsc-users] MatPreallocatorPreallocate segfault with PETSC 3.16

Patrick Sanan patrick.sanan at gmail.com
Tue Feb 1 09:06:17 CST 2022


Sorry about the delay on this. I can reproduce.

This regression appears to be a result of this optimization:
https://gitlab.com/petsc/petsc/-/merge_requests/4273

The changes there including having MatPreallocator destroy its internal
hash structure within MatPreallocatorPreallocate(), which allows for a
lower overall memory footprint but prevents usage of the same
MatPreallocate object for two Mats. The error you see is because this hash
structure was destroyed during the first preallocation. We didn't catch
this because our test suite doesn't test that usage.

cc'ing PETSc dev because I'm not sure how to best resolve this - enforce
that a MatPreallocator is only "good once", remove the PetscHSetIJDestroy()
calls and accept the bigger memory footprint, or something else more clever?

My test to reproduce with C, which can be included in our fix in
src/mat/tests , attached.

Am Mo., 24. Jan. 2022 um 10:33 Uhr schrieb Marius Buerkle <mbuerkle at web.de>:

>
> Hi,
>
> I try to use MatPreallocatorPreallocate to allocate a MATMPIAIJ matrix A .
> I define the MATPREALLOCATOR preM with MatSetValues and then call
> MatPreallocatorPreallocate to get A. This works on the first call to
> MatPreallocatorPreallocate, but if I call MatPreallocatorPreallocate  again
> with the same preM to get another matrix B then I get a segfault, although
> the program continues to run (see below). It worked with PETSC 3.15 but
> with 3.16 I stopped working.
> When I check mat_info_nz_allocated and mat_info_nz_used for the allocated
> matrix it looks correct for the first call, but on the second call
> mat_info_nz_used is 0. I also attached a minimal example.
>
>
> [0]PETSC ERROR: --------------------- Error Message
> --------------------------------------------------------------
> [0]PETSC ERROR: Null argument, when expecting valid pointer
> [1]PETSC ERROR: --------------------- Error Message
> --------------------------------------------------------------
> [0]PETSC ERROR: Null Pointer: Parameter # 1
> [0]PETSC ERROR: See https://petsc.org/release/faq/ for trouble shooting.
> [0]PETSC ERROR: [1]PETSC ERROR: Null argument, when expecting valid pointer
> [1]PETSC ERROR: Petsc Development GIT revision: v3.16.3-686-g5e81a90  GIT
> Date: 2022-01-23 05:13:26 +0000
> [0]PETSC ERROR: ./prem_test on a  named cd001 by cdfmat_marius Mon Jan 24
> 18:21:17 2022
> [0]PETSC ERROR: Null Pointer: Parameter # 1
> [1]PETSC ERROR: See https://petsc.org/release/faq/ for trouble shooting.
> [1]PETSC ERROR: Configure options
> --prefix=/home/cdfmat_marius/prog/petsc/petsc_main_dbg
> --with-scalar-type=complex --with-fortran-kernels=1 --with-64-bit-indices=0
> --CC=mpiicc --COPTFLAGS="-g -traceback" --CXX=mpiicpc --CXXOPTFLAGS="-g
> -traceback" --FC=mpiifort --FOPTFLAGS="-g -traceback" --with-mpi=1
> --with-x=0 --with-cuda=0
> --download-parmetis=/home/cdfmat_marius/prog/petsc/git/petsc_main/externalpackages/git.parmetis.tar.gz
> --download-parmetis-commit=HEAD
> --download-metis=/home/cdfmat_marius/prog/petsc/git/petsc_main/externalpackages/git.metis.tar.gz
> --download-metis-commit=HEAD
> --download-slepc=/home/cdfmat_marius/prog/petsc/git/petsc_main/externalpackages/git.slepc_main.tar.gz
> --download-slepc-commit=HEAD
> --download-superlu_dist=/home/cdfmat_marius/prog/petsc/git/petsc_main/externalpackages/git.superlu_dist.tar.gz
> --download-superlu_dist-commit=HEAD
> --download-mumps=/home/cdfmat_marius/prog/petsc/git/petsc_main/externalpackages/git.mumps.tar.gz
> --download-mumps-commit=HEAD
> --download-hypre=/home/cdfmat_marius/prog/petsc/git/petsc_main/externalpackages/git.hypre.tar.gz
> --download-hypre-commit=HEAD
> --download-hwloc=/home/cdfmat_marius/prog/petsc/git/petsc_main/externalpackages/hwloc-2.5.0.tar.gz
> --download-sowing=/home/cdfmat_marius/prog/petsc/git/petsc_main/externalpackages/git.sowing.tar.gz
> --download-elemental=/home/cdfmat_marius/prog/petsc/git/petsc_main/externalpackages/git.elemental.tar.gz
> --download-elemental-commit=HEAD
> --download-make=/home/cdfmat_marius/prog/petsc/git/petsc_main/externalpackages/make-4.2.1-6.fc28.tar.gz
> --download-ptscotch=/home/cdfmat_marius/prog/petsc/git/petsc_main/externalpackages/git.ptscotch.tar.gz
> --download-ptscotch-commit=HEAD --with-openmp=0 --with-pthread=0
> --with-cxx-dialect=c++11 --with-debugging=1 --with-cuda=0 --with-cudac=0
> --with-valgrind=0 --with-blaslapack-lib="-mkl=sequential
> -lmkl_scalapack_lp64 -lmkl_blacs_intelmpi_lp64 -lpthread -lm -ldl"
> --with-scalapack-lib="-mkl=sequential -lmkl_scalapack_lp64
> -lmkl_blacs_intelmpi_lp64 -lpthread -lm -ldl"
> --with-mkl_pardiso-dir=/home/appli/intel/compilers_and_libraries_2020.4.304/linux/mkl
> --with-mkl_cpardiso-dir=/home/appli/intel/compilers_and_libraries_2020.4.304/linux/mkl
> --with-mkl_sparse-dir=/home/appli/intel/compilers_and_libraries_2020.4.304/linux/mkl
> --with-mkl_sparse_optimize-dir=/home/appli/intel/compilers_and_libraries_2020.4.304/linux/mkl
> [0]PETSC ERROR: Petsc Development GIT revision: v3.16.3-686-g5e81a90  GIT
> Date: 2022-01-23 05:13:26 +0000
> [1]PETSC ERROR: ./prem_test on a  named cd001 by cdfmat_marius Mon Jan 24
> 18:21:17 2022
> [1]PETSC ERROR: #1 PetscHSetIJGetSize() at
> /home/cdfmat_marius/prog/petsc/git/petsc_main/include/petsc/private/hashsetij.h:13
> [0]PETSC ERROR: #2 MatPreallocatorPreallocate_Preallocator() at
> /home/cdfmat_marius/prog/petsc/git/petsc_main/src/mat/impls/preallocator/matpreallocator.c:165
> [0]PETSC ERROR: #3 MatPreallocatorPreallocate() at
> /home/cdfmat_marius/prog/petsc/git/petsc_main/src/mat/impls/preallocator/matpreallocator.c:234
> Configure options --prefix=/home/cdfmat_marius/prog/petsc/petsc_main_dbg
> --with-scalar-type=complex --with-fortran-kernels=1 --with-64-bit-indices=0
> --CC=mpiicc --COPTFLAGS="-g -traceback" --CXX=mpiicpc --CXXOPTFLAGS="-g
> -traceback" --FC=mpiifort --FOPTFLAGS="-g -traceback" --with-mpi=1
> --with-x=0 --with-cuda=0
> --download-parmetis=/home/cdfmat_marius/prog/petsc/git/petsc_main/externalpackages/git.parmetis.tar.gz
> --download-parmetis-commit=HEAD
> --download-metis=/home/cdfmat_marius/prog/petsc/git/petsc_main/externalpackages/git.metis.tar.gz
> --download-metis-commit=HEAD
> --download-slepc=/home/cdfmat_marius/prog/petsc/git/petsc_main/externalpackages/git.slepc_main.tar.gz
> --download-slepc-commit=HEAD
> --download-superlu_dist=/home/cdfmat_marius/prog/petsc/git/petsc_main/externalpackages/git.superlu_dist.tar.gz
> --download-superlu_dist-commit=HEAD
> --download-mumps=/home/cdfmat_marius/prog/petsc/git/petsc_main/externalpackages/git.mumps.tar.gz
> --download-mumps-commit=HEAD
> --download-hypre=/home/cdfmat_marius/prog/petsc/git/petsc_main/externalpackages/git.hypre.tar.gz
> --download-hypre-commit=HEAD
> --download-hwloc=/home/cdfmat_marius/prog/petsc/git/petsc_main/externalpackages/hwloc-2.5.0.tar.gz
> --download-sowing=/home/cdfmat_marius/prog/petsc/git/petsc_main/externalpackages/git.sowing.tar.gz
> --download-elemental=/home/cdfmat_marius/prog/petsc/git/petsc_main/externalpackages/git.elemental.tar.gz
> --download-elemental-commit=HEAD
> --download-make=/home/cdfmat_marius/prog/petsc/git/petsc_main/externalpackages/make-4.2.1-6.fc28.tar.gz
> --download-ptscotch=/home/cdfmat_marius/prog/petsc/git/petsc_main/externalpackages/git.ptscotch.tar.gz
> --download-ptscotch-commit=HEAD --with-openmp=0 --with-pthread=0
> --with-cxx-dialect=c++11 --with-debugging=1 --with-cuda=0 --with-cudac=0
> --with-valgrind=0 --with-blaslapack-lib="-mkl=sequential
> -lmkl_scalapack_lp64 -lmkl_blacs_intelmpi_lp64 -lpthread -lm -ldl"
> --with-scalapack-lib="-mkl=sequential -lmkl_scalapack_lp64
> -lmkl_blacs_intelmpi_lp64 -lpthread -lm -ldl"
> --with-mkl_pardiso-dir=/home/appli/intel/compilers_and_libraries_2020.4.304/linux/mkl
> --with-mkl_cpardiso-dir=/home/appli/intel/compilers_and_libraries_2020.4.304/linux/mkl
> --with-mkl_sparse-dir=/home/appli/intel/compilers_and_libraries_2020.4.304/linux/mkl
> --with-mkl_sparse_optimize-dir=/home/appli/intel/compilers_and_libraries_2020.4.304/linux/mkl
> [1]PETSC ERROR: #1 PetscHSetIJGetSize() at
> /home/cdfmat_marius/prog/petsc/git/petsc_main/include/petsc/private/hashsetij.h:13
> [1]PETSC ERROR: #2 MatPreallocatorPreallocate_Preallocator() at
> /home/cdfmat_marius/prog/petsc/git/petsc_main/src/mat/impls/preallocator/matpreallocator.c:165
> [1]PETSC ERROR: #3 MatPreallocatorPreallocate() at
> /home/cdfmat_marius/prog/petsc/git/petsc_main/src/mat/impls/preallocator/matpreallocator.c:234
>
> Best and Thanks,
> Marius
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-dev/attachments/20220201/c0518f78/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ex250.c
Type: application/octet-stream
Size: 2825 bytes
Desc: not available
URL: <http://lists.mcs.anl.gov/pipermail/petsc-dev/attachments/20220201/c0518f78/attachment.obj>


More information about the petsc-dev mailing list