From patchwork Fri Sep 6 13:37:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: libor.bukata@oracle.com X-Patchwork-Id: 34408 Received: (qmail 57918 invoked by alias); 6 Sep 2019 13:37:40 -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 57910 invoked by uid 89); 6 Sep 2019 13:37:40 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-4.1 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: aserp2120.oracle.com Received: from aserp2120.oracle.com (HELO aserp2120.oracle.com) (141.146.126.78) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 06 Sep 2019 13:37:39 +0000 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x86DbPoI175700 for ; Fri, 6 Sep 2019 13:37:37 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=to : from : subject : message-id : date : mime-version : content-type; s=corp-2019-08-05; bh=uf+3U1Sb1XbfkvRPoeJRN0gTpr9PQ93ag+ZHc/RI/5M=; b=ebCTLt1sKY0Kdh1+ft2onbsDBhoR6celKFipcmDt4jN9BjIBgxkeBL4c0Wcv9jrOdwQe M+wC6hwhgVYYFpeiQb9AnNx3JE9e/ANnS+XnPqHe1gn5LrArbS+pgSfn4av5KZRuOa2I q+0cgrJUxtx8vzU1nSMuZEzPFsDrpgyssMpYgdJBYjveOfcMp4KYdlx20ar8m5+2xGTW Su+gHjGvK9aj6n+yEpTpFlZC08i/ZJMgJbJQ8ufkl4GtWaTdqvF5FqsL4z5LMM0bYNIq 4IwIQHNjZU+qJnS/BjAoFOsKZjxm1AjKXi3SHtGWJn9A0ToHz3QhXj3ibsFXmTdNsYRY /A== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by aserp2120.oracle.com with ESMTP id 2uur9dg2y3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 06 Sep 2019 13:37:37 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x86DXrgf098487 for ; Fri, 6 Sep 2019 13:37:36 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserp3020.oracle.com with ESMTP id 2uud7phesm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 06 Sep 2019 13:37:36 +0000 Received: from abhmp0020.oracle.com (abhmp0020.oracle.com [141.146.116.26]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x86DbZLe018938 for ; Fri, 6 Sep 2019 13:37:35 GMT Received: from [10.175.31.40] (/10.175.31.40) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 06 Sep 2019 06:37:35 -0700 To: gdb-patches@sourceware.org From: libor.bukata@oracle.com Subject: Fix a crash in compile_to_object function Message-ID: <3ad99625-43ff-a450-6e50-d83242224443@oracle.com> Date: Fri, 6 Sep 2019 15:37:33 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 X-IsSubscribed: yes 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. Thanks, Libor The patch fixes the crash on non-Linux platforms when os_rx is a null pointer and converted to C++ std::string. --- gdb-8.3/gdb/osabi.c 2019-08-19 11:15:04.176948730 +0000 +++ gdb-8.3/gdb/osabi.c 2019-08-19 11:13:43.202284584 +0000 @@ -63,7 +63,7 @@ static const struct osabi_names gdb_osab { "SVR4", NULL }, { "GNU/Hurd", NULL }, - { "Solaris", NULL }, + { "Solaris", "solaris[2-9]\.[0-9][0-9]" }, { "GNU/Linux", "linux(-gnu[^-]*)?" }, { "FreeBSD", NULL }, { "NetBSD", NULL }, --- 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 ()); }