From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 78263 invoked by alias); 7 Apr 2015 14:41:35 -0000 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 Received: (qmail 78254 invoked by uid 89); 7 Apr 2015 14:41:34 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.7 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_LOW,SPF_SOFTFAIL autolearn=no version=3.3.2 X-HELO: mail-la0-f52.google.com Received: from mail-la0-f52.google.com (HELO mail-la0-f52.google.com) (209.85.215.52) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Tue, 07 Apr 2015 14:41:34 +0000 Received: by lagv1 with SMTP id v1so43810746lag.3 for ; Tue, 07 Apr 2015 07:41:30 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-type:content-transfer-encoding; bh=7XKOqV/CLTeVwguvIZ+sSI4t1STcBHt5JNdyKpvjyPg=; b=av0LW84RUzbyST5ENIsMBYJ/8rf4L5sIfMC9iSkVkYfoNC8kY46ZiKJcGcJSKFjaSj uGvTHCx6Ht0lyA6MOBhEh1LNf61vA3HsKeQF/H6Cxo/TdRdx/heQKyEzyXuTjPrTkE0H 0tfELqU8vt+u7TxCLz4TMBHdAQGJpbSvnW0v8bo8bQbGK1Qk5d4DYlzWdbaaFK94Nw4O GMhbFjfgnN1o6YZ2IXlf0m1+wPrm2mHtrChPOvNV/PtINzUDsQXILuvOiYNDz4zK5f2K IshVO/QdlsOAEenKtJjK2MjTcMy9X5pyfxjYHctS6B0fKS9WHd+nUizbnoQKwLkTgFDR XHeA== X-Gm-Message-State: ALoCoQmOCrTO1H9gpAufzjjyAwSY5BkmauneAersNlHsWGaMXDVDclScETAB7molXFb2rjJ78okB X-Received: by 10.112.230.37 with SMTP id sv5mr18103560lbc.85.1428417689946; Tue, 07 Apr 2015 07:41:29 -0700 (PDT) MIME-Version: 1.0 Received: by 10.112.52.42 with HTTP; Tue, 7 Apr 2015 07:40:49 -0700 (PDT) In-Reply-To: <5523EACF.2070108@redhat.com> References: <1428415783-15199-1-git-send-email-martin.galvan@tallertechnologies.com> <5523EACF.2070108@redhat.com> From: Martin Galvan Date: Tue, 07 Apr 2015 14:41:00 -0000 Message-ID: Subject: Re: [PATCH] Fix gdb crash when trying to print the address of a synthetic pointer. To: Pedro Alves Cc: gdb-patches Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-SW-Source: 2015-04/txt/msg00229.txt.bz2 On Tue, Apr 7, 2015 at 11:33 AM, Pedro Alves wrote: > Hi Martin, > > On 04/07/2015 03:09 PM, Martin Galvan wrote: >> Trying to print the address of a synthetic pointer (such as a C++ refere= nce after O3 optimization) will cause gdb to crash with the following messa= ge: >> >> ../gdb/dwarf2loc.c:1625: internal-error: Should not be able to create a = lazy value with an enclosing type >> >> This patch fixes that by doing a check for synthetic pointers in value_a= ddr and printing an error message. >> >> I have a company-wide copyright assignment. I don't have commit access, = though, so it would be great if anyone could commit this for me. >> > > Does this pass the testsuite? I seem to recall that the > TYPE_CODE_REF path below is used by synthetic pointers, but > I could well be wrong. For some reason this problem doesn't happen with some synthetic pointers, such as the "this" pointer in C++ (I assume those are handled by the TYPE_CODE_REF path). However, I can confirm this happens with C++ references if optimizing with gcc -O3. > Could you add some test to cover this? We have some pointer> tests in gdb.dwarf2/implptr.exp. Maybe add something there? Ok, will do it. >> gdb/ >> 2015-04-07 Martin Galvan > > Two spaces before and after name. > >> >> * valops.c (value_addr): Don't try to get the address of a synthet= ic pointer. > > Please wrap this at 80 cols. > >> >> --- >> gdb/valops.c | 7 +++++++ >> 1 file changed, 7 insertions(+) >> >> diff --git a/gdb/valops.c b/gdb/valops.c >> index 66c63c1..66e2c9d 100644 >> --- a/gdb/valops.c >> +++ b/gdb/valops.c >> @@ -1474,6 +1474,13 @@ value_addr (struct value *arg1) >> struct value *arg2; >> struct type *type =3D check_typedef (value_type (arg1)); >> >> + if (value_bits_synthetic_pointer(arg1, value_embedded_offset (arg1), > > Missing space before parens. > >> + TARGET_CHAR_BIT * TYPE_LENGTH (type))) >> + { >> + error (_("Attempt to take address of a synthetic pointer.")); >> + return NULL; > > This "return" is never reached, as "error" throws. Please remove it, > and then remove the then unnecessary braces. Will do. Thanks a lot! --=20 Martin Galvan Software Engineer Taller Technologies Argentina San Lorenzo 47, 3rd Floor, Office 5 C=C3=B3rdoba, Argentina Phone: 54 351 4217888 / +54 351 4218211