Re: UPS and infinite recursion

From: Jeremy Carroll (
Date: Fri Mar 17 2000 - 09:32:31 GMT

"Terry R. Friedrichsen" wrote:
> I had pointed out that running the infinite-recursion program
> under either FreeBSD or Linux (not under UPS) created a core
> file which gdb(1) had no trouble interpreting.  It did, in
> fact, report meaningfully about the call stack.

This sounds to me to be either quite a lot of work, or to be dependent
on otherwise unnecesary data in the stack.

Each stack frame is of variable width and the stack pointer points to
the current frame.
Each frame includes the value of the previous stack pointer (but not the
Thus to get from the current frame back up the stack, [upStack] it is
just a question of following the pointers.
To go the other way [downStack] you have to search down looking for a
pointer that might be pointing up to you, and hope it's the right one.
(There should be a lot of supporting evidence, but its an [unsound]
abductive argument from effect to cause rather than deductive).

In the infinite recursion case the current frame is corrupt and hence

With some OSs there may be superfluous information in the stack frame
that lets us go the other way.


There are two possibilities.
Either we start at the beginning of the stack and search down it to find
all the back-pointers, by repeatedly doing the downStack procedure.
Alternatively, we can start at the end of the stack, use some heuristics
not dissimilar to the downStack ones, to find a frame very close to the
bug. We can then use the upStack procedure from there.
[One approach would be:
+ have a safeAllTheWayUpStack procedure that was very careful (about
null pointers and other bad values) and returned a success or failure
code to indicate that it managed to decode stack frames. This takes a
stackPointer as an initial argument.
+ Try safeAllTheWayUpStack repeatedly with different values of
stackPointer near the end of the stack until it works.

I guess somebody ought to look at the GDB code. I am not volunteering.

Jeremy Carroll


Private message, not an official communication from HP.

This archive was generated by hypermail 2.1.4 : Wed Feb 13 2002 - 21:51:33 GMT