[petsc-users] Segfaults when calling some PETSc functions in Fortran with variables initialized to PETSC_NULL_XX
Mark Adams
mfadams at lbl.gov
Mon Jul 21 06:48:11 CDT 2025
Hi Robert, [I don't see this message to PETSc users in my email so cc'ing
manually]
This is odd, something is messed up.
These NULL things are certainly 0 and the initial value of these objects is
not defined by the compiler, and they could be 0 in some cases.
Others are more up on the new Fortran stuff, but I would do a clean build
of PETSc (rm -fr arch...), and turn debugging on.
You will get a stack trace and it might find something and give a useful
error message, or "fix" the problem mysteriously.
You could put a print statement in before these are initialized to see what
*was* in it that you are clobbering.
Mark
On Sun, Jul 20, 2025 at 10:33 AM Robert Hager <rhager at pppl.gov> wrote:
> FYI
>
> ---------- Forwarded message ---------
> From: Robert Hager <rhager at pppl.gov>
> Date: Sun, Jul 20, 2025 at 10:32 AM
> Subject: Segfaults when calling some PETSc functions in Fortran with
> variables initialized to PETSC_NULL_XX
> To: <petsc-users at mcs.anl.gov>
>
>
> Hello,
>
> I am in the process of updating my code to use PETSc versions >=3.22. (I
> am using v3.22.3 compiled with GCC on Perlmutter-CPU at NERSC for debugging
> at this time.) After updating all the Fortran function calls that have
> changed from v3.21 to v3.22 I am now getting segfaults in some PETSc
> routines. In the two instances I was able to identify, the problem seems to
> be calling the PETSc function with a PETSc variable that has been
> initialized to PETSC_NULL_XX:
>
> solver%rhs2_mat = PETSC_NULL_MAT
>
> [...]
>
> *call* MatDuplicate(solver%Amat,MAT_DO_NOT_COPY_VALUES,solver%rhs2
> _mat,ierr)
>
> --> Segfault
>
>
> solver%ksp = PETSC_NULL_KSP
>
> [...]
>
> *call* KSPCreate(solver%comm,solver%ksp,ierr)
>
> --> Segfault
>
>
> When I comment out the assignments to PETSC_NULL_XX in the above examples,
> the code works just fine.
>
> Is this the intended behavior or a bug that you might have fixed by now?
>
> Best,
>
> Robert
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20250721/5b9d27b6/attachment.html>
More information about the petsc-users
mailing list