From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 69748 invoked by alias); 6 Sep 2019 16:42:03 -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 69740 invoked by uid 89); 6 Sep 2019 16:42:03 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-6.8 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_2,GIT_PATCH_3,SPF_HELO_PASS autolearn=ham version=3.3.1 spammy= X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 06 Sep 2019 16:42:02 +0000 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 20CB6308FE9A; Fri, 6 Sep 2019 16:42:01 +0000 (UTC) Received: from theo.uglyboxes.com (ovpn-117-224.phx2.redhat.com [10.3.117.224]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E19B15D9D3; Fri, 6 Sep 2019 16:42:00 +0000 (UTC) Subject: Re: Fix a crash in compile_to_object function To: libor.bukata@oracle.com, gdb-patches@sourceware.org References: <3ad99625-43ff-a450-6e50-d83242224443@oracle.com> From: Keith Seitz Message-ID: <1742a18e-dfcb-6d80-03cc-5696a0cd3cd3@redhat.com> Date: Fri, 06 Sep 2019 16:42:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <3ad99625-43ff-a450-6e50-d83242224443@oracle.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2019-09/txt/msg00068.txt.bz2 On 9/6/19 6:37 AM, libor.bukata@oracle.com wrote: > On non-Linux platforms, gdb crashes when compile command is issued > because of the null pointer in struct osabi_names gdb_osab. The attached > patch adds a check to avoid this crash and adds osabi name for Solaris. > However, there is probably more work required to enable compile feature > on Solaris (e.g., solaris_infcall_munmap) and other platforms. > Thank you for the patch! The compile feature, as you have discovered, needs much more testing on non-linux configurations. > --- gdb-8.3/gdb/compile/compile.c 2019-08-19 13:07:57.669785758 +0000 > +++ gdb-8.3/gdb/compile/compile.c 2019-08-19 13:07:33.865626973 +0000 > @@ -697,7 +697,7 @@ compile_to_object (struct command_line * > const char *arch_rx = gdbarch_gnu_triplet_regexp (gdbarch); > > /* Allow triplets with or without vendor set. */ > - triplet_rx = std::string (arch_rx) + "(-[^-]*)?-" + os_rx; > + triplet_rx = std::string (arch_rx) + "(-[^-]*)?-" + (os_rx ? : ""); > compiler->set_triplet_regexp (triplet_rx.c_str ()); > } I'm not sure about this. Should os_rx be NULL (which you've shown is possible for a number of configurations), this would leave triplet_rx as $ARCH(-[^-]*)?-", e.g., "x86_64(-[^-]*)?-". I would call that a malformed regexp for this purpose. While the plugin may handle that gracefully, this just doesn't seem very user-friendly to me, but I am not a maintainer, so you should definitely wait for a real maintainer to chime in. Otherwise, the only comments I have relate to > + triplet_rx = std::string (arch_rx) + "(-[^-]*)?-" + (os_rx ? : ""); We prefer explicit comparisons with NULL/nullptr. Omitting the true-case expression is unusual. Not invalid, but certainly unusual (in gdb). I find no uses of this idiom in our sources. I would prefer to see the more explicit os_rx != nullptr ? os_rx : "" but I'll let official maintainers chime in on this usage. I'm just as curious to see how others feel about it. Keith