From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 36491 invoked by alias); 2 Mar 2018 03:32:12 -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 35285 invoked by uid 89); 2 Mar 2018 03:32:12 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.0 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:1917 X-HELO: rock.gnat.com Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 02 Mar 2018 03:32:10 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 7E4F156106; Thu, 1 Mar 2018 22:32:09 -0500 (EST) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id w9dUUqhYZRxH; Thu, 1 Mar 2018 22:32:09 -0500 (EST) Received: from joel.gnat.com (localhost.localdomain [127.0.0.1]) by rock.gnat.com (Postfix) with ESMTP id 21A4656105; Thu, 1 Mar 2018 22:32:09 -0500 (EST) Received: by joel.gnat.com (Postfix, from userid 1000) id BA42E83301; Fri, 2 Mar 2018 07:32:04 +0400 (+04) Date: Fri, 02 Mar 2018 03:32:00 -0000 From: Joel Brobecker To: Alan Hayward Cc: "gdb-patches@sourceware.org" , nd Subject: Re: [PATCH PR gdb/22736] [aarch64] gdb crashes on a conditional breakpoint with cast return type Message-ID: <20180302033204.v2wvjmquwy3dswyk@adacore.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20170113 (1.7.2) X-SW-Source: 2018-03/txt/msg00045.txt.bz2 On Thu, Mar 01, 2018 at 05:03:44PM +0000, Alan Hayward wrote: > On aarch64, the (int) casting in the following causes a gdb segfault: > $ ./gdb ./gdb > (gdb) b dwarf2_physname if (int)strcmp (name, "another_thread_local") == 0 > (gdb) run a.out // use any a.out > > This is due to getting a null pointer from TYPE_TARGET_TYPE, and then > using it for language_pass_by_reference(). > > Fixed by adding a null check, similar to other occurrences in gdb. > > Tested on aarch64 with make check using unix, native_gdbserver. > > Alan. > > > 2018-03-01 Alan Hayward > > * aarch64-tdep.c (aarch64_push_dummy_call): Check for null > return_type. The patch looks good to me, but do you think you could add a test for it? Intuitively, I think this should be fairly easily doable, but can you confirm? > diff --git a/gdb/aarch64-tdep.c b/gdb/aarch64-tdep.c > index f08945ea07101e1cd7906ca640c023ac7d189dd9..ef982c78fe64ceef3c7c378fd22d76604bf81c31 100644 > --- a/gdb/aarch64-tdep.c > +++ b/gdb/aarch64-tdep.c > @@ -1382,7 +1382,7 @@ aarch64_push_dummy_call (struct gdbarch *gdbarch, struct value *function, > struct aarch64_call_info info; > struct type *func_type; > struct type *return_type; > - int lang_struct_return; > + int lang_struct_return = 0; > > memset (&info, 0, sizeof (info)); > > @@ -1424,7 +1424,8 @@ aarch64_push_dummy_call (struct gdbarch *gdbarch, struct value *function, > given an additional initial argument, a hidden pointer to the > return slot in memory. */ > return_type = TYPE_TARGET_TYPE (func_type); > - lang_struct_return = language_pass_by_reference (return_type); > + if (return_type != nullptr) > + lang_struct_return = language_pass_by_reference (return_type); > > /* Set the return address. For the AArch64, the return breakpoint > is always at BP_ADDR. */ > -- Joel