PetscFunctionBegin has logic to to avoid overflowing the array, but the
stack still gets skewed because PetscFunctionReturn always pops the
stack.  This is a problem because many simple examples already overflow
the stack at some point, resulting in a truncated stack in the error
messages.  This macro is currently defined at 15, with fieldsplits and
V-cycles, it's easy to exceed 30 frames.

The stack skew problem could be overcome by introducing a new local
variable with another level of nesting, something like

#define PetscFunctionBegin {  \
    PetscTruth _petscstackpushed = petscstack->currentsize < PETSCSTACKSIZE; \
    ExistingPetscFunctionBegin;

#define PetscFunctionReturn(n) \
    {if (_petscstackpushed) PetscStackPop; return (n);} \
  }

But I'm not a huge fan of doing this sort of thing with macros and it's
still easy enough to get an error from deeper than 15 frames, so I want
to increase the PETSCSTACKSIZE regardless of whether the macro hack
above is also done.  Is there a reason not to use a biggish number like
50 or more?

Jed

Reply via email to