slepc4py demo ex3 crash with single process
slepc4py 3.18.0 demo ex3.py is crashing on a debian system, running as a single process:
$ python3 ex3.py
Symmetric Eigenproblem (matrix-free), N=1024 (32x32 grid)
Number of iterations of the method: 15
Solution method: krylovschur
Number of requested eigenvalues: 3
Stopping condition: tol=1e-08, maxit=113
Number of converged eigenpairs: 4
k ||Ax-kx||/||kx||
----------------- ------------------
7.981888 8.72315e-09
7.954801 5.81306e-09
7.927715 1.35496e-09
7.909930 5.12691e-09
[0]PETSC ERROR: ------------------------------------------------------------------------
[0]PETSC ERROR: Caught signal number 11 SEGV: Segmentation Violation, probably memory access out of range
[0]PETSC ERROR: Try option -start_in_debugger or -on_error_attach_debugger
[0]PETSC ERROR: or see https://petsc.org/release/faq/#valgrind and https://petsc.org/release/faq/
[0]PETSC ERROR: configure using --with-debugging=yes, recompile, link, and run
[0]PETSC ERROR: to get more information on the crash.
[0]PETSC ERROR: Run with -malloc_debug to check if memory corruption is causing the crash.
--------------------------------------------------------------------------
MPI_ABORT was invoked on rank 0 in communicator MPI_COMM_WORLD
with errorcode 59.
NOTE: invoking MPI_ABORT causes Open MPI to kill all MPI processes.
You may or may not see output from other processes, depending on
exactly when Open MPI kills them.
--------------------------------------------------------------------------
gdb provides a backtrace, suggesting the crash is triggered in petsc4py when shutting down the process after a successful calculation:
$ gdb python3
...
(gdb) run ex3.py
Starting program: /usr/bin/python3 ex3.py
...
Number of iterations of the method: 15
Solution method: krylovschur
Number of requested eigenvalues: 3
Stopping condition: tol=1e-08, maxit=113
Number of converged eigenpairs: 4
k ||Ax-kx||/||kx||
----------------- ------------------
7.981888 8.72315e-09
7.954801 5.81306e-09
7.927715 1.35496e-09
7.909930 5.12691e-09
Thread 1 "python3" received signal SIGSEGV, Segmentation fault.
0x000055555579b89c in new_threadstate (interp=0x0, init=1) at ../Python/pystate.c:616
616 ../Python/pystate.c: No such file or directory.
(gdb) bt
#0 0x000055555579b89c in new_threadstate (interp=0x0, init=1) at ../Python/pystate.c:616
#1 0x00005555555f4225 in PyThreadState_New (interp=<optimized out>) at ../Python/pystate.c:684
#2 PyGILState_Ensure () at ../Python/pystate.c:1504
#3 0x00007ffff73418c8 in __pyx_f_11libpetsc4py_MatDestroy_Python (__pyx_v_mat=0x5555565db250) at src/libpetsc4py/libpetsc4py.c:9915
#4 0x00007ffff60cbbdc in MatDestroy (A=0x5555565e30a0) at ./src/mat/interface/matrix.c:1366
#5 0x00007ffff60cc118 in MatDestroyMatrices (n=<optimized out>, mat=mat@entry=0x5555562ad1f0) at ./src/mat/interface/matrix.c:7094
#6 0x00007fffb1fa48df in STReset (st=0x5555562acf70) at ./src/sys/classes/st/interface/stfunc.c:107
#7 0x00007fffb2029dd4 in EPSReset (eps=0x5555565e30e0) at ./src/eps/interface/epsbasic.c:309
#8 0x00007fffb2029ea5 in EPSDestroy (eps=0x7fffffffa888) at ./src/eps/interface/epsbasic.c:337
#9 0x00007ffff5f54e60 in PetscObjectDestroy (obj=obj@entry=0x7fffffffa888) at ./src/sys/objects/destroy.c:51
#10 0x00007ffff5f6c66b in PetscGarbageCleanup (comm=<optimized out>) at ./src/sys/objects/garbage.c:219
#11 0x00007ffff5f64626 in PetscFinalize () at ./src/sys/objects/pinit.c:1372
#12 0x00007ffff70b3fc0 in __pyx_f_8petsc4py_5PETSc_finalize () at src/petsc4py.PETSc.c:355255
#13 __pyx_f_8petsc4py_5PETSc_finalize () at src/petsc4py.PETSc.c:27448
#14 0x0000555555607b43 in call_ll_exitfuncs (runtime=<optimized out>) at ../Python/pylifecycle.c:2848
#15 Py_FinalizeEx () at ../Python/pylifecycle.c:1861
#16 0x00005555557b92b9 in Py_RunMain () at ../Modules/main.c:668
#17 0x0000555555795687 in Py_BytesMain (argc=<optimized out>, argv=<optimized out>) at ../Modules/main.c:720
#18 0x00007ffff7c2920a in __libc_start_call_main (main=main@entry=0x555555795650 <main>, argc=argc@entry=2, argv=argv@entry=0x7fffffffe008) at ../sysdeps/nptl/libc_start_call_main.h:58
#19 0x00007ffff7c292bc in __libc_start_main_impl (main=0x555555795650 <main>, argc=2, argv=0x7fffffffe008, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7fffffffdff8)
at ../csu/libc-start.c:389
#20 0x0000555555795581 in _start ()
Edited by Drew Parsons