On Tue, May 4, 2010 at 2:42 PM, Jed Brown <span dir="ltr"><<a href="mailto:jed@59a2.org">jed@59a2.org</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
PetscFunctionBegin has logic to to avoid overflowing the array, but the<br>
stack still gets skewed because PetscFunctionReturn always pops the<br>
stack. This is a problem because many simple examples already overflow<br>
the stack at some point, resulting in a truncated stack in the error<br>
messages. This macro is currently defined at 15, with fieldsplits and<br>
V-cycles, it's easy to exceed 30 frames.<br>
<br>
The stack skew problem could be overcome by introducing a new local<br>
variable with another level of nesting, something like<br>
<br>
#define PetscFunctionBegin { \<br>
PetscTruth _petscstackpushed = petscstack->currentsize < PETSCSTACKSIZE; \<br>
ExistingPetscFunctionBegin;<br>
<br>
#define PetscFunctionReturn(n) \<br>
{if (_petscstackpushed) PetscStackPop; return (n);} \<br>
}<br>
<br>
But I'm not a huge fan of doing this sort of thing with macros and it's<br></blockquote><div><br></div><div>I really hate variables in macros that are necessary in other macros. It so opaque.</div><div>I do not have a better solution.</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
still easy enough to get an error from deeper than 15 frames, so I want<br>
to increase the PETSCSTACKSIZE regardless of whether the macro hack<br>
above is also done. Is there a reason not to use a biggish number like<br>
50 or more?</blockquote><div><br></div><div>Yep, we should increase it to 64.</div><div><br></div><div> Matt</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<font color="#888888"><br>
Jed</font></blockquote></div>-- <br>What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>-- Norbert Wiener<br>