From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 749 invoked by alias); 3 Mar 2013 22:53:33 -0000 Received: (qmail 736 invoked by uid 22791); 3 Mar 2013 22:53:31 -0000 X-SWARE-Spam-Status: No, hits=-6.4 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,KHOP_SPAMHAUS_DROP,RCVD_IN_DNSWL_HI,RCVD_IN_HOSTKARMA_W,RP_MATCHES_RCVD,SPF_HELO_PASS,TW_XZ,TW_YM 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; Sun, 03 Mar 2013 22:53:23 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r23MrNF2031460 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Sun, 3 Mar 2013 17:53:23 -0500 Received: from psique (ovpn-113-39.phx2.redhat.com [10.3.113.39]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r23MrKx5009038 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO) for ; Sun, 3 Mar 2013 17:53:22 -0500 From: Sergio Durigan Junior To: gdb-patches@sourceware.org Subject: Re: [patch] Fix crash in read_pe_exported_syms References: <20130302110216.GA6765@calimero.vinschen.de> X-URL: http://www.redhat.com Date: Sun, 03 Mar 2013 22:53:00 -0000 In-Reply-To: <20130302110216.GA6765@calimero.vinschen.de> (Corinna Vinschen's message of "Sat, 2 Mar 2013 12:02:16 +0100") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain 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: 2013-03/txt/msg00074.txt.bz2 On Saturday, March 02 2013, Corinna Vinschen wrote: > Hi, Hi Corinna, > when running GDB from current CVS on a PE/COFF target, and if this > target has no debug symbols, nor any exported symbols, then GDB crashes > with a SEGV in the first do_cleanup called from coff_symfile_read. > > The reason is that read_pe_exported_syms creates two cleanup handlers, > one of them referring to a symbol on the local stack: > > struct read_pe_section_data *section_data; > [...] > section_data = xzalloc (...) > make_cleanup (free_current_contents, §ion_data); > > but then returns from the function early in three different scenarios > without calling do_cleanup. The subsequent do_cleanup call in > coff_symfile_read now tries to dereference from an invalid stack address > and ultimately crashes. > > Below is a patch. Ok to apply? [I am not a maintainer.] You are right, the function returns without taking care of the possible cleanups. IMO the patch is almost obvious, but thanks anyway for sending it here. I don't want to create a flamewar here, but ISTR that the use of `goto' is discouraged in GDB/GNU. I remember I submitted a patch once that made use of `goto' in a similar way that you are doing here, and I was asked to rewrite it. Anyway, recently I faced a similar issue (i.e., having to call `do_cleanup' in several places, and what I did was to actually call it in all those places instead of using `goto'. You might want to wait until a global maintainer emits some opinion about this. Thanks, -- Sergio