This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
Re: [RFA]: Fix do_cleanups if oldchain is NULL
- From: Daniel Jacobowitz <drow at mvista dot com>
- To: gdb-patches at sources dot redhat dot com
- Date: Fri, 2 Jan 2004 12:51:38 -0500
- Subject: Re: [RFA]: Fix do_cleanups if oldchain is NULL
- References: <3FE0C502.7020408@redhat.com> <3FF59719.7020908@gnu.org>
On Fri, Jan 02, 2004 at 11:06:49AM -0500, Andrew Cagney wrote:
> >I recently solved a bug on the ia64 concerning cleanups. What was
> >happening was that a cleanup list was being re-initialized to NULL inside
> >a loop and later do_cleanups() was called. This caused the entire cleanup
> >list to be run because the design is to run the list until the passed in
> >cleanup is reached. This caused other errors when the stream being used
> >was deleted, etc...
> >
> >This patch adds a check to do_my_cleanups() so no cleanups will be
> >performed if the passed in chain is NULL.
> >
> >Ok to commit?
>
> (hmm, no one thought to review this while I was on hols :-()
Sorry, I was holding off on reviewing other people's patches during my vacation
so that I could catch up on my own.
> I think the bug is in the calling code, and not utils.c. That patch
> unfortunatly makes a fundamental change to the core of the cleanup code
> and there's no easy way of demonstrating that other callers aren't
> assuming that NULL implies do all cleanups.
How about making NULL an internal error then, as below? I think we
should either do that or document its behavior, and it seems
accident-prone.
--
Daniel Jacobowitz
MontaVista Software Debian GNU/Linux Developer
2003-01-02 Daniel Jacobowitz <drow@mvista.com>
* utils.c (do_my_cleanups): Raise an internal error if the old_chain
is NULL.
Index: utils.c
===================================================================
RCS file: /cvs/src/src/gdb/utils.c,v
retrieving revision 1.111
diff -u -p -r1.111 utils.c
--- utils.c 2 Jan 2004 17:35:01 -0000 1.111
+++ utils.c 2 Jan 2004 17:49:37 -0000
@@ -1,8 +1,8 @@
/* General utility routines for GDB, the GNU debugger.
Copyright 1986, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995,
- 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003 Free Software
- Foundation, Inc.
+ 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
+ Free Software Foundation, Inc.
This file is part of GDB.
@@ -318,6 +318,11 @@ do_my_cleanups (struct cleanup **pmy_cha
struct cleanup *old_chain)
{
struct cleanup *ptr;
+
+ if (old_chain == NULL)
+ internal_error (__FILE__, __LINE__,
+ "NULL chain passed to do_my_cleanups");
+
while ((ptr = *pmy_chain) != old_chain)
{
*pmy_chain = ptr->next; /* Do this first incase recursion */