From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6087 invoked by alias); 2 Sep 2011 20:17:44 -0000 Received: (qmail 6078 invoked by uid 22791); 2 Sep 2011 20:17:39 -0000 X-SWARE-Spam-Status: No, hits=-5.8 required=5.0 tests=AWL,BAYES_20,RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,SPF_HELO_PASS X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 02 Sep 2011 20:17:20 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p82KHJg2032264 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 2 Sep 2011 16:17:19 -0400 Received: from host1.jankratochvil.net (ovpn-116-38.ams2.redhat.com [10.36.116.38]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p82KHHIE013540 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Fri, 2 Sep 2011 16:17:19 -0400 Received: from host1.jankratochvil.net (localhost [127.0.0.1]) by host1.jankratochvil.net (8.14.4/8.14.4) with ESMTP id p82KHGxo016886; Fri, 2 Sep 2011 22:17:16 +0200 Received: (from jkratoch@localhost) by host1.jankratochvil.net (8.14.4/8.14.4/Submit) id p82KHFvR016885; Fri, 2 Sep 2011 22:17:15 +0200 Date: Fri, 02 Sep 2011 20:45:00 -0000 From: Jan Kratochvil To: Aleksandar Ristovski Cc: gdb-patches@sources.redhat.com Subject: Re: dangling pointer in so_list Message-ID: <20110902201715.GA16280@host1.jankratochvil.net> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2011-09/txt/msg00042.txt.bz2 On Fri, 02 Sep 2011 15:06:34 +0200, Aleksandar Ristovski wrote: > --- gdb/solib.c 30 Aug 2011 02:48:05 -0000 1.153 > +++ gdb/solib.c 1 Sep 2011 19:56:37 -0000 > @@ -633,6 +633,23 @@ solib_read_symbols (struct so_list *so, > return 0; > } > > +/* Return 1 if KNOWN->objfile is used by any other so_list object in the > + HEAD list. Return 0 otherwise. */ > + > +static int > +used (const struct so_list *const known, const struct so_list *const head) > +{ > + const struct so_list *pivot; > + int found = 0; > + > + for (pivot = head; pivot != NULL && !found; pivot = pivot->next) > + { > + if (pivot != known && pivot->objfile == known->objfile) > + found = 1; > + } > + return found; > +} static int solist_used (const struct so_list *const known) { const struct so_list *so; for (so = so_list_head; so != NULL; so = so->next) if (so != known && so->objfile == known->objfile) return 1; return 0; } (untested for consts) I find both the `head' (we are on solib.c) and `found' variables needless there. Use some solib-identifying name (such as the common solib_ prefix). OK without the `head' parameter and with the solib_ prefix. GNU/Linux compatible testcase is probably not possible, one would need two loaded solibs with the same vaddr of their `.text' section. Thanks, Jan