[petsc-dev] Reached the main program with an out-of-range error code 1. This should never happen

Jacob Faibussowitsch jacob.fai at gmail.com
Fri Nov 4 08:18:43 CDT 2022


> Who is supposed to be this someone?

Who indeed 🧐. If you can run the code in gdb you can pinpoint where the problem occurs with the following breakpoint (note untested):

br PetscTraceBackErrorHandler if n == 1

Or lldb:

br s -n PetscTraceBackErrorHandler -c '(int)n == 1’

Best regards,

Jacob Faibussowitsch
(Jacob Fai - booss - oh - vitch)

> On Nov 4, 2022, at 09:02, Stefano Zampini <stefano.zampini at gmail.com> wrote:
> 
> Look at the stacktrace. It is all petsc. Who is supposed to be this someone?
> 
> On Fri, Nov 4, 2022, 15:07 Jacob Faibussowitsch <jacob.fai at gmail.com> wrote:
> I’ve seen these too. It’s from here, right at the end of the error handler. `n` is the error code so someone is returning an unknown error code somewhere.
> 
> PetscStrncmp(fun, "main", 4, &ismain);
> if (ismain) {
>   if ((n <= PETSC_ERR_MIN_VALUE) || (n >= PETSC_ERR_MAX_VALUE)) (*PetscErrorPrintf)("Reached the main program with an out-of-range error code %d. This should never happen\n", n);
>     PetscOptionsViewError();
>     PetscErrorPrintfHilight();
>     (*PetscErrorPrintf)("----------------End of Error Message -------send entire error message to petsc-maint at mcs.anl.gov----------\n");
>     PetscErrorPrintfNormal();
>   }
> }
> 
> Best regards,
> 
> Jacob Faibussowitsch
> (Jacob Fai - booss - oh - vitch)
> 
> > On Nov 4, 2022, at 05:06, Stefano Zampini <stefano.zampini at gmail.com> wrote:
> > 
> > What does the message imply? That PETSc error handler is misbehaving? or that the user code is wrong? I don't understand. This is the latest release with a faulty code that I use as an example for using valgrind and gdb.
> > 
> > [0]PETSC ERROR: Memory corruption: https://petsc.org/release/faq/#valgrind
> > [0]PETSC ERROR: Corrupted memory
> > [0]PETSC ERROR: See https://petsc.org/release/faq/ for trouble shooting.
> > [0]PETSC ERROR: Petsc Release Version 3.18.1, unknown 
> > [0]PETSC ERROR: ./vecerror on a arch-ecrcml-double-debug named localhost.localdomain by szampini Fri Nov  4 12:01:33 2022
> > [0]PETSC ERROR: Configure options ...
> > [0]PETSC ERROR: #1 PetscTrFreeDefault() at /home/szampini/Devel/miniforge/Devel/petsc/src/sys/memory/mtr.c:305
> > [0]PETSC ERROR: #2 VecDestroy_Seq() at /home/szampini/Devel/miniforge/Devel/petsc/src/vec/vec/impls/seq/bvec2.c:753
> > [0]PETSC ERROR: #3 VecDestroy() at /home/szampini/Devel/miniforge/Devel/petsc/src/vec/vec/interface/vector.c:521
> > [0]PETSC ERROR: #4 main() at /home/szampini/Devel/petscexamples/debugging/vecerror.c:22
> > [0]PETSC ERROR: Reached the main program with an out-of-range error code 1. This should never happen
> > 
> > -- 
> > Stefano
> 



More information about the petsc-dev mailing list