From patchwork Thu Feb 27 22:11:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Aaron Merey X-Patchwork-Id: 38342 Received: (qmail 86065 invoked by alias); 27 Feb 2020 22:12:07 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 86055 invoked by uid 89); 27 Feb 2020 22:12:07 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 spammy= X-HELO: us-smtp-delivery-1.mimecast.com Received: from us-smtp-2.mimecast.com (HELO us-smtp-delivery-1.mimecast.com) (205.139.110.61) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 27 Feb 2020 22:12:05 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1582841524; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=M6OtAoaxxypAUxPgnTSjzZufKSpnZ4AJxgxSUMUh0UM=; b=NXkvwtw+UWju/qYsH7bZKCinYK19CAQzrKI1klzYp64btV6pixz8DX68/HYcw/iVYbTxvE 77sBX2CXPY+pUjpvdb7VH7ubYc2m6HVRGN5olb2XLkPolHKH1j3s6uxnuFJtLRzGhDSNJK YAOlh9JJ9uMXUea8MBPB2YtxV8BYjnQ= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-106-6p2e6ABSPNGqGBuJ7f6EqA-1; Thu, 27 Feb 2020 17:11:59 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3B2ED19057A0; Thu, 27 Feb 2020 22:11:58 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-125-71.rdu2.redhat.com [10.10.125.71]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6B1E5909FA; Thu, 27 Feb 2020 22:11:57 +0000 (UTC) From: Aaron Merey To: gdb-patches@sourceware.org, simark@simark.ca, cbiesinger@google.com Subject: Re: [PATCH] gdb: Check for nullptr when computing srcpath Date: Thu, 27 Feb 2020 17:11:56 -0500 Message-Id: <20200227221156.1248760-1-amerey@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com On Thu, Feb 27, 2020 at 2:18 PM Simon Marchi wrote: > Please provide in the commit message an explanation of what this fixes, including > how to reproduce the crash.  Since this fixes the execution of an existing test > case, you can include the "make check" command line used to run it, like: > >   make check TESTS="gdb.dwarf2/dw2-ranges-base" Fixed. > Also, do you think you'd be able to send your patches using git-send-email? That makes > it much easier to read and comment on. Sure. On Thu, Feb 27, 2020 at 2:33 PM Christian Biesinger wrote: > +   if (build_id != nullptr && srcpath.size () > 0) > > I usually prefer !srcpath.empty () Fixed. Aaron From d048f84f027006782cd96dc66a10477ed5a78243 Mon Sep 17 00:00:00 2001 From: Aaron Merey Date: Thu, 27 Feb 2020 15:51:11 -0500 Subject: [PATCH] gdb: Check for nullptr when computing srcpath This fixes a regression caused by commit 0d79cdc494d5: $ make check TESTS="gdb.dwarf2/dw2-ranges-base.exp" [...] ERROR: GDB process no longer exists This error is caused by an abort during the computation of srcpath when SYMTAB_DIRNAME (s) == NULL. Computing srcpath only when SYMTAB_DIRNAME (s) is not NULL fixes this error. Also change the condition for calling debuginfod_source_query to include whether srcpath could be computed. gdb/ChangeLog: 2020-02-27 Aaron Merey * source.c (open_source_file): Check for nullptr when computing srcpath. --- gdb/ChangeLog | 4 ++++ gdb/source.c | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 4376161673..371ef91421 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,7 @@ +2020-02-27 Aaron Merey + * source.c (open_source_file): Check for nullptr when computing + srcpath. + 2020-02-27 Andrew Burgess * gdbtypes.c (create_array_type_with_stride): Use std::abs not diff --git a/gdb/source.c b/gdb/source.c index 051caf5c57..50de93952b 100644 --- a/gdb/source.c +++ b/gdb/source.c @@ -1160,7 +1160,7 @@ open_source_file (struct symtab *s) std::string srcpath; if (IS_ABSOLUTE_PATH (s->filename)) srcpath = s->filename; - else + else if (SYMTAB_DIRNAME (s) != nullptr) { srcpath = SYMTAB_DIRNAME (s); srcpath += SLASH_STRING; @@ -1170,7 +1170,7 @@ open_source_file (struct symtab *s) const struct bfd_build_id *build_id = build_id_bfd_get (ofp->obfd); /* Query debuginfod for the source file. */ - if (build_id != nullptr) + if (build_id != nullptr && !srcpath.empty ()) fd = debuginfod_source_query (build_id->data, build_id->size, srcpath.c_str (),