This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
Re: [RFA] Avoid recursivly defined user functions.
- From: Don Howard <dhoward at redhat dot com>
- To: Andreas Schwab <schwab at suse dot de>
- Cc: Michael Snyder <msnyder at redhat dot com>, <Hilfinger at cs dot berkeley dot edu>, <gdb-patches at sources dot redhat dot com>
- Date: Tue, 9 Apr 2002 14:01:13 -0700 (PDT)
- Subject: Re: [RFA] Avoid recursivly defined user functions.
On Thu, 4 Apr 2002, Andreas Schwab wrote:
> Michael Snyder <msnyder@redhat.com> writes:
>
> |> Paul Hilfinger wrote:
> |> >
> |> > > Executing a recursively defined user function results in a core-dump from
> |> > > gdb:
> |> >
> |> > ...
> |> >
> |> > > The following patch catches recursive user function definitions and
> |> > > disallowes them:
> |> >
> |> > Is the segmentation fault the result of stack overflow?
> |>
> |> Yes it is.
> |>
> |> > If so, I
> |> > point out that there is an 'if' statement, so recursive commands are
> |> > not necessarily wrong, are they?
> |>
> |> No they're not. So it's a judgement call. Is it more important
> |> to allow recursive macros, or to prevent GDB from dumping core?
> |> We're basically running an interpreter here...
> |>
> |> I guess one thing we could do would be to impose an arbitrary
> |> (possibly user-settable) stack depth limit. That's more work,
> |> of course...
>
> The simple minded check in Don's patch won't catch many cases of infinite
> recursion anyway (mutual recursion, command invocation with arguments).
>
I think I can detect mutual recursion by walking through the body of each
user-defined command (recursivly). This amounts to static recursion
detection.
I think I could track simple recursion depth at runtime.
I don't see how to track mutual recursion depth at runtime. Maybe do the
static recursion detection and recursivly flag user-defined commands in
the body?
Can you explain what you mean by "command invocation with arguments"?
--
dhoward@redhat.com
gdb engineering