From patchwork Sat Nov 10 18:54:34 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tobias Burnus X-Patchwork-Id: 198203 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id D0B1C2C0086 for ; Sun, 11 Nov 2012 05:54:48 +1100 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1353178490; h=Comment: DomainKey-Signature:Received:Received:Received:Received: Message-ID:Date:From:User-Agent:MIME-Version:To:CC:Subject: References:In-Reply-To:Content-Type:Mailing-List:Precedence: List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender: Delivered-To; bh=laIWlc3T4/OvZ+LS6UHDmj16Q4U=; b=Jv/BvfReLThG1yq U2N+GmEMYflsq3sKSVwsm6MhyhDyxuDY+4X4u+3dvOuPOsA8UMz6uv3QPx0IuZUQ WsqwhjyXPLFJg1uUtglP+HVfuOBC53Syy3BW2Yc6M2W5W8pbAaFRaBedtTWwtAlF 9+yYNyrwXiDiMIijTEiL4aI+fyeI= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Message-ID:Date:From:User-Agent:MIME-Version:To:CC:Subject:References:In-Reply-To:Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=olCfJW/8MnSamDaBdc4bW0Wchb3Q/UxXb+rPMxkgG77psqOm2+RjVZ4CwnvTQj mT8DAHTzApuo36DETYMfnx0REKU6hM9j2WHOzMYydRWfy7Q/oudjxnB3TaAzeUg6 GfO9HuKtt8wucQfffJVjtDogqZe5G3nOHEW6EourMQ2h0=; Received: (qmail 10864 invoked by alias); 10 Nov 2012 18:54:44 -0000 Received: (qmail 10853 invoked by uid 22791); 10 Nov 2012 18:54:43 -0000 X-SWARE-Spam-Status: No, hits=-2.8 required=5.0 tests=AWL, BAYES_00, KHOP_THREADED, RCVD_IN_DNSWL_NONE, TW_TM X-Spam-Check-By: sourceware.org Received: from mx01.qsc.de (HELO mx01.qsc.de) (213.148.129.14) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 10 Nov 2012 18:54:37 +0000 Received: from [192.168.178.25] (port-92-195-110-241.dynamic.qsc.de [92.195.110.241]) by mx01.qsc.de (Postfix) with ESMTP id CB9283CDEA; Sat, 10 Nov 2012 19:54:34 +0100 (CET) Message-ID: <509EA2EA.50104@net-b.de> Date: Sat, 10 Nov 2012 19:54:34 +0100 From: Tobias Burnus User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:16.0) Gecko/20121025 Thunderbird/16.0.2 MIME-Version: 1.0 To: Jakub Jelinek CC: gcc patches , Wei Mi , Kostya Serebryany , Xinliang David Li , Dodji Seketeli Subject: Re: [asan] Patch - fix an ICE in asan.c References: <509D6965.5040405@net-b.de> <20121110091658.GI1886@tucnak.redhat.com> <509E53E2.5080908@net-b.de> <509E7051.7030407@net-b.de> In-Reply-To: <509E7051.7030407@net-b.de> Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Tobias Burnus wrote: > I spoke too early. With the updated patch, there is no ICE, but one > crashes for the following valid program with: But with my original patch, it works. To recap: My "if (gsi_end_p (i)) break;" (cf. [1]) fixes my original issue (ICE for fail31.ii; [1]) and gives the correct diagnostic at run time for strlen in the code [4] (both for correct and out-of-bounds programs). While Jakub's "*iter = gsi_for_stmt (call);" (cf. [3]) fixes the ICE for my fail10.ii program [2]; I haven't tried to construct a run-time version for that code. Updated patches attached (for the "asan" branch and for the trunk on top of Dodji's patches; I have only tested the latter). Hopefully, the test suite will be working soon, it should help finding such issues. Tobias [1] fail31.ii (strlen ICE): http://gcc.gnu.org/ml/gcc-patches/2012-11/msg00786.html [2] fail10.ii (control flow in BB ICE): http://gcc.gnu.org/ml/gcc-patches/2012-11/msg00791.html [3] Jakub's patch: http://gcc.gnu.org/ml/gcc-patches/2012-11/msg00801.html [4] strlen run test: http://gcc.gnu.org/ml/gcc-patches/2012-11/msg00809.html (This patch is for the trunk after the "asan" patch has been applied.) 2012-11-10 Tobias Burnus Jakub Jelinek * asan.c (maybe_instrument_builtin_call): Set *iter to gsi for the call at the end. (transform_statements): Leave loop when gsi_end_p. --- gcc/asan.c.orig 2012-11-09 21:26:26.000000000 +0100 +++ gcc/asan.c 2012-11-10 19:23:33.000000000 +0100 @@ -1302,16 +1302,17 @@ instrument_builtin_call (gimple_stmt_ite instrument_mem_region_access (source0, len, iter, loc, /*is_store=*/false); if (source1 != NULL_TREE) instrument_mem_region_access (source1, len, iter, loc, /*is_store=*/false); else if (dest != NULL_TREE) instrument_mem_region_access (dest, len, iter, loc, /*is_store=*/true); + *iter = gsi_for_stmt (call); } } /* Instrument the assignment statement ITER if it is subject to instrumentation. */ static void instrument_assignment (gimple_stmt_iterator *iter) @@ -1357,16 +1358,18 @@ transform_statements (void) for (i = gsi_start_bb (bb); !gsi_end_p (i); gsi_next (&i)) { gimple s = gsi_stmt (i); if (gimple_assign_single_p (s)) instrument_assignment (&i); else if (is_gimple_call (s)) maybe_instrument_call (&i); + if (gsi_end_p (i)) + break; } } } /* Build struct __asan_global { const void *__beg;