From: Dave Hayden (dave_at_xpedite.com)
Date: Thu Mar 16 2000 - 14:51:43 GMT
Since UPS is no worse than any other debugger in handling this sort of error, I don't think your friend's argument holds much water. I suppose a debugger could be configured with some sort of high water mark for the stack. If the stack grows beyond the high water mark, it would halt execution and print some sort of warning message. The real killer here would be figuring out how to check the stack at the right places. Here's what I do to diagnose infinite recursion. First, if the program crashes and ups can't make sense of the stack, then I suspect stack corruption or infinite recursion. I use ups on solaris, which has an 8MB stack by default, so it takes most programs a long time to blow the stack away through infinite recursion. I take advantage of this by running the program and stopping it sometime *before* the stack is blown away. A huge stack trace indicates infinite recursion and gives lots (and lots and lots :) ) of cases of the bad call to help me diagnose the problem. Finally, let me suggest a trick to avoid infinite recursion in the first place. Whenever I code a recursive function, I always write it like this: if this is the base case then process it return else do the recursive case This structure usually prevents the sort of bugs that lead to infinite recursion. Dave Hayden bob_at_fla.fujitsu.com (Bob Carragher) writes: > Hi there, > > A friend of mine (whom I've been trying to convert to using > UPS) suggested that if UPS could handle infinite recursion > gracefully then he'd convert. > > Specifically, when a program experiences infinite recursion, > the call stack becomes corrupted. Any debugger that is used > to examine the resulting core file is helpless, since the > pre-garbage stack cannot (usually) be reconstructed. Also, > most debuggers will not stop the corruption before it happens. > Thus, even if I start the program under UPS, it will not stop > before it loses track of the stack. > > What I'm wondering is whether it is possible to catch this > event with some signal before it happens? I did a quick > check under signal(5) (Solaris 2.x), but found nothing that > addressed this specific problem. Is this one of those problems > that goes beyond the abilities of debuggers (under Unix > systems)? > > Thanks! > > Bob >
This archive was generated by hypermail 2.1.4 : Wed Feb 13 2002 - 21:51:33 GMT