From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 917 invoked by alias); 9 Apr 2002 21:01:41 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 900 invoked from network); 9 Apr 2002 21:01:39 -0000 Received: from unknown (HELO cygnus.com) (205.180.230.5) by sources.redhat.com with SMTP; 9 Apr 2002 21:01:39 -0000 Received: from theotherone.redhat-remotie.org (taarna.sfbay.redhat.com [205.180.230.102]) by runyon.cygnus.com (8.8.7-cygnus/8.8.7) with ESMTP id OAA25679; Tue, 9 Apr 2002 14:01:37 -0700 (PDT) Received: from localhost (localhost.fidalgo.net [127.0.0.1]) by theotherone.redhat-remotie.org (Postfix) with ESMTP id 50354BB255; Tue, 9 Apr 2002 14:01:13 -0700 (PDT) Date: Tue, 09 Apr 2002 14:01:00 -0000 From: Don Howard X-X-Sender: To: Andreas Schwab Cc: Michael Snyder , , Subject: Re: [RFA] Avoid recursivly defined user functions. In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-SW-Source: 2002-04/txt/msg00373.txt.bz2 On Thu, 4 Apr 2002, Andreas Schwab wrote: > Michael Snyder 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