Hello PETSc Community, I think I've found a bug -
Go to $PETSC_DIR/src/ksp/ksp/tutorials/ open ex5f.F90, and add the following line in MyKSPConverged(), say around line 336: call KSPConvergedDefault(ksp,n,rnorm,flag,dummy,ierr) It should make sense why someone would want to do this - within a definition of custom convergence behaviour, get the default convergence flags, and, based on certain conditions, overwrite it. Now, building and running the exercise, making sure to include the flag to use the custom convergence: boston@boston-SYS-540A-TR:~/DATA_DRIVE/PETSC_DIRS/petsc_3.22/src/ksp/ksp/tutorials$ ./ex2f -my_ksp_convergence [0]PETSC ERROR: ------------------------------------------------------------------------ [0]PETSC ERROR: Caught signal number 11 SEGV: Segmentation Violation, probably memory access out of range[...] >From my debugging, the issue is at line 1520 of iterativ.c: KSPConvergedDefaultCtx *cctx = (KSPConvergedDefaultCtx *)ctx; Because a dummy is used for the context object, this cast fails (my debugger says "cannot access memory..." for cctx). Then the crash happens when trying to access members of cctx: if (cctx->convmaxits && n >= ksp->max_it) { I'm not sure how to fix it. Crucially, we must note that that this did work in older versions of PETSc - I can repeat this test in 3.19.1, for example, and it works fine - a debugger shows the cast succeeding and producing some defaulted version of the ctx object, the subsequent crash does not happen, etc. Does anybody have any advice for working around this for the time being? A piece of software I work with uses a custom ksp convergence test in the manner described above, and is only functional with older versions of petsc because of this. Like in ex2f, I have no need of the ctx object, and just as in ex2f, I use 0 instead. Things I'll try next: defining a proper ctx object (I use 0, like in ex2f), or looking for some PETSC_NULL_CTX definition somewhere. Many Thanks, Daniel