{"id":813926,"url":"http://patchwork.ozlabs.org/api/patches/813926/?format=json","web_url":"http://patchwork.ozlabs.org/project/gcc/patch/1505419774-35690-1-git-send-email-dmalcolm@redhat.com/","project":{"id":17,"url":"http://patchwork.ozlabs.org/api/projects/17/?format=json","name":"GNU Compiler Collection","link_name":"gcc","list_id":"gcc-patches.gcc.gnu.org","list_email":"gcc-patches@gcc.gnu.org","web_url":null,"scm_url":null,"webscm_url":null,"list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<1505419774-35690-1-git-send-email-dmalcolm@redhat.com>","list_archive_url":null,"date":"2017-09-14T20:09:34","name":"[committed] Fix crash accessing builtins in sanitizer.def and after (PR jit/82174)","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"f939a84886b40c90d169d71fdad2a23cc63fc3d3","submitter":{"id":24465,"url":"http://patchwork.ozlabs.org/api/people/24465/?format=json","name":"David Malcolm","email":"dmalcolm@redhat.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/gcc/patch/1505419774-35690-1-git-send-email-dmalcolm@redhat.com/mbox/","series":[{"id":3153,"url":"http://patchwork.ozlabs.org/api/series/3153/?format=json","web_url":"http://patchwork.ozlabs.org/project/gcc/list/?series=3153","date":"2017-09-14T20:09:34","name":"[committed] Fix crash accessing builtins in sanitizer.def and after (PR jit/82174)","version":1,"mbox":"http://patchwork.ozlabs.org/series/3153/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/813926/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/813926/checks/","tags":{},"related":[],"headers":{"Return-Path":"<gcc-patches-return-462171-incoming=patchwork.ozlabs.org@gcc.gnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":["patchwork-incoming@bilbo.ozlabs.org","mailing list gcc-patches@gcc.gnu.org"],"Authentication-Results":["ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org\n\t(client-ip=209.132.180.131; helo=sourceware.org;\n\tenvelope-from=gcc-patches-return-462171-incoming=patchwork.ozlabs.org@gcc.gnu.org;\n\treceiver=<UNKNOWN>)","ozlabs.org; dkim=pass (1024-bit key;\n\tunprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org\n\theader.b=\"ZmvNh59t\"; dkim-atps=neutral","sourceware.org; auth=none","ext-mx08.extmail.prod.ext.phx2.redhat.com;\n\tdmarc=none (p=none dis=none) header.from=redhat.com","ext-mx08.extmail.prod.ext.phx2.redhat.com;\n\tspf=fail smtp.mailfrom=dmalcolm@redhat.com"],"Received":["from sourceware.org (server1.sourceware.org [209.132.180.131])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256\n\tbits)) (No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xtTGY47Zzz9s7M\n\tfor <incoming@patchwork.ozlabs.org>;\n\tFri, 15 Sep 2017 05:33:24 +1000 (AEST)","(qmail 74989 invoked by alias); 14 Sep 2017 19:33:16 -0000","(qmail 74970 invoked by uid 89); 14 Sep 2017 19:33:15 -0000","from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by\n\tsourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP;\n\tThu, 14 Sep 2017 19:33:14 +0000","from smtp.corp.redhat.com\n\t(int-mx03.intmail.prod.int.phx2.redhat.com\n\t[10.5.11.13])\t(using TLSv1.2 with cipher AECDH-AES256-SHA\n\t(256/256 bits))\t(No client certificate requested)\tby\n\tmx1.redhat.com (Postfix) with ESMTPS id 76012C00477B;\n\tThu, 14 Sep 2017 19:33:13 +0000 (UTC)","from c64.redhat.com (ovpn-112-36.phx2.redhat.com [10.3.112.36])\tby\n\tsmtp.corp.redhat.com (Postfix) with ESMTP id 67EF86F12A;\n\tThu, 14 Sep 2017 19:33:12 +0000 (UTC)"],"DomainKey-Signature":"a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id\n\t:list-unsubscribe:list-archive:list-post:list-help:sender:from\n\t:to:cc:subject:date:message-id; q=dns; s=default; b=V1TIKUXGzB+v\n\tuCuOBwkPEI1H+HWzkoiaSLcXbIfsSSIkuSsOBslkvqPTr/WNxDWXh2mrBYzECp9z\n\tkSRPhxucibDPUxDX4mgnTFcKHdwZPO3VDsm27p6yyE4hYxBVs1AkLei+jXFMvj8t\n\tLYhqKpPKtWSbrtfU3/ZwvP2bPI4IjhE=","DKIM-Signature":"v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id\n\t:list-unsubscribe:list-archive:list-post:list-help:sender:from\n\t:to:cc:subject:date:message-id; s=default; bh=lhNiiNhUr//camMJnJ\n\tGSIfMXJ1o=; b=ZmvNh59tfkC7TNF2QX9SKbmWkBadse/DXXD4awvfvb32+lNEdD\n\tGYClXQX6R0E7Y/pfctJiBvMI4Ar2D+BoTbVd5LP0HaQ6lfIn/WPFGmA7CHZ1B/Zs\n\tlAguW2Ed5WQ11l7cdl+hkFua3VXsPkWkE97/rEweXJGl1ws0Q0xqI2cbM=","Mailing-List":"contact gcc-patches-help@gcc.gnu.org; run by ezmlm","Precedence":"bulk","List-Id":"<gcc-patches.gcc.gnu.org>","List-Unsubscribe":"<mailto:gcc-patches-unsubscribe-incoming=patchwork.ozlabs.org@gcc.gnu.org>","List-Archive":"<http://gcc.gnu.org/ml/gcc-patches/>","List-Post":"<mailto:gcc-patches@gcc.gnu.org>","List-Help":"<mailto:gcc-patches-help@gcc.gnu.org>","Sender":"gcc-patches-owner@gcc.gnu.org","X-Virus-Found":"No","X-Spam-SWARE-Status":"No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0,\n\tGIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RP_MATCHES_RCVD,\n\tSPF_HELO_PASS autolearn=ham version=3.3.2 spammy=","X-Spam-User":"qpsmtpd, 2 recipients","X-HELO":"mx1.redhat.com","DMARC-Filter":"OpenDMARC Filter v1.3.2 mx1.redhat.com 76012C00477B","From":"David Malcolm <dmalcolm@redhat.com>","To":"gcc-patches@gcc.gnu.org,\tjit@gcc.gnu.org","Cc":"David Malcolm <dmalcolm@redhat.com>","Subject":"[committed] Fix crash accessing builtins in sanitizer.def and after\n\t(PR jit/82174)","Date":"Thu, 14 Sep 2017 16:09:34 -0400","Message-Id":"<1505419774-35690-1-git-send-email-dmalcolm@redhat.com>","X-IsSubscribed":"yes"},"content":"Calls to gcc_jit_context_get_builtin_function that accessed builtins\nin sanitizer.def and after (or failed to match any builtin) led to\na crash accessing a NULL builtin name.\n\nThe entries with the NULL name came from these lines in sanitizer.def:\n\n  /* This has to come before all the sanitizer builtins.  */\n  DEF_BUILTIN_STUB(BEGIN_SANITIZER_BUILTINS, (const char *)0)\n\n  [...snip...]\n\n  /* This has to come after all the sanitizer builtins.  */\n  DEF_BUILTIN_STUB(END_SANITIZER_BUILTINS, (const char *)0)\n\nThis patch updates jit-builtins.c to cope with such entries, fixing the\ncrash.\n\nSuccessfully bootstrapped&regrtested on x86_64-pc-linux-gnu;\ntakes jit.sum from 9769 to 9789 PASS results.\n\nCommitted to trunk as r252769.\n\ngcc/jit/ChangeLog:\n\tPR jit/82174\n\t* jit-builtins.c (matches_builtin): Ignore entries with a NULL\n\tname.\n\ngcc/testsuite/ChangeLog:\n\tPR jit/82174\n\t* jit.dg/test-error-gcc_jit_context_get_builtin_function-unknown-builtin.c:\n\tNew test case.\n---\n gcc/jit/jit-builtins.c                             |  5 ++++-\n ..._context_get_builtin_function-unknown-builtin.c | 22 ++++++++++++++++++++++\n 2 files changed, 26 insertions(+), 1 deletion(-)\n create mode 100644 gcc/testsuite/jit.dg/test-error-gcc_jit_context_get_builtin_function-unknown-builtin.c","diff":"diff --git a/gcc/jit/jit-builtins.c b/gcc/jit/jit-builtins.c\nindex 7840915..35c4db0 100644\n--- a/gcc/jit/jit-builtins.c\n+++ b/gcc/jit/jit-builtins.c\n@@ -68,7 +68,10 @@ matches_builtin (const char *in_name,\n \t\t const struct builtin_data& bd)\n {\n   const bool debug = 0;\n-  gcc_assert (bd.name);\n+\n+  /* Ignore entries with a NULL name.  */\n+  if (!bd.name)\n+    return false;\n \n   if (debug)\n     fprintf (stderr, \"seen builtin: %s\\n\", bd.name);\ndiff --git a/gcc/testsuite/jit.dg/test-error-gcc_jit_context_get_builtin_function-unknown-builtin.c b/gcc/testsuite/jit.dg/test-error-gcc_jit_context_get_builtin_function-unknown-builtin.c\nnew file mode 100644\nindex 0000000..b1e389c\n--- /dev/null\n+++ b/gcc/testsuite/jit.dg/test-error-gcc_jit_context_get_builtin_function-unknown-builtin.c\n@@ -0,0 +1,22 @@\n+#include <stdlib.h>\n+#include <stdio.h>\n+\n+#include \"libgccjit.h\"\n+\n+#include \"harness.h\"\n+\n+void\n+create_code (gcc_jit_context *ctxt, void *user_data)\n+{\n+  gcc_jit_context_get_builtin_function (ctxt,\n+\t\t\t\t\t\"this_is_not_a_builtin\");\n+}\n+\n+void\n+verify_code (gcc_jit_context *ctxt, gcc_jit_result *result)\n+{\n+  CHECK_VALUE (result, NULL);\n+\n+  CHECK_STRING_VALUE (gcc_jit_context_get_first_error (ctxt),\n+\t\t      \"builtin \\\"this_is_not_a_builtin\\\" not found\");\n+}\n","prefixes":["committed"]}